1b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b3f79822SAndrew Rist * distributed with this work for additional information 6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b3f79822SAndrew Rist * software distributed under the License is distributed on an 15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17b3f79822SAndrew Rist * specific language governing permissions and limitations 18b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b3f79822SAndrew Rist *************************************************************/ 21b3f79822SAndrew Rist 22b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <svx/svdpage.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <svx/xtable.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "scitems.hxx" 34cdf0e10cSrcweir #include <tools/gen.hxx> 35cdf0e10cSrcweir #include <svtools/ctrltool.hxx> 36cdf0e10cSrcweir #include <editeng/flstitem.hxx> 37cdf0e10cSrcweir #include <svx/drawitem.hxx> 38cdf0e10cSrcweir #include <sfx2/printer.hxx> 39cdf0e10cSrcweir #include <svl/smplhint.hxx> 40cdf0e10cSrcweir #include <svx/svditer.hxx> 41cdf0e10cSrcweir #include <svx/svdobj.hxx> 42cdf0e10cSrcweir #include <svx/svdoole2.hxx> 43cdf0e10cSrcweir #include <vcl/svapp.hxx> 44cdf0e10cSrcweir #include <svl/asiancfg.hxx> 45cdf0e10cSrcweir #include <editeng/forbiddencharacterstable.hxx> 46cdf0e10cSrcweir #include <editeng/unolingu.hxx> 47cdf0e10cSrcweir #include <rtl/logfile.hxx> 48cdf0e10cSrcweir 49cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 50cdf0e10cSrcweir #include <basic/sbstar.hxx> 51cdf0e10cSrcweir #include <basic/basmgr.hxx> 52cdf0e10cSrcweir #include <sfx2/app.hxx> 53cdf0e10cSrcweir 54cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 55cdf0e10cSrcweir /* 56cdf0e10cSrcweir #include <svdrwetc.hxx> 57cdf0e10cSrcweir #include <svdrwobx.hxx> 58cdf0e10cSrcweir #include <sostor.hxx> 59cdf0e10cSrcweir */ 60cdf0e10cSrcweir #include "drwlayer.hxx" 61cdf0e10cSrcweir #include "stlpool.hxx" 62cdf0e10cSrcweir #include "docsh.hxx" 63cdf0e10cSrcweir #include "docshimp.hxx" 64cdf0e10cSrcweir #include "docfunc.hxx" 65cdf0e10cSrcweir #include "sc.hrc" 66cdf0e10cSrcweir 67cdf0e10cSrcweir using namespace com::sun::star; 68cdf0e10cSrcweir 69cdf0e10cSrcweir //------------------------------------------------------------------ 70cdf0e10cSrcweir 71cdf0e10cSrcweir sal_Bool __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" ); 74cdf0e10cSrcweir 75cdf0e10cSrcweir sal_Bool bRet = SfxObjectShell::InitNew( xStor ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir aDocument.MakeTable(0); 78cdf0e10cSrcweir // zusaetzliche Tabellen werden von der ersten View angelegt, 79cdf0e10cSrcweir // wenn bIsEmpty dann noch sal_True ist 80cdf0e10cSrcweir 81cdf0e10cSrcweir if( bRet ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ), 84cdf0e10cSrcweir (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) ); 85cdf0e10cSrcweir // hier muss auch der Start angepasst werden 86cdf0e10cSrcweir SetVisAreaOrSize( Rectangle( Point(), aSize ), sal_True ); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew 90cdf0e10cSrcweir 91cdf0e10cSrcweir // InitOptions sets the document languages, must be called before CreateStandardStyles 92cdf0e10cSrcweir InitOptions(false); 93cdf0e10cSrcweir 94cdf0e10cSrcweir aDocument.GetStyleSheetPool()->CreateStandardStyles(); 95cdf0e10cSrcweir aDocument.UpdStlShtPtrsFrmNms(); 96cdf0e10cSrcweir 97cdf0e10cSrcweir // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt! 98cdf0e10cSrcweir 99cdf0e10cSrcweir InitItems(); 100cdf0e10cSrcweir CalcOutputFactor(); 101cdf0e10cSrcweir #if 0 102cdf0e10cSrcweir uno::Any aGlobs; 103cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs(1); 104cdf0e10cSrcweir aArgs[ 0 ] <<= GetModel(); 105cdf0e10cSrcweir aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); 106cdf0e10cSrcweir GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); 107cdf0e10cSrcweir // Fake ThisComponent being setup by Activate ( which is a view 108cdf0e10cSrcweir // related thing ), 109cdf0e10cSrcweir // a) if another document is opened then in theory ThisComponent 110cdf0e10cSrcweir // will be reset as before, 111cdf0e10cSrcweir // b) when this document is 'really' Activated then ThisComponent 112cdf0e10cSrcweir // again will be set as before 113cdf0e10cSrcweir // The only wrinkle seems if this document is loaded 'InVisible' 114cdf0e10cSrcweir // but.. I don't see that this is possible from the vba API 115cdf0e10cSrcweir // I could be wrong though 116cdf0e10cSrcweir // There may be implications setting the current component 117cdf0e10cSrcweir // too early :-/ so I will just manually set the Basic Variables 118cdf0e10cSrcweir BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); 119cdf0e10cSrcweir if ( pAppMgr ) 120cdf0e10cSrcweir pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); 121cdf0e10cSrcweir #endif 122cdf0e10cSrcweir 123cdf0e10cSrcweir return bRet; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir //------------------------------------------------------------------ 127cdf0e10cSrcweir 128cdf0e10cSrcweir sal_Bool ScDocShell::IsEmpty() const 129cdf0e10cSrcweir { 130cdf0e10cSrcweir return bIsEmpty; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir 134cdf0e10cSrcweir void ScDocShell::SetEmpty(sal_Bool bSet) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir bIsEmpty = bSet; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir //------------------------------------------------------------------ 140cdf0e10cSrcweir 141cdf0e10cSrcweir void ScDocShell::InitItems() 142cdf0e10cSrcweir { 143cdf0e10cSrcweir // AllItemSet fuer Controller mit benoetigten Items fuellen: 144cdf0e10cSrcweir 145cdf0e10cSrcweir // if ( pImpl->pFontList ) 146cdf0e10cSrcweir // delete pImpl->pFontList; 147cdf0e10cSrcweir 148cdf0e10cSrcweir // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt 149cdf0e10cSrcweir 150cdf0e10cSrcweir // pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() ); 151cdf0e10cSrcweir //PutItem( SvxFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST ) ); 152cdf0e10cSrcweir UpdateFontList(); 153cdf0e10cSrcweir 154cdf0e10cSrcweir ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer(); 155cdf0e10cSrcweir if (pDrawLayer) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir PutItem( SvxColorTableItem ( pDrawLayer->GetColorTable(), SID_COLOR_TABLE ) ); 158cdf0e10cSrcweir PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) ); 159cdf0e10cSrcweir PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) ); 160cdf0e10cSrcweir PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) ); 161cdf0e10cSrcweir PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) ); 162cdf0e10cSrcweir PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) ); 163cdf0e10cSrcweir 164cdf0e10cSrcweir // andere Anpassungen nach dem Anlegen des DrawLayers 165cdf0e10cSrcweir 166cdf0e10cSrcweir pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir //if (SfxObjectShell::HasSbxObject()) 169cdf0e10cSrcweir pDrawLayer->UpdateBasic(); // DocShell-Basic in DrawPages setzen 170cdf0e10cSrcweir } 171cdf0e10cSrcweir else 172cdf0e10cSrcweir { 173cdf0e10cSrcweir // always use global color table instead of local copy 174*97e8a929SArmin Le Grand PutItem( SvxColorTableItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) ); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir if ( !aDocument.GetForbiddenCharacters().isValid() || 178cdf0e10cSrcweir !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir // get settings from SvxAsianConfig 181cdf0e10cSrcweir SvxAsianConfig aAsian( sal_False ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir if ( !aDocument.GetForbiddenCharacters().isValid() ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir // set forbidden characters if necessary 186cdf0e10cSrcweir uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales(); 187cdf0e10cSrcweir if (aLocales.getLength()) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir vos::ORef<SvxForbiddenCharactersTable> xForbiddenTable = 190cdf0e10cSrcweir new SvxForbiddenCharactersTable( aDocument.GetServiceManager() ); 191cdf0e10cSrcweir 192cdf0e10cSrcweir const lang::Locale* pLocales = aLocales.getConstArray(); 193cdf0e10cSrcweir for (sal_Int32 i = 0; i < aLocales.getLength(); i++) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir i18n::ForbiddenCharacters aForbidden; 196cdf0e10cSrcweir aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine ); 197cdf0e10cSrcweir LanguageType eLang = SvxLocaleToLanguage(pLocales[i]); 198cdf0e10cSrcweir //pDoc->SetForbiddenCharacters( eLang, aForbidden ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden ); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir aDocument.SetForbiddenCharacters( xForbiddenTable ); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir if ( !aDocument.IsValidAsianCompression() ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir // set compression mode from configuration if not already set (e.g. XML import) 210cdf0e10cSrcweir aDocument.SetAsianCompression( sal::static_int_cast<sal_uInt8>( aAsian.GetCharDistanceCompression() ) ); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir if ( !aDocument.IsValidAsianKerning() ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir // set asian punctuation kerning from configuration if not already set (e.g. XML import) 216cdf0e10cSrcweir aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed 217cdf0e10cSrcweir } 218cdf0e10cSrcweir } 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir //------------------------------------------------------------------ 222cdf0e10cSrcweir 223cdf0e10cSrcweir void ScDocShell::ResetDrawObjectShell() 224cdf0e10cSrcweir { 225cdf0e10cSrcweir ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer(); 226cdf0e10cSrcweir if (pDrawLayer) 227cdf0e10cSrcweir pDrawLayer->SetObjectShell( NULL ); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir //------------------------------------------------------------------ 231cdf0e10cSrcweir 232cdf0e10cSrcweir void __EXPORT ScDocShell::Activate() 233cdf0e10cSrcweir { 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir 237cdf0e10cSrcweir void __EXPORT ScDocShell::Deactivate() 238cdf0e10cSrcweir { 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir //------------------------------------------------------------------ 242cdf0e10cSrcweir 243cdf0e10cSrcweir 244cdf0e10cSrcweir ScDrawLayer* ScDocShell::MakeDrawLayer() 245cdf0e10cSrcweir { 246cdf0e10cSrcweir ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer(); 247cdf0e10cSrcweir if (!pDrawLayer) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::MakeDrawLayer" ); 250cdf0e10cSrcweir 251cdf0e10cSrcweir aDocument.InitDrawLayer(this); 252cdf0e10cSrcweir pDrawLayer = aDocument.GetDrawLayer(); 253cdf0e10cSrcweir InitItems(); // incl. Undo und Basic 254cdf0e10cSrcweir Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) ); 255cdf0e10cSrcweir if (nDocumentLock) 256cdf0e10cSrcweir pDrawLayer->setLock(sal_True); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir return pDrawLayer; 259cdf0e10cSrcweir } 260