15b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 55b190011SAndrew Rist * distributed with this work for additional information 65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 85b190011SAndrew Rist * "License"); you may not use this file except in compliance 95b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 145b190011SAndrew Rist * software distributed under the License is distributed on an 155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165b190011SAndrew Rist * KIND, either express or implied. See the License for the 175b190011SAndrew Rist * specific language governing permissions and limitations 185b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 205b190011SAndrew Rist *************************************************************/ 215b190011SAndrew Rist 225b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "PageListWatcher.hxx" 28cdf0e10cSrcweir #include <com/sun/star/text/WritingMode.hpp> 29cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp> 30cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp> 31cdf0e10cSrcweir #include <editeng/forbiddencharacterstable.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <svx/svxids.hrc> 34cdf0e10cSrcweir #include <svl/srchitem.hxx> 35cdf0e10cSrcweir #include <editeng/eeitem.hxx> 36cdf0e10cSrcweir #include <editeng/scriptspaceitem.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <unotools/useroptions.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <sfx2/printer.hxx> 41cdf0e10cSrcweir #include <sfx2/app.hxx> 42cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 43cdf0e10cSrcweir #include <svx/dialogs.hrc> 44cdf0e10cSrcweir #include "Outliner.hxx" 45cdf0e10cSrcweir #include "app.hxx" 46cdf0e10cSrcweir #include <editeng/eeitem.hxx> 47cdf0e10cSrcweir #include <editeng/editstat.hxx> 48cdf0e10cSrcweir #include <editeng/fontitem.hxx> 49cdf0e10cSrcweir #include <svl/flagitem.hxx> 50cdf0e10cSrcweir #include <svx/svdoattr.hxx> 51cdf0e10cSrcweir #include <svx/svdotext.hxx> 52cdf0e10cSrcweir #include <editeng/bulitem.hxx> 53cdf0e10cSrcweir #include <editeng/numitem.hxx> 54cdf0e10cSrcweir #include <svx/svditer.hxx> 55cdf0e10cSrcweir #include <editeng/unolingu.hxx> 56cdf0e10cSrcweir #include <svl/itempool.hxx> 57cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 58cdf0e10cSrcweir #include <svx/xtable.hxx> 59cdf0e10cSrcweir #include <com/sun/star/linguistic2/XHyphenator.hpp> 60cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp> 61cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 62cdf0e10cSrcweir #include <editeng/outlobj.hxx> 63cdf0e10cSrcweir #include <unotools/saveopt.hxx> 64cdf0e10cSrcweir #include <comphelper/extract.hxx> 65cdf0e10cSrcweir #include <i18npool/mslangid.hxx> 66cdf0e10cSrcweir #include <unotools/charclass.hxx> 67cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 68cdf0e10cSrcweir #ifndef _SVTOOLS_PATHOPTIONS_HXX_ 69cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 70cdf0e10cSrcweir #endif 71cdf0e10cSrcweir #include <unotools/lingucfg.hxx> 72cdf0e10cSrcweir #include <unotools/linguprops.hxx> 73cdf0e10cSrcweir 74cdf0e10cSrcweir #include "eetext.hxx" 75cdf0e10cSrcweir #include "drawdoc.hxx" 76cdf0e10cSrcweir #include "sdpage.hxx" 77cdf0e10cSrcweir #include "pglink.hxx" 78cdf0e10cSrcweir #include "sdattr.hxx" 79cdf0e10cSrcweir #include "glob.hrc" 80cdf0e10cSrcweir #include "glob.hxx" 81cdf0e10cSrcweir #include "stlpool.hxx" 82cdf0e10cSrcweir #include "sdiocmpt.hxx" 83cdf0e10cSrcweir #include "sdresid.hxx" 84cdf0e10cSrcweir #include "cusshow.hxx" 85cdf0e10cSrcweir #include "../ui/inc/DrawDocShell.hxx" 86cdf0e10cSrcweir #include "../ui/inc/GraphicDocShell.hxx" 87cdf0e10cSrcweir #include "../ui/inc/sdxfer.hxx" 88cdf0e10cSrcweir #include "../ui/inc/ViewShell.hxx" 89cdf0e10cSrcweir #include "../ui/inc/optsitem.hxx" 90cdf0e10cSrcweir #include "../ui/inc/FrameView.hxx" 91cdf0e10cSrcweir 92cdf0e10cSrcweir // #90477# 93cdf0e10cSrcweir #include <tools/tenccvt.hxx> 94cdf0e10cSrcweir 95cdf0e10cSrcweir using ::rtl::OUString; 96cdf0e10cSrcweir using namespace ::sd; 97cdf0e10cSrcweir using namespace ::com::sun::star; 98cdf0e10cSrcweir using namespace ::com::sun::star::uno; 99cdf0e10cSrcweir using namespace ::com::sun::star::lang; 100cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2; 101cdf0e10cSrcweir 102cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 103cdf0e10cSrcweir 104cdf0e10cSrcweir TYPEINIT1( SdDrawDocument, FmFormModel ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir SdDrawDocument* SdDrawDocument::pDocLockedInsertingLinks = NULL; 107cdf0e10cSrcweir 108cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 109cdf0e10cSrcweir 110cdf0e10cSrcweir PresentationSettings::PresentationSettings() 111cdf0e10cSrcweir : mbAll( true ), 112cdf0e10cSrcweir mbEndless( false ), 113cdf0e10cSrcweir mbCustomShow(false), 114cdf0e10cSrcweir mbManual( false ), 115cdf0e10cSrcweir mbMouseVisible( false ), 116cdf0e10cSrcweir mbMouseAsPen( false ), 117cdf0e10cSrcweir mbLockedPages( false ), 118cdf0e10cSrcweir mbAlwaysOnTop( false ), 119cdf0e10cSrcweir mbFullScreen( true ), 120cdf0e10cSrcweir mbAnimationAllowed( true ), 121cdf0e10cSrcweir mnPauseTimeout( 10 ), 122cdf0e10cSrcweir mbShowPauseLogo( false ), 123cdf0e10cSrcweir mbStartWithNavigator(false) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir // --------------------------------------------------------------------------- 128cdf0e10cSrcweir 129cdf0e10cSrcweir PresentationSettings::PresentationSettings( const PresentationSettings& r ) 130cdf0e10cSrcweir : maPresPage( r.maPresPage ), 131cdf0e10cSrcweir mbAll( r.mbAll ), 132cdf0e10cSrcweir mbEndless( r.mbEndless ), 133cdf0e10cSrcweir mbCustomShow( r.mbCustomShow ), 134cdf0e10cSrcweir mbManual( r.mbManual ), 135cdf0e10cSrcweir mbMouseVisible( r.mbMouseVisible ), 136cdf0e10cSrcweir mbMouseAsPen( r.mbMouseAsPen ), 137cdf0e10cSrcweir mbLockedPages( r.mbLockedPages ), 138cdf0e10cSrcweir mbAlwaysOnTop( r.mbAlwaysOnTop ), 139cdf0e10cSrcweir mbFullScreen( r.mbFullScreen ), 140cdf0e10cSrcweir mbAnimationAllowed( r.mbAnimationAllowed ), 141cdf0e10cSrcweir mnPauseTimeout( r.mnPauseTimeout ), 142cdf0e10cSrcweir mbShowPauseLogo( r.mbShowPauseLogo ), 143cdf0e10cSrcweir mbStartWithNavigator( r.mbStartWithNavigator ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir // --------------------------------------------------------------------------- 148cdf0e10cSrcweir 149cdf0e10cSrcweir SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) 150cdf0e10cSrcweir : FmFormModel( SvtPathOptions().GetPalettePath(), NULL, pDrDocSh ) 1510deba7fbSSteve Yin , bReadOnly(sal_False) 152cdf0e10cSrcweir , mpOutliner(NULL) 153cdf0e10cSrcweir , mpInternalOutliner(NULL) 154cdf0e10cSrcweir , mpWorkStartupTimer(NULL) 155cdf0e10cSrcweir , mpOnlineSpellingTimer(NULL) 156cdf0e10cSrcweir , mpOnlineSpellingList(NULL) 157cdf0e10cSrcweir , mpOnlineSearchItem(NULL) 158cdf0e10cSrcweir , mpFrameViewList( new List() ) 159cdf0e10cSrcweir , mpCustomShowList(NULL) 160cdf0e10cSrcweir , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh)) 161cdf0e10cSrcweir , mpCreatingTransferable( NULL ) 162cdf0e10cSrcweir , mbHasOnlineSpellErrors(sal_False) 163cdf0e10cSrcweir , mbInitialOnlineSpellingEnabled(sal_True) 164cdf0e10cSrcweir , mbNewOrLoadCompleted(sal_False) 165cdf0e10cSrcweir , mbStartWithPresentation( false ) 166cdf0e10cSrcweir , meLanguage( LANGUAGE_SYSTEM ) 167cdf0e10cSrcweir , meLanguageCJK( LANGUAGE_SYSTEM ) 168cdf0e10cSrcweir , meLanguageCTL( LANGUAGE_SYSTEM ) 169cdf0e10cSrcweir , mePageNumType(SVX_ARABIC) 170cdf0e10cSrcweir , mbAllocDocSh(sal_False) 171cdf0e10cSrcweir , meDocType(eType) 172cdf0e10cSrcweir , mpCharClass(NULL) 173cdf0e10cSrcweir , mpLocale(NULL) 174cdf0e10cSrcweir , mpDrawPageListWatcher(0) 175cdf0e10cSrcweir , mpMasterPageListWatcher(0) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir // #109538# 178cdf0e10cSrcweir mpDrawPageListWatcher = ::std::auto_ptr<ImpDrawPageListWatcher>( 179cdf0e10cSrcweir new ImpDrawPageListWatcher(*this)); 180cdf0e10cSrcweir mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>( 181cdf0e10cSrcweir new ImpMasterPageListWatcher(*this)); 182cdf0e10cSrcweir 183*ee62af74Smarcus SetObjectShell(pDrDocSh); // for the VCDrawModel 184cdf0e10cSrcweir 185cdf0e10cSrcweir if (mpDocSh) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir SetSwapGraphics(sal_True); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190*ee62af74Smarcus // set measurement unit (of App) and scale (of SdMod) 191cdf0e10cSrcweir sal_Int32 nX, nY; 192cdf0e10cSrcweir SdOptions* pOptions = SD_MOD()->GetSdOptions(meDocType); 193cdf0e10cSrcweir pOptions->GetScale( nX, nY ); 194cdf0e10cSrcweir 195cdf0e10cSrcweir // #92067# Allow UI scale only for draw documents. 196cdf0e10cSrcweir if( eType == DOCUMENT_TYPE_DRAW ) 197cdf0e10cSrcweir SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) ); // user-defined 198cdf0e10cSrcweir else 199cdf0e10cSrcweir SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) ); // default 200cdf0e10cSrcweir 201cdf0e10cSrcweir SetScaleUnit(MAP_100TH_MM); 202cdf0e10cSrcweir SetScaleFraction(Fraction(1, 1)); 203cdf0e10cSrcweir SetDefaultFontHeight(847); // 24p 204cdf0e10cSrcweir 205cdf0e10cSrcweir pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM); 206cdf0e10cSrcweir pItemPool->FreezeIdRanges(); 207cdf0e10cSrcweir SetTextDefaults(); 208cdf0e10cSrcweir 209*ee62af74Smarcus // also the DrawingEngine needs to know where it is 210cdf0e10cSrcweir FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) ); 211cdf0e10cSrcweir 212*ee62af74Smarcus // Set the StyleSheetPool to the DrawOutliner, in order to read text objects 213*ee62af74Smarcus // correctly. The link to the StyleRequest handler of the document will be 214*ee62af74Smarcus // set first in NewOrLoadCompleted, because only then all templates exist. 215cdf0e10cSrcweir SdrOutliner& rOutliner = GetDrawOutliner(); 216cdf0e10cSrcweir rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 217cdf0e10cSrcweir SetCalcFieldValueHdl( &rOutliner ); 218cdf0e10cSrcweir 219cdf0e10cSrcweir // set linguistic options 220cdf0e10cSrcweir { 221cdf0e10cSrcweir const SvtLinguConfig aLinguConfig; 222cdf0e10cSrcweir SvtLinguOptions aOptions; 223cdf0e10cSrcweir aLinguConfig.GetOptions( aOptions ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, 226cdf0e10cSrcweir ::com::sun::star::i18n::ScriptType::LATIN), EE_CHAR_LANGUAGE ); 227cdf0e10cSrcweir SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, 228cdf0e10cSrcweir ::com::sun::star::i18n::ScriptType::ASIAN), EE_CHAR_LANGUAGE_CJK ); 229cdf0e10cSrcweir SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, 230cdf0e10cSrcweir ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL ); 231cdf0e10cSrcweir 232cdf0e10cSrcweir mbOnlineSpell = aOptions.bIsSpellAuto; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage ); 236cdf0e10cSrcweir mpLocale = new ::com::sun::star::lang::Locale( MsLangId::convertLanguageToLocale( eRealLanguage )); 237cdf0e10cSrcweir mpCharClass = new CharClass( *mpLocale ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir // If the current application language is a language that uses right-to-left text... 240cdf0e10cSrcweir LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguage(); 241cdf0e10cSrcweir if( MsLangId::isRightToLeft( eRealCTLLanguage ) ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir // ... then we have to set this as a default 244cdf0e10cSrcweir SetDefaultWritingMode( ::com::sun::star::text::WritingMode_RL_TB ); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text 248cdf0e10cSrcweir if( ( LANGUAGE_KOREAN == eRealCTLLanguage ) || ( LANGUAGE_KOREAN_JOHAB == eRealCTLLanguage ) || ( LANGUAGE_JAPANESE == eRealCTLLanguage ) ) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) ); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253*ee62af74Smarcus // set DefTab and SpellOptions 254*ee62af74Smarcus // now at the module (SD) 255cdf0e10cSrcweir sal_uInt16 nDefTab = pOptions->GetDefTab(); 256cdf0e10cSrcweir SetDefaultTabulator( nDefTab ); 257cdf0e10cSrcweir 258cdf0e10cSrcweir try 259cdf0e10cSrcweir { 260cdf0e10cSrcweir Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); 261cdf0e10cSrcweir if ( xSpellChecker.is() ) 262cdf0e10cSrcweir rOutliner.SetSpeller( xSpellChecker ); 263cdf0e10cSrcweir 264cdf0e10cSrcweir Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); 265cdf0e10cSrcweir if( xHyphenator.is() ) 266cdf0e10cSrcweir rOutliner.SetHyphenator( xHyphenator ); 267cdf0e10cSrcweir 268cdf0e10cSrcweir SetForbiddenCharsTable( new SvxForbiddenCharactersTable( ::comphelper::getProcessServiceFactory() ) ); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir catch(...) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir DBG_ERROR("Can't get SpellChecker"); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir rOutliner.SetDefaultLanguage( Application::GetSettings().GetLanguage() ); 276cdf0e10cSrcweir 277cdf0e10cSrcweir if (mpDocSh) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir SetLinkManager( new sfx2::LinkManager(mpDocSh) ); 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir sal_uLong nCntrl = rOutliner.GetControlWord(); 283cdf0e10cSrcweir nCntrl |= EE_CNTRL_ALLOWBIGOBJS; 284cdf0e10cSrcweir nCntrl |= EE_CNTRL_URLSFXEXECUTE; 285cdf0e10cSrcweir 286cdf0e10cSrcweir if (mbOnlineSpell) 287cdf0e10cSrcweir nCntrl |= EE_CNTRL_ONLINESPELLING; 288cdf0e10cSrcweir else 289cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_ONLINESPELLING; 290cdf0e10cSrcweir 291cdf0e10cSrcweir nCntrl &= ~ EE_CNTRL_ULSPACESUMMATION; 292cdf0e10cSrcweir if ( meDocType != DOCUMENT_TYPE_IMPRESS ) 293cdf0e10cSrcweir SetSummationOfParagraphs( sal_False ); 294cdf0e10cSrcweir else 295cdf0e10cSrcweir { 296cdf0e10cSrcweir SetSummationOfParagraphs( pOptions->IsSummationOfParagraphs() ); 297cdf0e10cSrcweir if ( pOptions->IsSummationOfParagraphs() ) 298cdf0e10cSrcweir nCntrl |= EE_CNTRL_ULSPACESUMMATION; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir rOutliner.SetControlWord(nCntrl); 301cdf0e10cSrcweir 302cdf0e10cSrcweir // Initialize the printer independent layout mode. 303cdf0e10cSrcweir SetPrinterIndependentLayout (pOptions->GetPrinterIndependentLayout()); 304cdf0e10cSrcweir 305*ee62af74Smarcus // Set the StyleSheetPool to the HitTestOutliner. 306*ee62af74Smarcus // The link to the StyleRequest handler of the document will be set 307*ee62af74Smarcus // first in NewOrLoadCompleted, because only then all templates exist. 308cdf0e10cSrcweir SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() ); 309cdf0e10cSrcweir pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() ); 310cdf0e10cSrcweir 311cdf0e10cSrcweir SetCalcFieldValueHdl( pHitTestOutliner ); 312cdf0e10cSrcweir 313cdf0e10cSrcweir try 314cdf0e10cSrcweir { 315cdf0e10cSrcweir Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); 316cdf0e10cSrcweir if ( xSpellChecker.is() ) 317cdf0e10cSrcweir pHitTestOutliner->SetSpeller( xSpellChecker ); 318cdf0e10cSrcweir 319cdf0e10cSrcweir Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); 320cdf0e10cSrcweir if( xHyphenator.is() ) 321cdf0e10cSrcweir pHitTestOutliner->SetHyphenator( xHyphenator ); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir catch(...) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir DBG_ERROR("Can't get SpellChecker"); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguage() ); 329cdf0e10cSrcweir 330cdf0e10cSrcweir sal_uLong nCntrl2 = pHitTestOutliner->GetControlWord(); 331cdf0e10cSrcweir nCntrl2 |= EE_CNTRL_ALLOWBIGOBJS; 332cdf0e10cSrcweir nCntrl2 |= EE_CNTRL_URLSFXEXECUTE; 333cdf0e10cSrcweir nCntrl2 &= ~EE_CNTRL_ONLINESPELLING; 334cdf0e10cSrcweir 335cdf0e10cSrcweir nCntrl2 &= ~ EE_CNTRL_ULSPACESUMMATION; 336cdf0e10cSrcweir if ( pOptions->IsSummationOfParagraphs() ) 337cdf0e10cSrcweir nCntrl2 |= EE_CNTRL_ULSPACESUMMATION; 338cdf0e10cSrcweir 339cdf0e10cSrcweir pHitTestOutliner->SetControlWord( nCntrl2 ); 340cdf0e10cSrcweir 341cdf0e10cSrcweir /************************************************************************** 342*ee62af74Smarcus * Create layer 343cdf0e10cSrcweir * 344*ee62af74Smarcus * The following default layer will created on Pages and MasterPages: 345cdf0e10cSrcweir * 346*ee62af74Smarcus * Layer STR_LAYOUT : Default layer for all drawing objects 347cdf0e10cSrcweir * 348*ee62af74Smarcus * Layer STR_BCKGRND : Background of the MasterPage 349*ee62af74Smarcus * (it's currently not used on normal Pages) 350cdf0e10cSrcweir * 351*ee62af74Smarcus * Layer STR_BCKGRNDOBJ : Objects on the background of the MasterPage 352*ee62af74Smarcus * (it's currently not used on normal Pages) 353cdf0e10cSrcweir * 354*ee62af74Smarcus * Layer STR_CONTROLS : Default layer for Controls 355cdf0e10cSrcweir * 356cdf0e10cSrcweir **************************************************************************/ 357cdf0e10cSrcweir { 358cdf0e10cSrcweir String aControlLayerName( SdResId(STR_LAYER_CONTROLS) ); 359cdf0e10cSrcweir 360cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = GetLayerAdmin(); 361cdf0e10cSrcweir rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_LAYOUT)) ); 362cdf0e10cSrcweir rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRND)) ); 363cdf0e10cSrcweir rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRNDOBJ)) ); 364cdf0e10cSrcweir rLayerAdmin.NewLayer( aControlLayerName ); 365cdf0e10cSrcweir rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_MEASURELINES)) ); 366cdf0e10cSrcweir 367cdf0e10cSrcweir rLayerAdmin.SetControlLayerName(aControlLayerName); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir /************************************************************************* 374cdf0e10cSrcweir |* 375*ee62af74Smarcus |* Destructor 376cdf0e10cSrcweir |* 377cdf0e10cSrcweir \************************************************************************/ 378cdf0e10cSrcweir 379cdf0e10cSrcweir SdDrawDocument::~SdDrawDocument() 380cdf0e10cSrcweir { 381cdf0e10cSrcweir Broadcast(SdrHint(HINT_MODELCLEARED)); 382cdf0e10cSrcweir 383cdf0e10cSrcweir if (mpWorkStartupTimer) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir if ( mpWorkStartupTimer->IsActive() ) 386cdf0e10cSrcweir mpWorkStartupTimer->Stop(); 387cdf0e10cSrcweir 388cdf0e10cSrcweir delete mpWorkStartupTimer; 389cdf0e10cSrcweir mpWorkStartupTimer = NULL; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir StopOnlineSpelling(); 393cdf0e10cSrcweir delete mpOnlineSearchItem; 394cdf0e10cSrcweir mpOnlineSearchItem = NULL; 395cdf0e10cSrcweir 396cdf0e10cSrcweir CloseBookmarkDoc(); 397cdf0e10cSrcweir SetAllocDocSh(sal_False); 398cdf0e10cSrcweir 399cdf0e10cSrcweir // #116168# 400cdf0e10cSrcweir ClearModel(sal_True); 401cdf0e10cSrcweir 402cdf0e10cSrcweir if (pLinkManager) 403cdf0e10cSrcweir { 404*ee62af74Smarcus // deallocate BaseLinks 405cdf0e10cSrcweir if ( pLinkManager->GetLinks().Count() ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() ); 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir delete pLinkManager; 411cdf0e10cSrcweir pLinkManager = NULL; 412cdf0e10cSrcweir } 413cdf0e10cSrcweir 414cdf0e10cSrcweir ::sd::FrameView* pFrameView = NULL; 415cdf0e10cSrcweir 416cdf0e10cSrcweir for (sal_uLong i = 0; i < mpFrameViewList->Count(); i++) 417cdf0e10cSrcweir { 418*ee62af74Smarcus // if necessary delete FrameViews 419cdf0e10cSrcweir pFrameView = 420cdf0e10cSrcweir static_cast< ::sd::FrameView*>(mpFrameViewList->GetObject(i)); 421cdf0e10cSrcweir 422cdf0e10cSrcweir if (pFrameView) 423cdf0e10cSrcweir delete pFrameView; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir delete mpFrameViewList; 427cdf0e10cSrcweir mpFrameViewList = NULL; 428cdf0e10cSrcweir 429cdf0e10cSrcweir if (mpCustomShowList) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir for (sal_uLong j = 0; j < mpCustomShowList->Count(); j++) 432cdf0e10cSrcweir { 433*ee62af74Smarcus // if necessary delete CustomShows 434cdf0e10cSrcweir SdCustomShow* pCustomShow = (SdCustomShow*) mpCustomShowList->GetObject(j); 435cdf0e10cSrcweir delete pCustomShow; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir delete mpCustomShowList; 439cdf0e10cSrcweir mpCustomShowList = NULL; 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir delete mpOutliner; 443cdf0e10cSrcweir mpOutliner = NULL; 444cdf0e10cSrcweir 445cdf0e10cSrcweir delete mpInternalOutliner; 446cdf0e10cSrcweir mpInternalOutliner = NULL; 447cdf0e10cSrcweir 448cdf0e10cSrcweir delete mpLocale; 449cdf0e10cSrcweir mpLocale = NULL; 450cdf0e10cSrcweir 451cdf0e10cSrcweir delete mpCharClass; 452cdf0e10cSrcweir mpCharClass = NULL; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir /************************************************************************* 456cdf0e10cSrcweir |* 457*ee62af74Smarcus |* This methods creates a new document (SdDrawDocument) and gives back a 458*ee62af74Smarcus |* pointer to it. The Drawing Engine uses this method to be able to put 459*ee62af74Smarcus |* the document or parts of it into Clipboard/DragServer. 460cdf0e10cSrcweir |* 461cdf0e10cSrcweir \************************************************************************/ 462cdf0e10cSrcweir 463cdf0e10cSrcweir SdrModel* SdDrawDocument::AllocModel() const 464cdf0e10cSrcweir { 465cdf0e10cSrcweir SdDrawDocument* pNewModel = NULL; 466cdf0e10cSrcweir 467cdf0e10cSrcweir if( mpCreatingTransferable ) 468cdf0e10cSrcweir { 469*ee62af74Smarcus // the document will created for Drag&Drop/Clipboard, 470*ee62af74Smarcus // for this the document has to know a DocShell (SvPersist) 471cdf0e10cSrcweir SfxObjectShell* pObj = NULL; 472cdf0e10cSrcweir ::sd::DrawDocShell* pNewDocSh = NULL; 473cdf0e10cSrcweir 474cdf0e10cSrcweir if( meDocType == DOCUMENT_TYPE_IMPRESS ) 475cdf0e10cSrcweir mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell( 476cdf0e10cSrcweir SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) ); 477cdf0e10cSrcweir else 478cdf0e10cSrcweir mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell( 479cdf0e10cSrcweir SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) ); 480cdf0e10cSrcweir 481cdf0e10cSrcweir pNewDocSh = static_cast< ::sd::DrawDocShell*>( pObj = mpCreatingTransferable->GetDocShell() ); 482cdf0e10cSrcweir pNewDocSh->DoInitNew( NULL ); 483cdf0e10cSrcweir pNewModel = pNewDocSh->GetDoc(); 484cdf0e10cSrcweir 485*ee62af74Smarcus // only necessary for Clipboard, 486*ee62af74Smarcus // for Drag&Drop this will happen in DragServer 487cdf0e10cSrcweir SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) GetStyleSheetPool(); 488cdf0e10cSrcweir SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pNewModel->GetStyleSheetPool(); 489cdf0e10cSrcweir 490cdf0e10cSrcweir pNewStylePool->CopyGraphicSheets(*pOldStylePool); 491cdf0e10cSrcweir pNewStylePool->CopyCellSheets(*pOldStylePool); 492cdf0e10cSrcweir pNewStylePool->CopyTableStyles(*pOldStylePool); 493cdf0e10cSrcweir 494cdf0e10cSrcweir 495cdf0e10cSrcweir for (sal_uInt16 i = 0; i < GetMasterSdPageCount(PK_STANDARD); i++) 496cdf0e10cSrcweir { 497*ee62af74Smarcus // take all layouts of the MasterPage 498cdf0e10cSrcweir String aOldLayoutName(((SdDrawDocument*) this)->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName()); 499cdf0e10cSrcweir aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) ); 500cdf0e10cSrcweir SdStyleSheetVector aCreatedSheets; 501cdf0e10cSrcweir pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets ); 502cdf0e10cSrcweir } 503cdf0e10cSrcweir 504cdf0e10cSrcweir pNewModel->NewOrLoadCompleted( DOC_LOADED ); // loaded from source document 505cdf0e10cSrcweir } 506cdf0e10cSrcweir else if( mbAllocDocSh ) 507cdf0e10cSrcweir { 508*ee62af74Smarcus // a DocShell will be created which will be returned with GetAllocedDocSh() 509cdf0e10cSrcweir SdDrawDocument* pDoc = (SdDrawDocument*) this; 510cdf0e10cSrcweir pDoc->SetAllocDocSh(sal_False); 511cdf0e10cSrcweir pDoc->mxAllocedDocShRef = new ::sd::DrawDocShell( 512cdf0e10cSrcweir SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType); 513cdf0e10cSrcweir pDoc->mxAllocedDocShRef->DoInitNew(NULL); 514cdf0e10cSrcweir pNewModel = pDoc->mxAllocedDocShRef->GetDoc(); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir else 517cdf0e10cSrcweir { 518cdf0e10cSrcweir pNewModel = new SdDrawDocument(meDocType, NULL); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir 521cdf0e10cSrcweir return pNewModel; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir /************************************************************************* 525cdf0e10cSrcweir |* 526*ee62af74Smarcus |* This methods creates a new page (SdPage) and gives back a pointer to it. 527*ee62af74Smarcus |* The Drawing Engine uses this method when loading to create pages (whose 528*ee62af74Smarcus |* types are not knowed for it because these are DERIVATIONS of SdrPage). 529cdf0e10cSrcweir |* 530cdf0e10cSrcweir \************************************************************************/ 531cdf0e10cSrcweir 532cdf0e10cSrcweir SdrPage* SdDrawDocument::AllocPage(FASTBOOL bMasterPage) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir return new SdPage(*this, NULL, (sal_Bool)bMasterPage); 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir /************************************************************************* 538cdf0e10cSrcweir |* 539*ee62af74Smarcus |* SetChanged(), the modele was changed 540cdf0e10cSrcweir |* 541cdf0e10cSrcweir \************************************************************************/ 542cdf0e10cSrcweir 543cdf0e10cSrcweir void SdDrawDocument::SetChanged(sal_Bool bFlag) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir if (mpDocSh) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified()) 548cdf0e10cSrcweir { 549*ee62af74Smarcus // forward to baseclass 550cdf0e10cSrcweir FmFormModel::SetChanged(bFlag); 551cdf0e10cSrcweir 552*ee62af74Smarcus // pass to ObjectShell 553cdf0e10cSrcweir mpDocSh->SetModified(bFlag); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir } 556cdf0e10cSrcweir else 557cdf0e10cSrcweir { 558*ee62af74Smarcus // forward to baseclass 559cdf0e10cSrcweir FmFormModel::SetChanged(bFlag); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir } 562cdf0e10cSrcweir 563cdf0e10cSrcweir /************************************************************************* 564cdf0e10cSrcweir |* 565cdf0e10cSrcweir |* NbcSetChanged(), the model changed, don't call anybody else 566cdf0e10cSrcweir |* 567cdf0e10cSrcweir \************************************************************************/ 568cdf0e10cSrcweir 569cdf0e10cSrcweir void SdDrawDocument::NbcSetChanged(sal_Bool bFlag) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir // #100237# forward to baseclass 572cdf0e10cSrcweir FmFormModel::SetChanged(bFlag); 573cdf0e10cSrcweir } 574cdf0e10cSrcweir 575cdf0e10cSrcweir /************************************************************************* 576cdf0e10cSrcweir |* 577cdf0e10cSrcweir |* NewOrLoadCompleted 578cdf0e10cSrcweir |* 579*ee62af74Smarcus |* Will be called when the document was loaded respectively when it is 580*ee62af74Smarcus |* certain that it will not be loaded any longer. 581cdf0e10cSrcweir |* 582cdf0e10cSrcweir \************************************************************************/ 583cdf0e10cSrcweir 584cdf0e10cSrcweir void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir if (eMode == NEW_DOC) 587cdf0e10cSrcweir { 588*ee62af74Smarcus // new document: 589*ee62af74Smarcus // create Presentation and default templates, 590*ee62af74Smarcus // create pool for virtual controls 591cdf0e10cSrcweir CreateLayoutTemplates(); 592cdf0e10cSrcweir CreateDefaultCellStyles(); 593cdf0e10cSrcweir 594cdf0e10cSrcweir static_cast< SdStyleSheetPool* >( mxStyleSheetPool.get() )->CreatePseudosIfNecessary(); 595cdf0e10cSrcweir } 596cdf0e10cSrcweir else if (eMode == DOC_LOADED) 597cdf0e10cSrcweir { 598*ee62af74Smarcus // document was loaded: 599cdf0e10cSrcweir 600cdf0e10cSrcweir CheckMasterPages(); 601cdf0e10cSrcweir 602cdf0e10cSrcweir if ( GetMasterSdPageCount(PK_STANDARD) > 1 ) 603cdf0e10cSrcweir RemoveUnnecessaryMasterPages( NULL, sal_True, sal_False ); 604cdf0e10cSrcweir 605cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < GetPageCount(); i++ ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir // Check for correct layout names 608cdf0e10cSrcweir SdPage* pPage = (SdPage*) GetPage( i ); 609cdf0e10cSrcweir 610cdf0e10cSrcweir if(pPage->TRG_HasMasterPage()) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage(); 613cdf0e10cSrcweir 614cdf0e10cSrcweir if(rMaster.GetLayoutName() != pPage->GetLayoutName()) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir pPage->SetLayoutName(rMaster.GetLayoutName()); 617cdf0e10cSrcweir } 618cdf0e10cSrcweir } 619cdf0e10cSrcweir } 620cdf0e10cSrcweir 621cdf0e10cSrcweir for ( sal_uInt16 nPage = 0; nPage < GetMasterPageCount(); nPage++) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir // LayoutName and PageName must be the same 624cdf0e10cSrcweir SdPage* pPage = (SdPage*) GetMasterPage( nPage ); 625cdf0e10cSrcweir 626cdf0e10cSrcweir String aName( pPage->GetLayoutName() ); 627cdf0e10cSrcweir aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ) ); 628cdf0e10cSrcweir 629cdf0e10cSrcweir if( aName != pPage->GetName() ) 630cdf0e10cSrcweir pPage->SetName( aName ); 631cdf0e10cSrcweir } 632cdf0e10cSrcweir 633*ee62af74Smarcus // create language-dependent names of the default layer 634cdf0e10cSrcweir RestoreLayerNames(); 635cdf0e10cSrcweir 636*ee62af74Smarcus // set language-dependent names of the templates 637cdf0e10cSrcweir static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames(); 638cdf0e10cSrcweir 639*ee62af74Smarcus // if necessary create missing templates (e.g., formerly there was no Subtitle) 640cdf0e10cSrcweir static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary(); 641cdf0e10cSrcweir } 642cdf0e10cSrcweir 643*ee62af74Smarcus // set default template at the Drawing Engine 644cdf0e10cSrcweir String aName( SdResId(STR_STANDARD_STYLESHEET_NAME)); 645cdf0e10cSrcweir SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_GRAPHICS))); 646cdf0e10cSrcweir 6479e9dd2d5SArmin Le Grand // #119287# Set default StyleSheet for SdrGrafObj and SdrOle2Obj 6489e9dd2d5SArmin Le Grand SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(String( SdResId(STR_POOLSHEET_OBJNOLINENOFILL)), SD_STYLE_FAMILY_GRAPHICS))); 6499e9dd2d5SArmin Le Grand 650*ee62af74Smarcus // initialize Draw-Outliner and Document Outliner, 651*ee62af74Smarcus // but not the global Outliner because it is not document-specific 652*ee62af74Smarcus // like StyleSheetPool and StyleRequestHandler 653cdf0e10cSrcweir ::Outliner& rDrawOutliner = GetDrawOutliner(); 654cdf0e10cSrcweir rDrawOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 655cdf0e10cSrcweir sal_uLong nCntrl = rDrawOutliner.GetControlWord(); 656cdf0e10cSrcweir if (mbOnlineSpell) 657cdf0e10cSrcweir nCntrl |= EE_CNTRL_ONLINESPELLING; 658cdf0e10cSrcweir else 659cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_ONLINESPELLING; 660cdf0e10cSrcweir rDrawOutliner.SetControlWord(nCntrl); 661cdf0e10cSrcweir 662*ee62af74Smarcus // initialize HitTest-Outliner and Document Outliner, 663*ee62af74Smarcus // but not the global Outliner because it is not document-specific 664*ee62af74Smarcus // like StyleSheetPool and StyleRequestHandler 665cdf0e10cSrcweir pHitTestOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 666cdf0e10cSrcweir 667cdf0e10cSrcweir if(mpOutliner) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 670cdf0e10cSrcweir } 671cdf0e10cSrcweir if(mpInternalOutliner) 672cdf0e10cSrcweir { 673cdf0e10cSrcweir mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 674cdf0e10cSrcweir } 675cdf0e10cSrcweir 676cdf0e10cSrcweir if ( eMode == DOC_LOADED ) 677cdf0e10cSrcweir { 678*ee62af74Smarcus // presentation objects have to be Listener again of the respective templates 679cdf0e10cSrcweir SdStyleSheetPool* pSPool = (SdStyleSheetPool*) GetStyleSheetPool(); 680cdf0e10cSrcweir sal_uInt16 nPage, nPageCount; 681cdf0e10cSrcweir 682cdf0e10cSrcweir // #96323# create missing layout style sheets for broken documents 683cdf0e10cSrcweir // that where created with the 5.2 684cdf0e10cSrcweir nPageCount = GetMasterSdPageCount( PK_STANDARD ); 685cdf0e10cSrcweir for (nPage = 0; nPage < nPageCount; nPage++) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir SdPage* pPage = GetMasterSdPage(nPage, PK_STANDARD); 688cdf0e10cSrcweir pSPool->CreateLayoutStyleSheets( pPage->GetName(), sal_True ); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir 691*ee62af74Smarcus // Default and note pages: 692cdf0e10cSrcweir for (nPage = 0; nPage < GetPageCount(); nPage++) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir SdPage* pPage = (SdPage*)GetPage(nPage); 695cdf0e10cSrcweir NewOrLoadCompleted( pPage, pSPool ); 696cdf0e10cSrcweir } 697cdf0e10cSrcweir 698cdf0e10cSrcweir // Masterpages: 699cdf0e10cSrcweir for (nPage = 0; nPage < GetMasterPageCount(); nPage++) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir SdPage* pPage = (SdPage*)GetMasterPage(nPage); 702cdf0e10cSrcweir 703cdf0e10cSrcweir NewOrLoadCompleted( pPage, pSPool ); 704cdf0e10cSrcweir } 705cdf0e10cSrcweir } 706cdf0e10cSrcweir 707cdf0e10cSrcweir mbNewOrLoadCompleted = sal_True; 708cdf0e10cSrcweir 709cdf0e10cSrcweir /************************************************************************** 710*ee62af74Smarcus * Update all linked Pages 711cdf0e10cSrcweir **************************************************************************/ 712cdf0e10cSrcweir SdPage* pPage = NULL; 713cdf0e10cSrcweir sal_uInt16 nMaxSdPages = GetSdPageCount(PK_STANDARD); 714cdf0e10cSrcweir 715cdf0e10cSrcweir for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD); 718cdf0e10cSrcweir 719cdf0e10cSrcweir if (pPage && pPage->GetFileName().Len() && pPage->GetBookmarkName().Len()) 720cdf0e10cSrcweir { 721cdf0e10cSrcweir pPage->SetModel(this); 722cdf0e10cSrcweir } 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725cdf0e10cSrcweir UpdateAllLinks(); 726cdf0e10cSrcweir 727cdf0e10cSrcweir SetChanged( sal_False ); 728cdf0e10cSrcweir } 729cdf0e10cSrcweir 730cdf0e10cSrcweir /** updates all links, only links in this document should by resolved */ 731cdf0e10cSrcweir void SdDrawDocument::UpdateAllLinks() 732cdf0e10cSrcweir { 733cdf0e10cSrcweir if ( !pDocLockedInsertingLinks && pLinkManager && pLinkManager->GetLinks().Count() ) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved 736cdf0e10cSrcweir 737cdf0e10cSrcweir pLinkManager->UpdateAllLinks(); // query box: update all links? 738cdf0e10cSrcweir 739cdf0e10cSrcweir if( pDocLockedInsertingLinks == this ) 740cdf0e10cSrcweir pDocLockedInsertingLinks = NULL; // unlock inserting links 741cdf0e10cSrcweir } 742cdf0e10cSrcweir } 743cdf0e10cSrcweir 744cdf0e10cSrcweir /** this loops over the presentation objectes of a page and repairs some new settings 745cdf0e10cSrcweir from old binary files and resets all default strings for empty presentation objects. 746cdf0e10cSrcweir */ 747cdf0e10cSrcweir void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool ) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir /* cl removed because not needed anymore since binfilter 750cdf0e10cSrcweir SdrObjListIter aShapeIter( *pPage ); 751cdf0e10cSrcweir while( aShapeIter.IsMore() ) 752cdf0e10cSrcweir { 753cdf0e10cSrcweir OutlinerParaObject* pOPO = aShapeIter.Next()->GetOutlinerParaObject(); 754cdf0e10cSrcweir if( pOPO ) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir if( pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW ) 757cdf0e10cSrcweir pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT ); 758cdf0e10cSrcweir 759cdf0e10cSrcweir pOPO->FinishLoad( pSPool ); 760cdf0e10cSrcweir } 761cdf0e10cSrcweir } 762cdf0e10cSrcweir */ 763cdf0e10cSrcweir 764cdf0e10cSrcweir const sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() ); 765cdf0e10cSrcweir if(!rPresentationShapes.isEmpty()) 766cdf0e10cSrcweir { 767*ee62af74Smarcus // create lists with title and outline templates 768cdf0e10cSrcweir String aName = pPage->GetLayoutName(); 769cdf0e10cSrcweir aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR )); 770cdf0e10cSrcweir 771cdf0e10cSrcweir List* pOutlineList = pSPool->CreateOutlineSheetList(aName); 772cdf0e10cSrcweir SfxStyleSheet* pTitleSheet = (SfxStyleSheet*) 773cdf0e10cSrcweir pSPool->GetTitleSheet(aName); 774cdf0e10cSrcweir 775cdf0e10cSrcweir SdrObject* pObj = rPresentationShapes.getNextShape(0); 776cdf0e10cSrcweir 777*ee62af74Smarcus // now search for title and outline text objects and 778*ee62af74Smarcus // change objects into Listener 779cdf0e10cSrcweir while(pObj) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir if (pObj->GetObjInventor() == SdrInventor) 782cdf0e10cSrcweir { 783cdf0e10cSrcweir OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); 784cdf0e10cSrcweir sal_uInt16 nId = pObj->GetObjIdentifier(); 785cdf0e10cSrcweir 786cdf0e10cSrcweir if (nId == OBJ_TITLETEXT) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW ) 789cdf0e10cSrcweir pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT ); 790cdf0e10cSrcweir 791*ee62af74Smarcus // sal_True: in doing so do not delete hard attributes 792cdf0e10cSrcweir if (pTitleSheet) 793cdf0e10cSrcweir pObj->SetStyleSheet(pTitleSheet, sal_True); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir else if (nId == OBJ_OUTLINETEXT) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW ) 798cdf0e10cSrcweir pOPO->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT ); 799cdf0e10cSrcweir 800cdf0e10cSrcweir for (sal_uInt16 nSheet = 0; nSheet < 10; nSheet++) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineList->GetObject(nSheet); 803cdf0e10cSrcweir if (pSheet) 804cdf0e10cSrcweir { 805cdf0e10cSrcweir pObj->StartListening(*pSheet); 806cdf0e10cSrcweir 807cdf0e10cSrcweir if( nSheet == 0) 808*ee62af74Smarcus // text frame listen to StyleSheet of Layer1 809cdf0e10cSrcweir pObj->NbcSetStyleSheet(pSheet, sal_True); 810cdf0e10cSrcweir } 811cdf0e10cSrcweir } 812cdf0e10cSrcweir } 813cdf0e10cSrcweir 814cdf0e10cSrcweir if (pObj->ISA(SdrTextObj) && pObj->IsEmptyPresObj() && pPage) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj); 817cdf0e10cSrcweir String aString( pPage->GetPresObjText(ePresObjKind) ); 818cdf0e10cSrcweir 819cdf0e10cSrcweir if (aString.Len()) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir sd::Outliner* pInternalOutl = GetInternalOutliner(sal_True); 822cdf0e10cSrcweir pPage->SetObjText( (SdrTextObj*) pObj, pInternalOutl, ePresObjKind, aString ); 823cdf0e10cSrcweir pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), sal_True ); 824cdf0e10cSrcweir pInternalOutl->Clear(); 825cdf0e10cSrcweir } 826cdf0e10cSrcweir } 827cdf0e10cSrcweir } 828cdf0e10cSrcweir 829cdf0e10cSrcweir pObj = rPresentationShapes.getNextShape(pObj); 830cdf0e10cSrcweir } 831cdf0e10cSrcweir 832cdf0e10cSrcweir delete pOutlineList; 833cdf0e10cSrcweir } 834cdf0e10cSrcweir } 835cdf0e10cSrcweir 836cdf0e10cSrcweir /************************************************************************* 837cdf0e10cSrcweir |* 838*ee62af74Smarcus |* Local Outliner that is used for the outline mode. 839*ee62af74Smarcus |* If necessary, insert OutlinerViews into this outliner ! 840cdf0e10cSrcweir |* 841cdf0e10cSrcweir \************************************************************************/ 842cdf0e10cSrcweir 843cdf0e10cSrcweir ::sd::Outliner* SdDrawDocument::GetOutliner(sal_Bool bCreateOutliner) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir if (!mpOutliner && bCreateOutliner) 846cdf0e10cSrcweir { 847cdf0e10cSrcweir mpOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT ); 848cdf0e10cSrcweir 849cdf0e10cSrcweir if (mpDocSh) 850cdf0e10cSrcweir mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) ); 851cdf0e10cSrcweir 852cdf0e10cSrcweir mpOutliner->SetDefTab( nDefaultTabulator ); 853cdf0e10cSrcweir mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 854cdf0e10cSrcweir } 855cdf0e10cSrcweir 856cdf0e10cSrcweir return(mpOutliner); 857cdf0e10cSrcweir } 858cdf0e10cSrcweir 859cdf0e10cSrcweir 860cdf0e10cSrcweir /************************************************************************* 861cdf0e10cSrcweir |* 862*ee62af74Smarcus |* Internal Outliner that is used for creating text objects. 863*ee62af74Smarcus |* No OutlinerViews will be inserted into this Outliner! 864cdf0e10cSrcweir |* 865cdf0e10cSrcweir \************************************************************************/ 866cdf0e10cSrcweir 867cdf0e10cSrcweir ::sd::Outliner* SdDrawDocument::GetInternalOutliner(sal_Bool bCreateOutliner) 868cdf0e10cSrcweir { 869cdf0e10cSrcweir if ( !mpInternalOutliner && bCreateOutliner ) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir mpInternalOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT ); 872cdf0e10cSrcweir // MT: 873*ee62af74Smarcus // This Outliner is used to create special text objects only. 874*ee62af74Smarcus // As no portion information have to be saved in these text objects, 875*ee62af74Smarcus // the update mode can/should stay always sal_False. 876cdf0e10cSrcweir mpInternalOutliner->SetUpdateMode( sal_False ); 877cdf0e10cSrcweir mpInternalOutliner->EnableUndo( sal_False ); 878cdf0e10cSrcweir 879cdf0e10cSrcweir if (mpDocSh) 880cdf0e10cSrcweir mpInternalOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) ); 881cdf0e10cSrcweir 882cdf0e10cSrcweir mpInternalOutliner->SetDefTab( nDefaultTabulator ); 883cdf0e10cSrcweir mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 884cdf0e10cSrcweir } 885cdf0e10cSrcweir 886cdf0e10cSrcweir DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->GetUpdateMode() == sal_False ) , "InternalOutliner: UpdateMode = sal_True !" ); 887cdf0e10cSrcweir DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->IsUndoEnabled() == sal_False ), "InternalOutliner: Undo = sal_True !" ); 888cdf0e10cSrcweir 889*ee62af74Smarcus // MT: Who fills it with spam has to empty it right after: 890*ee62af74Smarcus // Advantages: 891*ee62af74Smarcus // a) No uncessary clear calls. 892*ee62af74Smarcus // b) No spam in memory. 893cdf0e10cSrcweir DBG_ASSERT( !mpInternalOutliner || ( ( mpInternalOutliner->GetParagraphCount() == 1 ) && ( mpInternalOutliner->GetText( mpInternalOutliner->GetParagraph( 0 ) ).Len() == 0 ) ), "InternalOutliner: Nicht leer!" ); 894cdf0e10cSrcweir 895cdf0e10cSrcweir return mpInternalOutliner; 896cdf0e10cSrcweir } 897cdf0e10cSrcweir 898cdf0e10cSrcweir /************************************************************************* 899cdf0e10cSrcweir |* 900*ee62af74Smarcus |* OnlineSpelling on/off 901cdf0e10cSrcweir |* 902cdf0e10cSrcweir \************************************************************************/ 903cdf0e10cSrcweir 904cdf0e10cSrcweir void SdDrawDocument::SetOnlineSpell(sal_Bool bIn) 905cdf0e10cSrcweir { 906cdf0e10cSrcweir mbOnlineSpell = bIn; 907cdf0e10cSrcweir sal_uLong nCntrl = 0; 908cdf0e10cSrcweir 909cdf0e10cSrcweir if(mpOutliner) 910cdf0e10cSrcweir { 911cdf0e10cSrcweir nCntrl = mpOutliner->GetControlWord(); 912cdf0e10cSrcweir 913cdf0e10cSrcweir if(mbOnlineSpell) 914cdf0e10cSrcweir nCntrl |= EE_CNTRL_ONLINESPELLING; 915cdf0e10cSrcweir else 916cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_ONLINESPELLING; 917cdf0e10cSrcweir 918cdf0e10cSrcweir mpOutliner->SetControlWord(nCntrl); 919cdf0e10cSrcweir } 920cdf0e10cSrcweir 921cdf0e10cSrcweir if (mpInternalOutliner) 922cdf0e10cSrcweir { 923cdf0e10cSrcweir nCntrl = mpInternalOutliner->GetControlWord(); 924cdf0e10cSrcweir 925cdf0e10cSrcweir if (mbOnlineSpell) 926cdf0e10cSrcweir nCntrl |= EE_CNTRL_ONLINESPELLING; 927cdf0e10cSrcweir else 928cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_ONLINESPELLING; 929cdf0e10cSrcweir 930cdf0e10cSrcweir mpInternalOutliner->SetControlWord(nCntrl); 931cdf0e10cSrcweir } 932cdf0e10cSrcweir 933cdf0e10cSrcweir ::Outliner& rOutliner = GetDrawOutliner(); 934cdf0e10cSrcweir 935cdf0e10cSrcweir nCntrl = rOutliner.GetControlWord(); 936cdf0e10cSrcweir 937cdf0e10cSrcweir if (mbOnlineSpell) 938cdf0e10cSrcweir nCntrl |= EE_CNTRL_ONLINESPELLING; 939cdf0e10cSrcweir else 940cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_ONLINESPELLING; 941cdf0e10cSrcweir 942cdf0e10cSrcweir rOutliner.SetControlWord(nCntrl); 943cdf0e10cSrcweir 944cdf0e10cSrcweir if (mbOnlineSpell) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir StartOnlineSpelling(); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir else 949cdf0e10cSrcweir { 950cdf0e10cSrcweir StopOnlineSpelling(); 951cdf0e10cSrcweir } 952cdf0e10cSrcweir } 953cdf0e10cSrcweir 954cdf0e10cSrcweir 955cdf0e10cSrcweir /************************************************************************* 956cdf0e10cSrcweir |* 957*ee62af74Smarcus |* OnlineSpelling: Marking on/off 958cdf0e10cSrcweir |* 959cdf0e10cSrcweir \************************************************************************/ 960cdf0e10cSrcweir 961cdf0e10cSrcweir uno::Reference< uno::XInterface > SdDrawDocument::createUnoModel() 962cdf0e10cSrcweir { 963cdf0e10cSrcweir uno::Reference< uno::XInterface > xModel; 964cdf0e10cSrcweir 965cdf0e10cSrcweir try 966cdf0e10cSrcweir { 967cdf0e10cSrcweir if ( mpDocSh ) 968cdf0e10cSrcweir xModel = mpDocSh->GetModel(); 969cdf0e10cSrcweir } 970cdf0e10cSrcweir catch( uno::RuntimeException& ) 971cdf0e10cSrcweir { 972cdf0e10cSrcweir } 973cdf0e10cSrcweir 974cdf0e10cSrcweir return xModel; 975cdf0e10cSrcweir } 976cdf0e10cSrcweir 977cdf0e10cSrcweir SvxNumType SdDrawDocument::GetPageNumType() const 978cdf0e10cSrcweir { 979cdf0e10cSrcweir return mePageNumType; 980cdf0e10cSrcweir } 981cdf0e10cSrcweir 982cdf0e10cSrcweir 983cdf0e10cSrcweir 984cdf0e10cSrcweir 985cdf0e10cSrcweir void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode) 986cdf0e10cSrcweir { 987cdf0e10cSrcweir // #108104# 988cdf0e10cSrcweir // DBG_ASSERT (mpDocSh!=NULL, "No available document shell to set ref device at."); 989cdf0e10cSrcweir 990cdf0e10cSrcweir switch (nMode) 991cdf0e10cSrcweir { 992cdf0e10cSrcweir case ::com::sun::star::document::PrinterIndependentLayout::DISABLED: 993cdf0e10cSrcweir case ::com::sun::star::document::PrinterIndependentLayout::ENABLED: 994cdf0e10cSrcweir // Just store supported modes and inform the doc shell. 995cdf0e10cSrcweir mnPrinterIndependentLayout = nMode; 996cdf0e10cSrcweir 997cdf0e10cSrcweir // #108104# 998cdf0e10cSrcweir // Since it is possible that a SdDrawDocument is constructed without a 999cdf0e10cSrcweir // SdDrawDocShell the pointer member mpDocSh needs to be tested 1000cdf0e10cSrcweir // before the call is executed. This is e.-g. used for copy/paste. 1001cdf0e10cSrcweir if(mpDocSh) 1002cdf0e10cSrcweir { 1003cdf0e10cSrcweir mpDocSh->UpdateRefDevice (); 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir 1006cdf0e10cSrcweir break; 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir default: 1009cdf0e10cSrcweir // Ignore unknown values. 1010cdf0e10cSrcweir break; 1011cdf0e10cSrcweir } 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir sal_Int32 SdDrawDocument::GetPrinterIndependentLayout (void) 1015cdf0e10cSrcweir { 1016cdf0e10cSrcweir return mnPrinterIndependentLayout; 1017cdf0e10cSrcweir } 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir bool SdDrawDocument::IsStartWithPresentation() const 1020cdf0e10cSrcweir { 1021cdf0e10cSrcweir return mbStartWithPresentation; 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation ) 1025cdf0e10cSrcweir { 1026cdf0e10cSrcweir mbStartWithPresentation = bStartWithPresentation; 1027cdf0e10cSrcweir } 1028cdf0e10cSrcweir 1029cdf0e10cSrcweir // #109538# 1030cdf0e10cSrcweir void SdDrawDocument::PageListChanged() 1031cdf0e10cSrcweir { 1032cdf0e10cSrcweir mpDrawPageListWatcher->Invalidate(); 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir 1035cdf0e10cSrcweir // #109538# 1036cdf0e10cSrcweir void SdDrawDocument::MasterPageListChanged() 1037cdf0e10cSrcweir { 1038cdf0e10cSrcweir mpMasterPageListWatcher->Invalidate(); 1039cdf0e10cSrcweir } 1040cdf0e10cSrcweir 1041cdf0e10cSrcweir void SdDrawDocument::SetCalcFieldValueHdl(::Outliner* pOutliner) 1042cdf0e10cSrcweir { 1043cdf0e10cSrcweir pOutliner->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl)); 1044cdf0e10cSrcweir } 1045cdf0e10cSrcweir 1046cdf0e10cSrcweir sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const rtl::OUString& rAuthor ) 1047cdf0e10cSrcweir { 1048cdf0e10cSrcweir // force current user to have first color 1049cdf0e10cSrcweir if( maAnnotationAuthors.empty() ) 1050cdf0e10cSrcweir { 1051cdf0e10cSrcweir SvtUserOptions aUserOptions; 1052cdf0e10cSrcweir maAnnotationAuthors.push_back( aUserOptions.GetFullName() ); 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir sal_uInt16 idx = 0; 1056cdf0e10cSrcweir for( std::vector< OUString >::iterator iter( maAnnotationAuthors.begin() ); iter != maAnnotationAuthors.end(); iter++ ) 1057cdf0e10cSrcweir { 1058cdf0e10cSrcweir if( (*iter) == rAuthor ) 1059cdf0e10cSrcweir { 1060cdf0e10cSrcweir break; 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir idx++; 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir if( idx == maAnnotationAuthors.size() ) 1066cdf0e10cSrcweir { 1067cdf0e10cSrcweir maAnnotationAuthors.push_back( rAuthor ); 1068cdf0e10cSrcweir } 1069cdf0e10cSrcweir 1070cdf0e10cSrcweir return idx; 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir // eof 1074