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