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 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #include "PageListWatcher.hxx" 28 #include <com/sun/star/text/WritingMode.hpp> 29 #include <com/sun/star/document/PrinterIndependentLayout.hpp> 30 #include <com/sun/star/i18n/ScriptType.hpp> 31 #include <editeng/forbiddencharacterstable.hxx> 32 33 #include <svx/svxids.hrc> 34 #include <svl/srchitem.hxx> 35 #include <editeng/eeitem.hxx> 36 #include <editeng/scriptspaceitem.hxx> 37 38 #include <unotools/useroptions.hxx> 39 40 #include <sfx2/printer.hxx> 41 #include <sfx2/app.hxx> 42 #include <sfx2/linkmgr.hxx> 43 #include <svx/dialogs.hrc> 44 #include "Outliner.hxx" 45 #include "app.hxx" 46 #include <editeng/eeitem.hxx> 47 #include <editeng/editstat.hxx> 48 #include <editeng/fontitem.hxx> 49 #include <svl/flagitem.hxx> 50 #include <svx/svdoattr.hxx> 51 #include <svx/svdotext.hxx> 52 #include <editeng/bulitem.hxx> 53 #include <editeng/numitem.hxx> 54 #include <svx/svditer.hxx> 55 #include <editeng/unolingu.hxx> 56 #include <svl/itempool.hxx> 57 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 58 #include <svx/xtable.hxx> 59 #include <com/sun/star/linguistic2/XHyphenator.hpp> 60 #include <com/sun/star/linguistic2/XSpellChecker1.hpp> 61 #include <com/sun/star/beans/XPropertySet.hpp> 62 #include <editeng/outlobj.hxx> 63 #include <unotools/saveopt.hxx> 64 #include <comphelper/extract.hxx> 65 #include <i18npool/mslangid.hxx> 66 #include <unotools/charclass.hxx> 67 #include <comphelper/processfactory.hxx> 68 #ifndef _SVTOOLS_PATHOPTIONS_HXX_ 69 #include <unotools/pathoptions.hxx> 70 #endif 71 #include <unotools/lingucfg.hxx> 72 #include <unotools/linguprops.hxx> 73 74 #include "eetext.hxx" 75 #include "drawdoc.hxx" 76 #include "sdpage.hxx" 77 #include "pglink.hxx" 78 #include "sdattr.hxx" 79 #include "glob.hrc" 80 #include "glob.hxx" 81 #include "stlpool.hxx" 82 #include "sdiocmpt.hxx" 83 #include "sdresid.hxx" 84 #include "cusshow.hxx" 85 #include "../ui/inc/DrawDocShell.hxx" 86 #include "../ui/inc/GraphicDocShell.hxx" 87 #include "../ui/inc/sdxfer.hxx" 88 #include "../ui/inc/ViewShell.hxx" 89 #include "../ui/inc/optsitem.hxx" 90 #include "../ui/inc/FrameView.hxx" 91 92 // #90477# 93 #include <tools/tenccvt.hxx> 94 95 using ::rtl::OUString; 96 using namespace ::sd; 97 using namespace ::com::sun::star; 98 using namespace ::com::sun::star::uno; 99 using namespace ::com::sun::star::lang; 100 using namespace ::com::sun::star::linguistic2; 101 102 ////////////////////////////////////////////////////////////////////////////// 103 104 TYPEINIT1( SdDrawDocument, FmFormModel ); 105 106 SdDrawDocument* SdDrawDocument::pDocLockedInsertingLinks = NULL; 107 108 ////////////////////////////////////////////////////////////////////////////// 109 110 PresentationSettings::PresentationSettings() 111 : mbAll( true ), 112 mbEndless( false ), 113 mbCustomShow(false), 114 mbManual( false ), 115 mbMouseVisible( false ), 116 mbMouseAsPen( false ), 117 mbLockedPages( false ), 118 mbAlwaysOnTop( false ), 119 mbFullScreen( true ), 120 mbAnimationAllowed( true ), 121 mnPauseTimeout( 10 ), 122 mbShowPauseLogo( false ), 123 mbStartWithNavigator(false) 124 { 125 } 126 127 // --------------------------------------------------------------------------- 128 129 PresentationSettings::PresentationSettings( const PresentationSettings& r ) 130 : maPresPage( r.maPresPage ), 131 mbAll( r.mbAll ), 132 mbEndless( r.mbEndless ), 133 mbCustomShow( r.mbCustomShow ), 134 mbManual( r.mbManual ), 135 mbMouseVisible( r.mbMouseVisible ), 136 mbMouseAsPen( r.mbMouseAsPen ), 137 mbLockedPages( r.mbLockedPages ), 138 mbAlwaysOnTop( r.mbAlwaysOnTop ), 139 mbFullScreen( r.mbFullScreen ), 140 mbAnimationAllowed( r.mbAnimationAllowed ), 141 mnPauseTimeout( r.mnPauseTimeout ), 142 mbShowPauseLogo( r.mbShowPauseLogo ), 143 mbStartWithNavigator( r.mbStartWithNavigator ) 144 { 145 } 146 147 // --------------------------------------------------------------------------- 148 149 SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) 150 : FmFormModel( SvtPathOptions().GetPalettePath(), NULL, pDrDocSh ) 151 , mpOutliner(NULL) 152 , mpInternalOutliner(NULL) 153 , mpWorkStartupTimer(NULL) 154 , mpOnlineSpellingTimer(NULL) 155 , mpOnlineSpellingList(NULL) 156 , mpOnlineSearchItem(NULL) 157 , mpFrameViewList( new List() ) 158 , mpCustomShowList(NULL) 159 , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh)) 160 , mpCreatingTransferable( NULL ) 161 , mbHasOnlineSpellErrors(sal_False) 162 , mbInitialOnlineSpellingEnabled(sal_True) 163 , mbNewOrLoadCompleted(sal_False) 164 , mbStartWithPresentation( false ) 165 , meLanguage( LANGUAGE_SYSTEM ) 166 , meLanguageCJK( LANGUAGE_SYSTEM ) 167 , meLanguageCTL( LANGUAGE_SYSTEM ) 168 , mePageNumType(SVX_ARABIC) 169 , mbAllocDocSh(sal_False) 170 , meDocType(eType) 171 , mpCharClass(NULL) 172 , mpLocale(NULL) 173 , mpDrawPageListWatcher(0) 174 , mpMasterPageListWatcher(0) 175 { 176 // #109538# 177 mpDrawPageListWatcher = ::std::auto_ptr<ImpDrawPageListWatcher>( 178 new ImpDrawPageListWatcher(*this)); 179 mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>( 180 new ImpMasterPageListWatcher(*this)); 181 182 SetObjectShell(pDrDocSh); // fuer das VCDrawModel 183 184 if (mpDocSh) 185 { 186 SetSwapGraphics(sal_True); 187 } 188 189 // Masseinheit (von App) und Massstab (von SdMod) setzen 190 sal_Int32 nX, nY; 191 SdOptions* pOptions = SD_MOD()->GetSdOptions(meDocType); 192 pOptions->GetScale( nX, nY ); 193 194 // #92067# Allow UI scale only for draw documents. 195 if( eType == DOCUMENT_TYPE_DRAW ) 196 SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) ); // user-defined 197 else 198 SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) ); // default 199 200 SetScaleUnit(MAP_100TH_MM); 201 SetScaleFraction(Fraction(1, 1)); 202 SetDefaultFontHeight(847); // 24p 203 204 pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM); 205 pItemPool->FreezeIdRanges(); 206 SetTextDefaults(); 207 208 // die DrawingEngine muss auch wissen, wo er ist 209 FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) ); 210 211 // Dem DrawOutliner den StyleSheetPool setzen, damit Textobjekte richtig 212 // eingelesen werden koennen. Der Link zum StyleRequest-Handler des 213 // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle 214 // Vorlagen existieren. 215 SdrOutliner& rOutliner = GetDrawOutliner(); 216 rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 217 SetCalcFieldValueHdl( &rOutliner ); 218 219 // set linguistic options 220 { 221 const SvtLinguConfig aLinguConfig; 222 SvtLinguOptions aOptions; 223 aLinguConfig.GetOptions( aOptions ); 224 225 SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, 226 ::com::sun::star::i18n::ScriptType::LATIN), EE_CHAR_LANGUAGE ); 227 SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, 228 ::com::sun::star::i18n::ScriptType::ASIAN), EE_CHAR_LANGUAGE_CJK ); 229 SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, 230 ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL ); 231 232 mbOnlineSpell = aOptions.bIsSpellAuto; 233 } 234 235 LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage ); 236 mpLocale = new ::com::sun::star::lang::Locale( MsLangId::convertLanguageToLocale( eRealLanguage )); 237 mpCharClass = new CharClass( *mpLocale ); 238 239 // If the current application language is a language that uses right-to-left text... 240 LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguage(); 241 if( MsLangId::isRightToLeft( eRealCTLLanguage ) ) 242 { 243 // ... then we have to set this as a default 244 SetDefaultWritingMode( ::com::sun::star::text::WritingMode_RL_TB ); 245 } 246 247 // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text 248 if( ( LANGUAGE_KOREAN == eRealCTLLanguage ) || ( LANGUAGE_KOREAN_JOHAB == eRealCTLLanguage ) || ( LANGUAGE_JAPANESE == eRealCTLLanguage ) ) 249 { 250 GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) ); 251 } 252 253 // DefTab und SpellOptions setzen 254 // Jetzt am Modul (SD) 255 sal_uInt16 nDefTab = pOptions->GetDefTab(); 256 SetDefaultTabulator( nDefTab ); 257 258 try 259 { 260 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); 261 if ( xSpellChecker.is() ) 262 rOutliner.SetSpeller( xSpellChecker ); 263 264 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); 265 if( xHyphenator.is() ) 266 rOutliner.SetHyphenator( xHyphenator ); 267 268 SetForbiddenCharsTable( new SvxForbiddenCharactersTable( ::comphelper::getProcessServiceFactory() ) ); 269 } 270 catch(...) 271 { 272 DBG_ERROR("Can't get SpellChecker"); 273 } 274 275 rOutliner.SetDefaultLanguage( Application::GetSettings().GetLanguage() ); 276 277 if (mpDocSh) 278 { 279 SetLinkManager( new sfx2::LinkManager(mpDocSh) ); 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 // Dem HitTestOutliner den StyleSheetPool setzen. 306 // Der Link zum StyleRequest-Handler des 307 // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle 308 // Vorlagen existieren. 309 SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() ); 310 pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() ); 311 312 SetCalcFieldValueHdl( pHitTestOutliner ); 313 314 try 315 { 316 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); 317 if ( xSpellChecker.is() ) 318 pHitTestOutliner->SetSpeller( xSpellChecker ); 319 320 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); 321 if( xHyphenator.is() ) 322 pHitTestOutliner->SetHyphenator( xHyphenator ); 323 } 324 catch(...) 325 { 326 DBG_ERROR("Can't get SpellChecker"); 327 } 328 329 pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguage() ); 330 331 sal_uLong nCntrl2 = pHitTestOutliner->GetControlWord(); 332 nCntrl2 |= EE_CNTRL_ALLOWBIGOBJS; 333 nCntrl2 |= EE_CNTRL_URLSFXEXECUTE; 334 nCntrl2 &= ~EE_CNTRL_ONLINESPELLING; 335 336 nCntrl2 &= ~ EE_CNTRL_ULSPACESUMMATION; 337 if ( pOptions->IsSummationOfParagraphs() ) 338 nCntrl2 |= EE_CNTRL_ULSPACESUMMATION; 339 340 pHitTestOutliner->SetControlWord( nCntrl2 ); 341 342 /************************************************************************** 343 * Layer anlegen 344 * 345 * Es werden auf Pages und MasterPages folgende Default-Layer angelegt: 346 * 347 * Layer STR_LAYOUT : Standardlayer f�r alle Zeichenobjekte 348 * 349 * Layer STR_BCKGRND : Hintergrund der MasterPage 350 * (auf normalen Pages z.Z. keine Verwendung) 351 * 352 * Layer STR_BCKGRNDOBJ: Objekte auf dem Hintergrund der MasterPage 353 * (auf normalen Pages z.Z. keine Verwendung) 354 * 355 * Layer STR_CONTROLS : Standardlayer f�r Controls 356 * 357 **************************************************************************/ 358 { 359 String aControlLayerName( SdResId(STR_LAYER_CONTROLS) ); 360 361 SdrLayerAdmin& rLayerAdmin = GetLayerAdmin(); 362 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_LAYOUT)) ); 363 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRND)) ); 364 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRNDOBJ)) ); 365 rLayerAdmin.NewLayer( aControlLayerName ); 366 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_MEASURELINES)) ); 367 368 rLayerAdmin.SetControlLayerName(aControlLayerName); 369 } 370 371 372 } 373 374 /************************************************************************* 375 |* 376 |* Destruktor 377 |* 378 \************************************************************************/ 379 380 SdDrawDocument::~SdDrawDocument() 381 { 382 Broadcast(SdrHint(HINT_MODELCLEARED)); 383 384 if (mpWorkStartupTimer) 385 { 386 if ( mpWorkStartupTimer->IsActive() ) 387 mpWorkStartupTimer->Stop(); 388 389 delete mpWorkStartupTimer; 390 mpWorkStartupTimer = NULL; 391 } 392 393 StopOnlineSpelling(); 394 delete mpOnlineSearchItem; 395 mpOnlineSearchItem = NULL; 396 397 CloseBookmarkDoc(); 398 SetAllocDocSh(sal_False); 399 400 // #116168# 401 ClearModel(sal_True); 402 403 if (pLinkManager) 404 { 405 // BaseLinks freigeben 406 if ( pLinkManager->GetLinks().Count() ) 407 { 408 pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() ); 409 } 410 411 delete pLinkManager; 412 pLinkManager = NULL; 413 } 414 415 ::sd::FrameView* pFrameView = NULL; 416 417 for (sal_uLong i = 0; i < mpFrameViewList->Count(); i++) 418 { 419 // Ggf. FrameViews loeschen 420 pFrameView = 421 static_cast< ::sd::FrameView*>(mpFrameViewList->GetObject(i)); 422 423 if (pFrameView) 424 delete pFrameView; 425 } 426 427 delete mpFrameViewList; 428 mpFrameViewList = NULL; 429 430 if (mpCustomShowList) 431 { 432 for (sal_uLong j = 0; j < mpCustomShowList->Count(); j++) 433 { 434 // Ggf. CustomShows loeschen 435 SdCustomShow* pCustomShow = (SdCustomShow*) mpCustomShowList->GetObject(j); 436 delete pCustomShow; 437 } 438 439 delete mpCustomShowList; 440 mpCustomShowList = NULL; 441 } 442 443 delete mpOutliner; 444 mpOutliner = NULL; 445 446 delete mpInternalOutliner; 447 mpInternalOutliner = NULL; 448 449 delete mpLocale; 450 mpLocale = NULL; 451 452 delete mpCharClass; 453 mpCharClass = NULL; 454 } 455 456 /************************************************************************* 457 |* 458 |* Diese Methode erzeugt ein neues Dokument (SdDrawDocument) und gibt einen 459 |* Zeiger darauf zurueck. Die Drawing Engine benutzt diese Methode um das 460 |* Dokument oder Teile davon ins Clipboard/DragServer stellen zu koennen. 461 |* 462 \************************************************************************/ 463 464 SdrModel* SdDrawDocument::AllocModel() const 465 { 466 SdDrawDocument* pNewModel = NULL; 467 468 if( mpCreatingTransferable ) 469 { 470 // Dokument wird fuer Drag&Drop/Clipboard erzeugt, dafuer muss dem Dokument eine DocShell (SvPersist) bekannt sein 471 SfxObjectShell* pObj = NULL; 472 ::sd::DrawDocShell* pNewDocSh = NULL; 473 474 if( meDocType == DOCUMENT_TYPE_IMPRESS ) 475 mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell( 476 SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) ); 477 else 478 mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell( 479 SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) ); 480 481 pNewDocSh = static_cast< ::sd::DrawDocShell*>( pObj = mpCreatingTransferable->GetDocShell() ); 482 pNewDocSh->DoInitNew( NULL ); 483 pNewModel = pNewDocSh->GetDoc(); 484 485 // Nur fuer Clipboard notwendig, 486 // fuer Drag&Drop erfolgt dieses im DragServer 487 SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) GetStyleSheetPool(); 488 SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pNewModel->GetStyleSheetPool(); 489 490 pNewStylePool->CopyGraphicSheets(*pOldStylePool); 491 pNewStylePool->CopyCellSheets(*pOldStylePool); 492 pNewStylePool->CopyTableStyles(*pOldStylePool); 493 494 495 for (sal_uInt16 i = 0; i < GetMasterSdPageCount(PK_STANDARD); i++) 496 { 497 // Alle Layouts der MasterPage mitnehmen 498 String aOldLayoutName(((SdDrawDocument*) this)->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName()); 499 aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) ); 500 SdStyleSheetVector aCreatedSheets; 501 pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets ); 502 } 503 504 pNewModel->NewOrLoadCompleted( DOC_LOADED ); // loaded from source document 505 } 506 else if( mbAllocDocSh ) 507 { 508 // Es wird eine DocShell erzeugt, welche mit GetAllocedDocSh() zurueckgegeben wird 509 SdDrawDocument* pDoc = (SdDrawDocument*) this; 510 pDoc->SetAllocDocSh(sal_False); 511 pDoc->mxAllocedDocShRef = new ::sd::DrawDocShell( 512 SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType); 513 pDoc->mxAllocedDocShRef->DoInitNew(NULL); 514 pNewModel = pDoc->mxAllocedDocShRef->GetDoc(); 515 } 516 else 517 { 518 pNewModel = new SdDrawDocument(meDocType, NULL); 519 } 520 521 return pNewModel; 522 } 523 524 /************************************************************************* 525 |* 526 |* Diese Methode erzeugt eine neue Seite (SdPage) und gibt einen Zeiger 527 |* darauf zurueck. Die Drawing Engine benutzt diese Methode beim Laden 528 |* zur Erzeugung von Seiten (deren Typ sie ja nicht kennt, da es ABLEITUNGEN 529 |* der SdrPage sind). 530 |* 531 \************************************************************************/ 532 533 SdrPage* SdDrawDocument::AllocPage(FASTBOOL bMasterPage) 534 { 535 return new SdPage(*this, NULL, (sal_Bool)bMasterPage); 536 } 537 538 /************************************************************************* 539 |* 540 |* SetChanged(), das Model wurde geaendert 541 |* 542 \************************************************************************/ 543 544 void SdDrawDocument::SetChanged(sal_Bool bFlag) 545 { 546 if (mpDocSh) 547 { 548 if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified()) 549 { 550 // weitergeben an Basisklasse 551 FmFormModel::SetChanged(bFlag); 552 553 // an ObjectShell weiterleiten 554 mpDocSh->SetModified(bFlag); 555 } 556 } 557 else 558 { 559 // weitergeben an Basisklasse 560 FmFormModel::SetChanged(bFlag); 561 } 562 } 563 564 /************************************************************************* 565 |* 566 |* NbcSetChanged(), the model changed, don't call anybody else 567 |* 568 \************************************************************************/ 569 570 void SdDrawDocument::NbcSetChanged(sal_Bool bFlag) 571 { 572 // #100237# forward to baseclass 573 FmFormModel::SetChanged(bFlag); 574 } 575 576 /************************************************************************* 577 |* 578 |* NewOrLoadCompleted 579 |* 580 |* Wird gerufen, wenn das Dokument geladen wurde bzw. feststeht, dass es 581 |* nicht mehr geladen wird. 582 |* 583 \************************************************************************/ 584 585 void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode) 586 { 587 if (eMode == NEW_DOC) 588 { 589 // Neues Dokument: 590 // Praesentations- und Standardvorlagen erzeugen, 591 // Pool fuer virtuelle Controls erzeugen 592 CreateLayoutTemplates(); 593 CreateDefaultCellStyles(); 594 595 static_cast< SdStyleSheetPool* >( mxStyleSheetPool.get() )->CreatePseudosIfNecessary(); 596 } 597 else if (eMode == DOC_LOADED) 598 { 599 // Dokument wurde geladen: 600 601 CheckMasterPages(); 602 603 if ( GetMasterSdPageCount(PK_STANDARD) > 1 ) 604 RemoveUnnecessaryMasterPages( NULL, sal_True, sal_False ); 605 606 for ( sal_uInt16 i = 0; i < GetPageCount(); i++ ) 607 { 608 // Check for correct layout names 609 SdPage* pPage = (SdPage*) GetPage( i ); 610 611 if(pPage->TRG_HasMasterPage()) 612 { 613 SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage(); 614 615 if(rMaster.GetLayoutName() != pPage->GetLayoutName()) 616 { 617 pPage->SetLayoutName(rMaster.GetLayoutName()); 618 } 619 } 620 } 621 622 for ( sal_uInt16 nPage = 0; nPage < GetMasterPageCount(); nPage++) 623 { 624 // LayoutName and PageName must be the same 625 SdPage* pPage = (SdPage*) GetMasterPage( nPage ); 626 627 String aName( pPage->GetLayoutName() ); 628 aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ) ); 629 630 if( aName != pPage->GetName() ) 631 pPage->SetName( aName ); 632 } 633 634 // Sprachabhaengige Namen der StandardLayer erzeugen 635 RestoreLayerNames(); 636 637 // Sprachabhaengige Namen der Vorlagen setzen 638 static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames(); 639 640 // Ggf. fehlende Vorlagen erzeugen (es gab z.B. frueher keinen Subtitle) 641 static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary(); 642 } 643 644 // Standardvorlage an der Drawing Engine setzen 645 String aName( SdResId(STR_STANDARD_STYLESHEET_NAME)); 646 SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_GRAPHICS))); 647 648 // Draw-Outliner und Dokument Outliner initialisieren, 649 // aber nicht den globalen Outliner, den der ist ja nicht 650 // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler 651 ::Outliner& rDrawOutliner = GetDrawOutliner(); 652 rDrawOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 653 sal_uLong nCntrl = rDrawOutliner.GetControlWord(); 654 if (mbOnlineSpell) 655 nCntrl |= EE_CNTRL_ONLINESPELLING; 656 else 657 nCntrl &= ~EE_CNTRL_ONLINESPELLING; 658 rDrawOutliner.SetControlWord(nCntrl); 659 660 // HitTest-Outliner und Dokument Outliner initialisieren, 661 // aber nicht den globalen Outliner, den der ist ja nicht 662 // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler 663 pHitTestOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 664 665 if(mpOutliner) 666 { 667 mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 668 } 669 if(mpInternalOutliner) 670 { 671 mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 672 } 673 674 if ( eMode == DOC_LOADED ) 675 { 676 // Praesentationsobjekte muessen wieder Listener der entsprechenden 677 // Vorlagen werden 678 SdStyleSheetPool* pSPool = (SdStyleSheetPool*) GetStyleSheetPool(); 679 sal_uInt16 nPage, nPageCount; 680 681 // #96323# create missing layout style sheets for broken documents 682 // that where created with the 5.2 683 nPageCount = GetMasterSdPageCount( PK_STANDARD ); 684 for (nPage = 0; nPage < nPageCount; nPage++) 685 { 686 SdPage* pPage = GetMasterSdPage(nPage, PK_STANDARD); 687 pSPool->CreateLayoutStyleSheets( pPage->GetName(), sal_True ); 688 } 689 690 // Standard- und Notizseiten: 691 for (nPage = 0; nPage < GetPageCount(); nPage++) 692 { 693 SdPage* pPage = (SdPage*)GetPage(nPage); 694 NewOrLoadCompleted( pPage, pSPool ); 695 } 696 697 // Masterpages: 698 for (nPage = 0; nPage < GetMasterPageCount(); nPage++) 699 { 700 SdPage* pPage = (SdPage*)GetMasterPage(nPage); 701 702 NewOrLoadCompleted( pPage, pSPool ); 703 } 704 } 705 706 mbNewOrLoadCompleted = sal_True; 707 708 /************************************************************************** 709 * Alle gelinkten Pages aktualisieren 710 **************************************************************************/ 711 SdPage* pPage = NULL; 712 sal_uInt16 nMaxSdPages = GetSdPageCount(PK_STANDARD); 713 714 for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++) 715 { 716 pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD); 717 718 if (pPage && pPage->GetFileName().Len() && pPage->GetBookmarkName().Len()) 719 { 720 pPage->SetModel(this); 721 } 722 } 723 724 UpdateAllLinks(); 725 726 SetChanged( sal_False ); 727 } 728 729 /** updates all links, only links in this document should by resolved */ 730 void SdDrawDocument::UpdateAllLinks() 731 { 732 if ( !pDocLockedInsertingLinks && pLinkManager && pLinkManager->GetLinks().Count() ) 733 { 734 pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved 735 736 pLinkManager->UpdateAllLinks(); // query box: update all links? 737 738 if( pDocLockedInsertingLinks == this ) 739 pDocLockedInsertingLinks = NULL; // unlock inserting links 740 } 741 } 742 743 /** this loops over the presentation objectes of a page and repairs some new settings 744 from old binary files and resets all default strings for empty presentation objects. 745 */ 746 void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool ) 747 { 748 /* cl removed because not needed anymore since binfilter 749 SdrObjListIter aShapeIter( *pPage ); 750 while( aShapeIter.IsMore() ) 751 { 752 OutlinerParaObject* pOPO = aShapeIter.Next()->GetOutlinerParaObject(); 753 if( pOPO ) 754 { 755 if( pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW ) 756 pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT ); 757 758 pOPO->FinishLoad( pSPool ); 759 } 760 } 761 */ 762 763 const sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() ); 764 if(!rPresentationShapes.isEmpty()) 765 { 766 // Listen mit Titel- und Gliederungsvorlagen erstellen 767 String aName = pPage->GetLayoutName(); 768 aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR )); 769 770 List* pOutlineList = pSPool->CreateOutlineSheetList(aName); 771 SfxStyleSheet* pTitleSheet = (SfxStyleSheet*) 772 pSPool->GetTitleSheet(aName); 773 774 SdrObject* pObj = rPresentationShapes.getNextShape(0); 775 776 // jetzt nach Titel- und Gliederungstextobjekten suchen und 777 // Objekte zu Listenern machen 778 while(pObj) 779 { 780 if (pObj->GetObjInventor() == SdrInventor) 781 { 782 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); 783 sal_uInt16 nId = pObj->GetObjIdentifier(); 784 785 if (nId == OBJ_TITLETEXT) 786 { 787 if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW ) 788 pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT ); 789 790 // sal_True: harte Attribute dabei nicht loeschen 791 if (pTitleSheet) 792 pObj->SetStyleSheet(pTitleSheet, sal_True); 793 } 794 else if (nId == OBJ_OUTLINETEXT) 795 { 796 if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW ) 797 pOPO->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT ); 798 799 for (sal_uInt16 nSheet = 0; nSheet < 10; nSheet++) 800 { 801 SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineList->GetObject(nSheet); 802 if (pSheet) 803 { 804 pObj->StartListening(*pSheet); 805 806 if( nSheet == 0) 807 // Textrahmen hoert auf StyleSheet der Ebene1 808 pObj->NbcSetStyleSheet(pSheet, sal_True); 809 } 810 } 811 } 812 813 if (pObj->ISA(SdrTextObj) && pObj->IsEmptyPresObj() && pPage) 814 { 815 PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj); 816 String aString( pPage->GetPresObjText(ePresObjKind) ); 817 818 if (aString.Len()) 819 { 820 sd::Outliner* pInternalOutl = GetInternalOutliner(sal_True); 821 pPage->SetObjText( (SdrTextObj*) pObj, pInternalOutl, ePresObjKind, aString ); 822 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), sal_True ); 823 pInternalOutl->Clear(); 824 } 825 } 826 } 827 828 pObj = rPresentationShapes.getNextShape(pObj); 829 } 830 831 delete pOutlineList; 832 } 833 } 834 835 /************************************************************************* 836 |* 837 |* Lokaler Outliner, welcher fuer den Gliederungsmodus verwendet wird 838 |* In diesen Outliner werden ggf. OutlinerViews inserted! 839 |* 840 \************************************************************************/ 841 842 ::sd::Outliner* SdDrawDocument::GetOutliner(sal_Bool bCreateOutliner) 843 { 844 if (!mpOutliner && bCreateOutliner) 845 { 846 mpOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT ); 847 848 if (mpDocSh) 849 mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) ); 850 851 mpOutliner->SetDefTab( nDefaultTabulator ); 852 mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 853 } 854 855 return(mpOutliner); 856 } 857 858 859 /************************************************************************* 860 |* 861 |* Interner Outliner, welcher fuer die Erzeugung von Textobjekten 862 |* verwendet wird. 863 |* In diesen Outliner werden keine OutlinerViews inserted! 864 |* 865 \************************************************************************/ 866 867 ::sd::Outliner* SdDrawDocument::GetInternalOutliner(sal_Bool bCreateOutliner) 868 { 869 if ( !mpInternalOutliner && bCreateOutliner ) 870 { 871 mpInternalOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT ); 872 // MT: 873 // Dieser Outliner wird nur fuer das Erzeugen spezieller Textobjekte 874 // verwendet. Da in diesen Textobjekten keine Portion-Informationen 875 // gespeichert werden muessen, kann/soll der Update-Mode immer sal_False bleiben. 876 mpInternalOutliner->SetUpdateMode( sal_False ); 877 mpInternalOutliner->EnableUndo( sal_False ); 878 879 if (mpDocSh) 880 mpInternalOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) ); 881 882 mpInternalOutliner->SetDefTab( nDefaultTabulator ); 883 mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); 884 } 885 886 DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->GetUpdateMode() == sal_False ) , "InternalOutliner: UpdateMode = sal_True !" ); 887 DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->IsUndoEnabled() == sal_False ), "InternalOutliner: Undo = sal_True !" ); 888 889 // MT: Wer ihn vollmuellt, macht ihn auch gleich wieder leer: 890 // Vorteile: 891 // a) Keine unnoetigen Clear-Aufrufe 892 // b) Kein Muell im Speicher. 893 DBG_ASSERT( !mpInternalOutliner || ( ( mpInternalOutliner->GetParagraphCount() == 1 ) && ( mpInternalOutliner->GetText( mpInternalOutliner->GetParagraph( 0 ) ).Len() == 0 ) ), "InternalOutliner: Nicht leer!" ); 894 895 return mpInternalOutliner; 896 } 897 898 /************************************************************************* 899 |* 900 |* OnlineSpelling ein/aus 901 |* 902 \************************************************************************/ 903 904 void SdDrawDocument::SetOnlineSpell(sal_Bool bIn) 905 { 906 mbOnlineSpell = bIn; 907 sal_uLong nCntrl = 0; 908 909 if(mpOutliner) 910 { 911 nCntrl = mpOutliner->GetControlWord(); 912 913 if(mbOnlineSpell) 914 nCntrl |= EE_CNTRL_ONLINESPELLING; 915 else 916 nCntrl &= ~EE_CNTRL_ONLINESPELLING; 917 918 mpOutliner->SetControlWord(nCntrl); 919 } 920 921 if (mpInternalOutliner) 922 { 923 nCntrl = mpInternalOutliner->GetControlWord(); 924 925 if (mbOnlineSpell) 926 nCntrl |= EE_CNTRL_ONLINESPELLING; 927 else 928 nCntrl &= ~EE_CNTRL_ONLINESPELLING; 929 930 mpInternalOutliner->SetControlWord(nCntrl); 931 } 932 933 ::Outliner& rOutliner = GetDrawOutliner(); 934 935 nCntrl = rOutliner.GetControlWord(); 936 937 if (mbOnlineSpell) 938 nCntrl |= EE_CNTRL_ONLINESPELLING; 939 else 940 nCntrl &= ~EE_CNTRL_ONLINESPELLING; 941 942 rOutliner.SetControlWord(nCntrl); 943 944 if (mbOnlineSpell) 945 { 946 StartOnlineSpelling(); 947 } 948 else 949 { 950 StopOnlineSpelling(); 951 } 952 } 953 954 955 /************************************************************************* 956 |* 957 |* OnlineSpelling: Markierung ein/aus 958 |* 959 \************************************************************************/ 960 961 uno::Reference< uno::XInterface > SdDrawDocument::createUnoModel() 962 { 963 uno::Reference< uno::XInterface > xModel; 964 965 try 966 { 967 if ( mpDocSh ) 968 xModel = mpDocSh->GetModel(); 969 } 970 catch( uno::RuntimeException& ) 971 { 972 } 973 974 return xModel; 975 } 976 977 SvxNumType SdDrawDocument::GetPageNumType() const 978 { 979 return mePageNumType; 980 } 981 982 983 984 985 void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode) 986 { 987 // #108104# 988 // DBG_ASSERT (mpDocSh!=NULL, "No available document shell to set ref device at."); 989 990 switch (nMode) 991 { 992 case ::com::sun::star::document::PrinterIndependentLayout::DISABLED: 993 case ::com::sun::star::document::PrinterIndependentLayout::ENABLED: 994 // Just store supported modes and inform the doc shell. 995 mnPrinterIndependentLayout = nMode; 996 997 // #108104# 998 // Since it is possible that a SdDrawDocument is constructed without a 999 // SdDrawDocShell the pointer member mpDocSh needs to be tested 1000 // before the call is executed. This is e.-g. used for copy/paste. 1001 if(mpDocSh) 1002 { 1003 mpDocSh->UpdateRefDevice (); 1004 } 1005 1006 break; 1007 1008 default: 1009 // Ignore unknown values. 1010 break; 1011 } 1012 } 1013 1014 sal_Int32 SdDrawDocument::GetPrinterIndependentLayout (void) 1015 { 1016 return mnPrinterIndependentLayout; 1017 } 1018 1019 bool SdDrawDocument::IsStartWithPresentation() const 1020 { 1021 return mbStartWithPresentation; 1022 } 1023 1024 void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation ) 1025 { 1026 mbStartWithPresentation = bStartWithPresentation; 1027 } 1028 1029 // #109538# 1030 void SdDrawDocument::PageListChanged() 1031 { 1032 mpDrawPageListWatcher->Invalidate(); 1033 } 1034 1035 // #109538# 1036 void SdDrawDocument::MasterPageListChanged() 1037 { 1038 mpMasterPageListWatcher->Invalidate(); 1039 } 1040 1041 void SdDrawDocument::SetCalcFieldValueHdl(::Outliner* pOutliner) 1042 { 1043 pOutliner->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl)); 1044 } 1045 1046 sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const rtl::OUString& rAuthor ) 1047 { 1048 // force current user to have first color 1049 if( maAnnotationAuthors.empty() ) 1050 { 1051 SvtUserOptions aUserOptions; 1052 maAnnotationAuthors.push_back( aUserOptions.GetFullName() ); 1053 } 1054 1055 sal_uInt16 idx = 0; 1056 for( std::vector< OUString >::iterator iter( maAnnotationAuthors.begin() ); iter != maAnnotationAuthors.end(); iter++ ) 1057 { 1058 if( (*iter) == rAuthor ) 1059 { 1060 break; 1061 } 1062 idx++; 1063 } 1064 1065 if( idx == maAnnotationAuthors.size() ) 1066 { 1067 maAnnotationAuthors.push_back( rAuthor ); 1068 } 1069 1070 return idx; 1071 } 1072 1073 // eof 1074