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