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