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