update dev300-m58
[ooovba.git] / sd / source / core / drawdoc.cxx
blob8211ff6ec8294f21f2eb8ec3d805826cd25e0945
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawdoc.cxx,v $
10 * $Revision: 1.87 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "PageListWatcher.hxx"
35 #include <com/sun/star/text/WritingMode.hpp>
36 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
37 #include <svx/forbiddencharacterstable.hxx>
39 #include <svx/svxids.hrc>
40 #include <sfx2/srchitem.hxx>
41 #include <svx/eeitem.hxx>
42 #include <svx/scriptspaceitem.hxx>
44 #ifndef _OFA_MISCCFG_HXX
45 #include <svtools/misccfg.hxx>
46 #endif
47 #include <sfx2/printer.hxx>
48 #include <sfx2/topfrm.hxx>
49 #include <sfx2/app.hxx>
50 #include <svx/linkmgr.hxx>
51 #include <svx/dialogs.hrc>
52 #include "Outliner.hxx"
53 #include "app.hxx"
54 #include <svx/eeitem.hxx>
55 #include <svx/editstat.hxx>
56 #include <svx/fontitem.hxx>
57 #include <svtools/flagitem.hxx>
58 #include <svx/svdoattr.hxx>
59 #include <svx/svdotext.hxx>
60 #include <svx/bulitem.hxx>
61 #include <svx/numitem.hxx>
62 #include <svx/svditer.hxx>
63 #include <svx/unolingu.hxx>
64 #include <svtools/itempool.hxx>
65 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
66 #include <svx/xtable.hxx>
67 #include <com/sun/star/linguistic2/XHyphenator.hpp>
68 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
69 #include <com/sun/star/beans/XPropertySet.hpp>
70 #include <svx/outlobj.hxx>
71 #include <svtools/saveopt.hxx>
72 #include <comphelper/extract.hxx>
73 #include <i18npool/mslangid.hxx>
74 #include <unotools/charclass.hxx>
75 #include <comphelper/processfactory.hxx>
76 #ifndef _SVTOOLS_PATHOPTIONS_HXX_
77 #include <svtools/pathoptions.hxx>
78 #endif
79 #include <svtools/lingucfg.hxx>
80 #include <svtools/linguprops.hxx>
82 #include "eetext.hxx"
83 #include "drawdoc.hxx"
84 #include "sdpage.hxx"
85 #include "pglink.hxx"
86 #include "sdattr.hxx"
87 #include "glob.hrc"
88 #include "glob.hxx"
89 #include "stlpool.hxx"
90 #include "sdiocmpt.hxx"
91 #include "sdresid.hxx"
92 #include "cusshow.hxx"
93 #include "../ui/inc/DrawDocShell.hxx"
94 #include "../ui/inc/GraphicDocShell.hxx"
95 #include "../ui/inc/sdxfer.hxx"
96 #include "../ui/inc/ViewShell.hxx"
97 #include "../ui/inc/optsitem.hxx"
98 #include "../ui/inc/FrameView.hxx"
100 // #90477#
101 #include <tools/tenccvt.hxx>
103 using ::rtl::OUString;
104 using namespace ::sd;
105 using namespace ::com::sun::star;
106 using namespace ::com::sun::star::uno;
107 using namespace ::com::sun::star::lang;
108 using namespace ::com::sun::star::linguistic2;
110 //////////////////////////////////////////////////////////////////////////////
112 TYPEINIT1( SdDrawDocument, FmFormModel );
114 SdDrawDocument* SdDrawDocument::pDocLockedInsertingLinks = NULL;
116 //////////////////////////////////////////////////////////////////////////////
118 PresentationSettings::PresentationSettings()
119 : mbAll( true ),
120 mbEndless( false ),
121 mbCustomShow(false),
122 mbManual( false ),
123 mbMouseVisible( false ),
124 mbMouseAsPen( false ),
125 mbLockedPages( false ),
126 mbAlwaysOnTop( false ),
127 mbFullScreen( true ),
128 mbAnimationAllowed( true ),
129 mnPauseTimeout( 10 ),
130 mbShowPauseLogo( false ),
131 mbStartWithNavigator(false)
135 // ---------------------------------------------------------------------------
137 PresentationSettings::PresentationSettings( const PresentationSettings& r )
138 : maPresPage( r.maPresPage ),
139 mbAll( r.mbAll ),
140 mbEndless( r.mbEndless ),
141 mbCustomShow( r.mbCustomShow ),
142 mbManual( r.mbManual ),
143 mbMouseVisible( r.mbMouseVisible ),
144 mbMouseAsPen( r.mbMouseAsPen ),
145 mbLockedPages( r.mbLockedPages ),
146 mbAlwaysOnTop( r.mbAlwaysOnTop ),
147 mbFullScreen( r.mbFullScreen ),
148 mbAnimationAllowed( r.mbAnimationAllowed ),
149 mnPauseTimeout( r.mnPauseTimeout ),
150 mbShowPauseLogo( r.mbShowPauseLogo ),
151 mbStartWithNavigator( r.mbStartWithNavigator )
155 // ---------------------------------------------------------------------------
157 SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
158 : FmFormModel( SvtPathOptions().GetPalettePath(), NULL, pDrDocSh )
159 , mpOutliner(NULL)
160 , mpInternalOutliner(NULL)
161 , mpWorkStartupTimer(NULL)
162 , mpOnlineSpellingTimer(NULL)
163 , mpOnlineSpellingList(NULL)
164 , mpOnlineSearchItem(NULL)
165 , mpFrameViewList( new List() )
166 , mpCustomShowList(NULL)
167 , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh))
168 , mpCreatingTransferable( NULL )
169 , mbHasOnlineSpellErrors(FALSE)
170 , mbInitialOnlineSpellingEnabled(TRUE)
171 , mbNewOrLoadCompleted(FALSE)
172 , mbStartWithPresentation( false )
173 , meLanguage( LANGUAGE_SYSTEM )
174 , meLanguageCJK( LANGUAGE_SYSTEM )
175 , meLanguageCTL( LANGUAGE_SYSTEM )
176 , mePageNumType(SVX_ARABIC)
177 , mbAllocDocSh(FALSE)
178 , meDocType(eType)
179 , mpCharClass(NULL)
180 , mpLocale(NULL)
181 , mpDrawPageListWatcher(0)
182 , mpMasterPageListWatcher(0)
184 // #109538#
185 mpDrawPageListWatcher = ::std::auto_ptr<ImpDrawPageListWatcher>(
186 new ImpDrawPageListWatcher(*this));
187 mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>(
188 new ImpMasterPageListWatcher(*this));
190 SetObjectShell(pDrDocSh); // fuer das VCDrawModel
192 if (mpDocSh)
194 SetSwapGraphics(TRUE);
197 // Masseinheit (von App) und Massstab (von SdMod) setzen
198 INT32 nX, nY;
199 SdOptions* pOptions = SD_MOD()->GetSdOptions(meDocType);
200 pOptions->GetScale( nX, nY );
202 // #92067# Allow UI scale only for draw documents.
203 if( eType == DOCUMENT_TYPE_DRAW )
204 SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) ); // user-defined
205 else
206 SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) ); // default
208 SetScaleUnit(MAP_100TH_MM);
209 SetScaleFraction(Fraction(1, 1));
210 SetDefaultFontHeight(847); // 24p
212 pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
213 pItemPool->FreezeIdRanges();
214 SetTextDefaults();
216 // die DrawingEngine muss auch wissen, wo er ist
217 FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) );
219 // Dem DrawOutliner den StyleSheetPool setzen, damit Textobjekte richtig
220 // eingelesen werden koennen. Der Link zum StyleRequest-Handler des
221 // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle
222 // Vorlagen existieren.
223 SdrOutliner& rOutliner = GetDrawOutliner();
224 rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
225 rOutliner.SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
227 // set linguistic options
229 const SvtLinguConfig aLinguConfig;
230 SvtLinguOptions aOptions;
231 aLinguConfig.GetOptions( aOptions );
233 SetLanguage( aOptions.nDefaultLanguage, EE_CHAR_LANGUAGE );
234 SetLanguage( aOptions.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK );
235 SetLanguage( aOptions.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL );
237 mbOnlineSpell = aOptions.bIsSpellAuto;
240 LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage );
241 mpLocale = new ::com::sun::star::lang::Locale( MsLangId::convertLanguageToLocale( eRealLanguage ));
242 mpCharClass = new CharClass( *mpLocale );
244 // If the current application language is a language that uses right-to-left text...
245 LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguage();
246 if( MsLangId::isRightToLeft( eRealCTLLanguage ) )
248 // ... then we have to set this as a default
249 SetDefaultWritingMode( ::com::sun::star::text::WritingMode_RL_TB );
252 // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text
253 if( ( LANGUAGE_KOREAN == eRealCTLLanguage ) || ( LANGUAGE_KOREAN_JOHAB == eRealCTLLanguage ) || ( LANGUAGE_JAPANESE == eRealCTLLanguage ) )
255 GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( FALSE, EE_PARA_ASIANCJKSPACING ) );
258 // DefTab und SpellOptions setzen
259 //OfaMiscCfg* pOfaMiscCfg = SFX_APP()->GetMiscConfig();
260 // Jetzt am Modul (SD)
261 USHORT nDefTab = pOptions->GetDefTab();
262 SetDefaultTabulator( nDefTab );
266 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
267 if ( xSpellChecker.is() )
268 rOutliner.SetSpeller( xSpellChecker );
270 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
271 if( xHyphenator.is() )
272 rOutliner.SetHyphenator( xHyphenator );
274 SetForbiddenCharsTable( new SvxForbiddenCharactersTable( ::comphelper::getProcessServiceFactory() ) );
276 catch(...)
278 DBG_ERROR("Can't get SpellChecker");
281 rOutliner.SetDefaultLanguage( Application::GetSettings().GetLanguage() );
283 if (mpDocSh)
285 SetLinkManager( new SvxLinkManager(mpDocSh) );
288 ULONG nCntrl = rOutliner.GetControlWord();
289 nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
290 nCntrl |= EE_CNTRL_URLSFXEXECUTE;
292 if (mbOnlineSpell)
293 nCntrl |= EE_CNTRL_ONLINESPELLING;
294 else
295 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
297 nCntrl &= ~ EE_CNTRL_ULSPACESUMMATION;
298 if ( meDocType != DOCUMENT_TYPE_IMPRESS )
299 SetSummationOfParagraphs( sal_False );
300 else
302 SetSummationOfParagraphs( pOptions->IsSummationOfParagraphs() );
303 if ( pOptions->IsSummationOfParagraphs() )
304 nCntrl |= EE_CNTRL_ULSPACESUMMATION;
306 rOutliner.SetControlWord(nCntrl);
308 // Initialize the printer independent layout mode.
309 SetPrinterIndependentLayout (pOptions->GetPrinterIndependentLayout());
311 // Dem HitTestOutliner den StyleSheetPool setzen.
312 // Der Link zum StyleRequest-Handler des
313 // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle
314 // Vorlagen existieren.
315 SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() );
316 pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() );
318 pHitTestOutliner->SetCalcFieldValueHdl( LINK(SD_MOD(), SdModule, CalcFieldValueHdl) );
322 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
323 if ( xSpellChecker.is() )
324 pHitTestOutliner->SetSpeller( xSpellChecker );
326 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
327 if( xHyphenator.is() )
328 pHitTestOutliner->SetHyphenator( xHyphenator );
330 catch(...)
332 DBG_ERROR("Can't get SpellChecker");
335 pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
337 ULONG nCntrl2 = pHitTestOutliner->GetControlWord();
338 nCntrl2 |= EE_CNTRL_ALLOWBIGOBJS;
339 nCntrl2 |= EE_CNTRL_URLSFXEXECUTE;
340 nCntrl2 &= ~EE_CNTRL_ONLINESPELLING;
342 nCntrl2 &= ~ EE_CNTRL_ULSPACESUMMATION;
343 if ( pOptions->IsSummationOfParagraphs() )
344 nCntrl2 |= EE_CNTRL_ULSPACESUMMATION;
346 pHitTestOutliner->SetControlWord( nCntrl2 );
348 /**************************************************************************
349 * Layer anlegen
351 * Es werden auf Pages und MasterPages folgende Default-Layer angelegt:
353 * Layer STR_LAYOUT : Standardlayer f�r alle Zeichenobjekte
355 * Layer STR_BCKGRND : Hintergrund der MasterPage
356 * (auf normalen Pages z.Z. keine Verwendung)
358 * Layer STR_BCKGRNDOBJ: Objekte auf dem Hintergrund der MasterPage
359 * (auf normalen Pages z.Z. keine Verwendung)
361 * Layer STR_CONTROLS : Standardlayer f�r Controls
363 **************************************************************************/
365 String aControlLayerName( SdResId(STR_LAYER_CONTROLS) );
367 SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
368 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_LAYOUT)) );
369 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRND)) );
370 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRNDOBJ)) );
371 rLayerAdmin.NewLayer( aControlLayerName );
372 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_MEASURELINES)) );
374 rLayerAdmin.SetControlLayerName(aControlLayerName);
380 /*************************************************************************
382 |* Destruktor
384 \************************************************************************/
386 SdDrawDocument::~SdDrawDocument()
388 Broadcast(SdrHint(HINT_MODELCLEARED));
390 if (mpWorkStartupTimer)
392 if ( mpWorkStartupTimer->IsActive() )
393 mpWorkStartupTimer->Stop();
395 delete mpWorkStartupTimer;
396 mpWorkStartupTimer = NULL;
399 StopOnlineSpelling();
400 delete mpOnlineSearchItem;
401 mpOnlineSearchItem = NULL;
403 CloseBookmarkDoc();
404 SetAllocDocSh(FALSE);
406 // #116168#
407 ClearModel(sal_True);
409 if (pLinkManager)
411 // BaseLinks freigeben
412 if ( pLinkManager->GetLinks().Count() )
414 pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() );
417 delete pLinkManager;
418 pLinkManager = NULL;
421 ::sd::FrameView* pFrameView = NULL;
423 for (ULONG i = 0; i < mpFrameViewList->Count(); i++)
425 // Ggf. FrameViews loeschen
426 pFrameView =
427 static_cast< ::sd::FrameView*>(mpFrameViewList->GetObject(i));
429 if (pFrameView)
430 delete pFrameView;
433 delete mpFrameViewList;
434 mpFrameViewList = NULL;
436 if (mpCustomShowList)
438 for (ULONG j = 0; j < mpCustomShowList->Count(); j++)
440 // Ggf. CustomShows loeschen
441 SdCustomShow* pCustomShow = (SdCustomShow*) mpCustomShowList->GetObject(j);
442 delete pCustomShow;
445 delete mpCustomShowList;
446 mpCustomShowList = NULL;
449 delete mpOutliner;
450 mpOutliner = NULL;
452 delete mpInternalOutliner;
453 mpInternalOutliner = NULL;
455 delete mpLocale;
456 mpLocale = NULL;
458 delete mpCharClass;
459 mpCharClass = NULL;
462 /*************************************************************************
464 |* Diese Methode erzeugt ein neues Dokument (SdDrawDocument) und gibt einen
465 |* Zeiger darauf zurueck. Die Drawing Engine benutzt diese Methode um das
466 |* Dokument oder Teile davon ins Clipboard/DragServer stellen zu koennen.
468 \************************************************************************/
470 SdrModel* SdDrawDocument::AllocModel() const
472 SdDrawDocument* pNewModel = NULL;
474 if( mpCreatingTransferable )
476 // Dokument wird fuer Drag&Drop/Clipboard erzeugt, dafuer muss dem Dokument eine DocShell (SvPersist) bekannt sein
477 SfxObjectShell* pObj = NULL;
478 ::sd::DrawDocShell* pNewDocSh = NULL;
480 if( meDocType == DOCUMENT_TYPE_IMPRESS )
481 mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell(
482 SFX_CREATE_MODE_EMBEDDED, TRUE, meDocType ) );
483 else
484 mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell(
485 SFX_CREATE_MODE_EMBEDDED, TRUE, meDocType ) );
487 pNewDocSh = static_cast< ::sd::DrawDocShell*>( pObj = mpCreatingTransferable->GetDocShell() );
488 pNewDocSh->DoInitNew( NULL );
489 pNewModel = pNewDocSh->GetDoc();
491 // Nur fuer Clipboard notwendig,
492 // fuer Drag&Drop erfolgt dieses im DragServer
493 SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
494 SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pNewModel->GetStyleSheetPool();
496 pNewStylePool->CopyGraphicSheets(*pOldStylePool);
497 pNewStylePool->CopyCellSheets(*pOldStylePool);
498 pNewStylePool->CopyTableStyles(*pOldStylePool);
501 for (USHORT i = 0; i < GetMasterSdPageCount(PK_STANDARD); i++)
503 // Alle Layouts der MasterPage mitnehmen
504 String aOldLayoutName(((SdDrawDocument*) this)->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName());
505 aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
506 SdStyleSheetVector aCreatedSheets;
507 pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets );
510 pNewModel->NewOrLoadCompleted( DOC_LOADED ); // loaded from source document
512 else if( mbAllocDocSh )
514 // Es wird eine DocShell erzeugt, welche mit GetAllocedDocSh() zurueckgegeben wird
515 SdDrawDocument* pDoc = (SdDrawDocument*) this;
516 pDoc->SetAllocDocSh(FALSE);
517 pDoc->mxAllocedDocShRef = new ::sd::DrawDocShell(
518 SFX_CREATE_MODE_EMBEDDED, TRUE, meDocType);
519 pDoc->mxAllocedDocShRef->DoInitNew(NULL);
520 pNewModel = pDoc->mxAllocedDocShRef->GetDoc();
522 else
524 pNewModel = new SdDrawDocument(meDocType, NULL);
527 return pNewModel;
530 /*************************************************************************
532 |* Diese Methode erzeugt eine neue Seite (SdPage) und gibt einen Zeiger
533 |* darauf zurueck. Die Drawing Engine benutzt diese Methode beim Laden
534 |* zur Erzeugung von Seiten (deren Typ sie ja nicht kennt, da es ABLEITUNGEN
535 |* der SdrPage sind).
537 \************************************************************************/
539 SdrPage* SdDrawDocument::AllocPage(FASTBOOL bMasterPage)
541 return new SdPage(*this, NULL, (BOOL)bMasterPage);
544 /*************************************************************************
546 |* SetChanged(), das Model wurde geaendert
548 \************************************************************************/
550 void SdDrawDocument::SetChanged(sal_Bool bFlag)
552 if (mpDocSh)
554 if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified())
556 // weitergeben an Basisklasse
557 FmFormModel::SetChanged(bFlag);
559 // an ObjectShell weiterleiten
560 mpDocSh->SetModified(bFlag);
563 else
565 // weitergeben an Basisklasse
566 FmFormModel::SetChanged(bFlag);
570 /*************************************************************************
572 |* NbcSetChanged(), the model changed, don't call anybody else
574 \************************************************************************/
576 void SdDrawDocument::NbcSetChanged(sal_Bool bFlag)
578 // #100237# forward to baseclass
579 FmFormModel::SetChanged(bFlag);
582 /*************************************************************************
584 |* NewOrLoadCompleted
586 |* Wird gerufen, wenn das Dokument geladen wurde bzw. feststeht, dass es
587 |* nicht mehr geladen wird.
589 \************************************************************************/
591 void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode)
593 if (eMode == NEW_DOC)
595 // Neues Dokument:
596 // Praesentations- und Standardvorlagen erzeugen,
597 // Pool fuer virtuelle Controls erzeugen
598 CreateLayoutTemplates();
599 CreateDefaultCellStyles();
601 static_cast< SdStyleSheetPool* >( mxStyleSheetPool.get() )->CreatePseudosIfNecessary();
603 else if (eMode == DOC_LOADED)
605 // Dokument wurde geladen:
607 CheckMasterPages();
609 if ( GetMasterSdPageCount(PK_STANDARD) > 1 )
610 RemoveUnnecessaryMasterPages( NULL, TRUE, FALSE );
612 for ( USHORT i = 0; i < GetPageCount(); i++ )
614 // Check for correct layout names
615 SdPage* pPage = (SdPage*) GetPage( i );
617 if(pPage->TRG_HasMasterPage())
619 SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage();
621 if(rMaster.GetLayoutName() != pPage->GetLayoutName())
623 pPage->SetLayoutName(rMaster.GetLayoutName());
628 for ( USHORT nPage = 0; nPage < GetMasterPageCount(); nPage++)
630 // LayoutName and PageName must be the same
631 SdPage* pPage = (SdPage*) GetMasterPage( nPage );
633 String aName( pPage->GetLayoutName() );
634 aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ) );
636 if( aName != pPage->GetName() )
637 pPage->SetName( aName );
639 SdrObject* pPresObj = pPage->GetPresObj( PRESOBJ_BACKGROUND ) ;
641 if( pPage->GetPageKind() == PK_STANDARD )
643 DBG_ASSERT( pPresObj, "Masterpage without a background object!" );
644 if (pPresObj && pPresObj->GetOrdNum() != 0 )
645 pPage->NbcSetObjectOrdNum(pPresObj->GetOrdNum(),0);
647 else
649 DBG_ASSERT( pPresObj == NULL, "Non Standard Masterpage with a background object!\n(This assertion is ok for old binary files)" );
650 if( pPresObj )
652 pPage->RemoveObject( pPresObj->GetOrdNum() );
653 pPage->RemovePresObj(pPresObj);
654 SdrObject::Free( pPresObj );
659 // Sprachabhaengige Namen der StandardLayer erzeugen
660 RestoreLayerNames();
662 // Sprachabhaengige Namen der Vorlagen setzen
663 static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames();
665 // Ggf. fehlende Vorlagen erzeugen (es gab z.B. frueher keinen Subtitle)
666 static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary();
669 // Standardvorlage an der Drawing Engine setzen
670 String aName( SdResId(STR_STANDARD_STYLESHEET_NAME));
671 SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_GRAPHICS)));
673 // Draw-Outliner und Dokument Outliner initialisieren,
674 // aber nicht den globalen Outliner, den der ist ja nicht
675 // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler
676 ::Outliner& rDrawOutliner = GetDrawOutliner();
677 rDrawOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
678 ULONG nCntrl = rDrawOutliner.GetControlWord();
679 if (mbOnlineSpell)
680 nCntrl |= EE_CNTRL_ONLINESPELLING;
681 else
682 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
683 rDrawOutliner.SetControlWord(nCntrl);
685 // HitTest-Outliner und Dokument Outliner initialisieren,
686 // aber nicht den globalen Outliner, den der ist ja nicht
687 // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler
688 pHitTestOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
690 if(mpOutliner)
692 mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
694 if(mpInternalOutliner)
696 mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
699 if ( eMode == DOC_LOADED )
701 // Praesentationsobjekte muessen wieder Listener der entsprechenden
702 // Vorlagen werden
703 SdStyleSheetPool* pSPool = (SdStyleSheetPool*) GetStyleSheetPool();
704 USHORT nPage, nPageCount;
706 // #96323# create missing layout style sheets for broken documents
707 // that where created with the 5.2
708 nPageCount = GetMasterSdPageCount( PK_STANDARD );
709 for (nPage = 0; nPage < nPageCount; nPage++)
711 SdPage* pPage = GetMasterSdPage(nPage, PK_STANDARD);
712 pSPool->CreateLayoutStyleSheets( pPage->GetName(), sal_True );
715 // Standard- und Notizseiten:
716 for (nPage = 0; nPage < GetPageCount(); nPage++)
718 SdPage* pPage = (SdPage*)GetPage(nPage);
719 NewOrLoadCompleted( pPage, pSPool );
722 // Masterpages:
723 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
725 SdPage* pPage = (SdPage*)GetMasterPage(nPage);
727 NewOrLoadCompleted( pPage, pSPool );
729 // BackgroundObjekt vor Selektion schuetzen #62144#
730 SdrObject* pBackObj = pPage->GetPresObj(PRESOBJ_BACKGROUND);
731 if(pBackObj)
732 pBackObj->SetMarkProtect(TRUE);
736 mbNewOrLoadCompleted = TRUE;
738 /**************************************************************************
739 * Alle gelinkten Pages aktualisieren
740 **************************************************************************/
741 SdPage* pPage = NULL;
742 USHORT nMaxSdPages = GetSdPageCount(PK_STANDARD);
744 for (USHORT nSdPage=0; nSdPage < nMaxSdPages; nSdPage++)
746 pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD);
748 if (pPage && pPage->GetFileName().Len() && pPage->GetBookmarkName().Len())
750 pPage->SetModel(this);
754 UpdateAllLinks();
756 SetChanged( FALSE );
759 /** updates all links, only links in this document should by resolved */
760 void SdDrawDocument::UpdateAllLinks()
762 if ( !pDocLockedInsertingLinks && pLinkManager && pLinkManager->GetLinks().Count() )
764 pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved
766 pLinkManager->UpdateAllLinks(); // query box: update all links?
768 if( pDocLockedInsertingLinks == this )
769 pDocLockedInsertingLinks = NULL; // unlock inserting links
773 /** this loops over the presentation objectes of a page and repairs some new settings
774 from old binary files and resets all default strings for empty presentation objects.
776 void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool )
778 /* cl removed because not needed anymore since binfilter
779 SdrObjListIter aShapeIter( *pPage );
780 while( aShapeIter.IsMore() )
782 OutlinerParaObject* pOPO = aShapeIter.Next()->GetOutlinerParaObject();
783 if( pOPO )
785 if( pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
786 pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT );
788 pOPO->FinishLoad( pSPool );
793 const sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() );
794 if(!rPresentationShapes.isEmpty())
796 // Listen mit Titel- und Gliederungsvorlagen erstellen
797 String aName = pPage->GetLayoutName();
798 aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ));
800 List* pOutlineList = pSPool->CreateOutlineSheetList(aName);
801 SfxStyleSheet* pTitleSheet = (SfxStyleSheet*)
802 pSPool->GetTitleSheet(aName);
804 SdrObject* pObj = rPresentationShapes.getNextShape(0);
806 // jetzt nach Titel- und Gliederungstextobjekten suchen und
807 // Objekte zu Listenern machen
808 while(pObj)
810 if (pObj->GetObjInventor() == SdrInventor)
812 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
813 UINT16 nId = pObj->GetObjIdentifier();
815 if (nId == OBJ_TITLETEXT)
817 if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
818 pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT );
820 // TRUE: harte Attribute dabei nicht loeschen
821 if (pTitleSheet)
822 pObj->SetStyleSheet(pTitleSheet, TRUE);
824 else if (nId == OBJ_OUTLINETEXT)
826 if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
827 pOPO->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
829 for (USHORT nSheet = 0; nSheet < 10; nSheet++)
831 SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineList->GetObject(nSheet);
832 if (pSheet)
834 pObj->StartListening(*pSheet);
836 if( nSheet == 0)
837 // Textrahmen hoert auf StyleSheet der Ebene1
838 pObj->NbcSetStyleSheet(pSheet, TRUE);
843 if (pObj->ISA(SdrTextObj) && pObj->IsEmptyPresObj() && pPage)
845 PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj);
846 String aString( pPage->GetPresObjText(ePresObjKind) );
848 if (aString.Len())
850 sd::Outliner* pInternalOutl = GetInternalOutliner(TRUE);
851 pPage->SetObjText( (SdrTextObj*) pObj, pInternalOutl, ePresObjKind, aString );
852 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), TRUE );
853 pInternalOutl->Clear();
858 pObj = rPresentationShapes.getNextShape(pObj);
861 delete pOutlineList;
865 /*************************************************************************
867 |* Lokaler Outliner, welcher fuer den Gliederungsmodus verwendet wird
868 |* In diesen Outliner werden ggf. OutlinerViews inserted!
870 \************************************************************************/
872 ::sd::Outliner* SdDrawDocument::GetOutliner(BOOL bCreateOutliner)
874 if (!mpOutliner && bCreateOutliner)
876 mpOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
878 if (mpDocSh)
879 mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
881 mpOutliner->SetDefTab( nDefaultTabulator );
882 mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
885 return(mpOutliner);
889 /*************************************************************************
891 |* Interner Outliner, welcher fuer die Erzeugung von Textobjekten
892 |* verwendet wird.
893 |* In diesen Outliner werden keine OutlinerViews inserted!
895 \************************************************************************/
897 ::sd::Outliner* SdDrawDocument::GetInternalOutliner(BOOL bCreateOutliner)
899 if ( !mpInternalOutliner && bCreateOutliner )
901 mpInternalOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
902 // MT:
903 // Dieser Outliner wird nur fuer das Erzeugen spezieller Textobjekte
904 // verwendet. Da in diesen Textobjekten keine Portion-Informationen
905 // gespeichert werden muessen, kann/soll der Update-Mode immer FALSE bleiben.
906 mpInternalOutliner->SetUpdateMode( FALSE );
907 mpInternalOutliner->EnableUndo( FALSE );
909 if (mpDocSh)
910 mpInternalOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
912 mpInternalOutliner->SetDefTab( nDefaultTabulator );
913 mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
916 DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->GetUpdateMode() == FALSE ) , "InternalOutliner: UpdateMode = TRUE !" );
917 DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->IsUndoEnabled() == FALSE ), "InternalOutliner: Undo = TRUE !" );
919 // MT: Wer ihn vollmuellt, macht ihn auch gleich wieder leer:
920 // Vorteile:
921 // a) Keine unnoetigen Clear-Aufrufe
922 // b) Kein Muell im Speicher.
923 DBG_ASSERT( !mpInternalOutliner || ( ( mpInternalOutliner->GetParagraphCount() == 1 ) && ( mpInternalOutliner->GetText( mpInternalOutliner->GetParagraph( 0 ) ).Len() == 0 ) ), "InternalOutliner: Nicht leer!" );
925 return mpInternalOutliner;
928 /*************************************************************************
930 |* OnlineSpelling ein/aus
932 \************************************************************************/
934 void SdDrawDocument::SetOnlineSpell(BOOL bIn)
936 mbOnlineSpell = bIn;
937 ULONG nCntrl = 0;
939 if(mpOutliner)
941 nCntrl = mpOutliner->GetControlWord();
943 if(mbOnlineSpell)
944 nCntrl |= EE_CNTRL_ONLINESPELLING;
945 else
946 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
948 mpOutliner->SetControlWord(nCntrl);
951 if (mpInternalOutliner)
953 nCntrl = mpInternalOutliner->GetControlWord();
955 if (mbOnlineSpell)
956 nCntrl |= EE_CNTRL_ONLINESPELLING;
957 else
958 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
960 mpInternalOutliner->SetControlWord(nCntrl);
963 ::Outliner& rOutliner = GetDrawOutliner();
965 nCntrl = rOutliner.GetControlWord();
967 if (mbOnlineSpell)
968 nCntrl |= EE_CNTRL_ONLINESPELLING;
969 else
970 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
972 rOutliner.SetControlWord(nCntrl);
974 if (mbOnlineSpell)
976 StartOnlineSpelling();
978 else
980 StopOnlineSpelling();
985 /*************************************************************************
987 |* OnlineSpelling: Markierung ein/aus
989 \************************************************************************/
991 uno::Reference< uno::XInterface > SdDrawDocument::createUnoModel()
993 uno::Reference< uno::XInterface > xModel;
997 if ( mpDocSh )
998 xModel = mpDocSh->GetModel();
1000 catch( uno::RuntimeException& )
1004 return xModel;
1007 SvxNumType SdDrawDocument::GetPageNumType() const
1009 return mePageNumType;
1015 void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode)
1017 // #108104#
1018 // DBG_ASSERT (mpDocSh!=NULL, "No available document shell to set ref device at.");
1020 switch (nMode)
1022 case ::com::sun::star::document::PrinterIndependentLayout::DISABLED:
1023 case ::com::sun::star::document::PrinterIndependentLayout::ENABLED:
1024 // Just store supported modes and inform the doc shell.
1025 mnPrinterIndependentLayout = nMode;
1027 // #108104#
1028 // Since it is possible that a SdDrawDocument is constructed without a
1029 // SdDrawDocShell the pointer member mpDocSh needs to be tested
1030 // before the call is executed. This is e.-g. used for copy/paste.
1031 if(mpDocSh)
1033 mpDocSh->UpdateRefDevice ();
1036 break;
1038 default:
1039 // Ignore unknown values.
1040 break;
1044 sal_Int32 SdDrawDocument::GetPrinterIndependentLayout (void)
1046 return mnPrinterIndependentLayout;
1049 bool SdDrawDocument::IsStartWithPresentation() const
1051 return mbStartWithPresentation;
1054 void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation )
1056 mbStartWithPresentation = bStartWithPresentation;
1059 // #109538#
1060 void SdDrawDocument::PageListChanged()
1062 mpDrawPageListWatcher->Invalidate();
1065 // #109538#
1066 void SdDrawDocument::MasterPageListChanged()
1068 mpMasterPageListWatcher->Invalidate();
1072 // eof