merge the formfield patch from ooo-build
[ooovba.git] / sd / source / core / drawdoc.cxx
blob624fa6fc5c8a24b7f3d23db7e92d80842199f70d
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 <com/sun/star/i18n/ScriptType.hpp>
38 #include <svx/forbiddencharacterstable.hxx>
40 #include <svx/svxids.hrc>
41 #include <sfx2/srchitem.hxx>
42 #include <svx/eeitem.hxx>
43 #include <svx/scriptspaceitem.hxx>
45 #include <svtools/useroptions.hxx>
47 #ifndef _OFA_MISCCFG_HXX
48 #include <svtools/misccfg.hxx>
49 #endif
50 #include <sfx2/printer.hxx>
51 #include <sfx2/topfrm.hxx>
52 #include <sfx2/app.hxx>
53 #include <svx/linkmgr.hxx>
54 #include <svx/dialogs.hrc>
55 #include "Outliner.hxx"
56 #include "app.hxx"
57 #include <svx/eeitem.hxx>
58 #include <svx/editstat.hxx>
59 #include <svx/fontitem.hxx>
60 #include <svtools/flagitem.hxx>
61 #include <svx/svdoattr.hxx>
62 #include <svx/svdotext.hxx>
63 #include <svx/bulitem.hxx>
64 #include <svx/numitem.hxx>
65 #include <svx/svditer.hxx>
66 #include <svx/unolingu.hxx>
67 #include <svtools/itempool.hxx>
68 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
69 #include <svx/xtable.hxx>
70 #include <com/sun/star/linguistic2/XHyphenator.hpp>
71 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
72 #include <com/sun/star/beans/XPropertySet.hpp>
73 #include <svx/outlobj.hxx>
74 #include <svtools/saveopt.hxx>
75 #include <comphelper/extract.hxx>
76 #include <i18npool/mslangid.hxx>
77 #include <unotools/charclass.hxx>
78 #include <comphelper/processfactory.hxx>
79 #ifndef _SVTOOLS_PATHOPTIONS_HXX_
80 #include <svtools/pathoptions.hxx>
81 #endif
82 #include <svtools/lingucfg.hxx>
83 #include <svtools/linguprops.hxx>
85 #include "eetext.hxx"
86 #include "drawdoc.hxx"
87 #include "sdpage.hxx"
88 #include "pglink.hxx"
89 #include "sdattr.hxx"
90 #include "glob.hrc"
91 #include "glob.hxx"
92 #include "stlpool.hxx"
93 #include "sdiocmpt.hxx"
94 #include "sdresid.hxx"
95 #include "cusshow.hxx"
96 #include "../ui/inc/DrawDocShell.hxx"
97 #include "../ui/inc/GraphicDocShell.hxx"
98 #include "../ui/inc/sdxfer.hxx"
99 #include "../ui/inc/ViewShell.hxx"
100 #include "../ui/inc/optsitem.hxx"
101 #include "../ui/inc/FrameView.hxx"
103 // #90477#
104 #include <tools/tenccvt.hxx>
106 using ::rtl::OUString;
107 using namespace ::sd;
108 using namespace ::com::sun::star;
109 using namespace ::com::sun::star::uno;
110 using namespace ::com::sun::star::lang;
111 using namespace ::com::sun::star::linguistic2;
113 //////////////////////////////////////////////////////////////////////////////
115 TYPEINIT1( SdDrawDocument, FmFormModel );
117 SdDrawDocument* SdDrawDocument::pDocLockedInsertingLinks = NULL;
119 //////////////////////////////////////////////////////////////////////////////
121 PresentationSettings::PresentationSettings()
122 : mbAll( true ),
123 mbEndless( false ),
124 mbCustomShow(false),
125 mbManual( false ),
126 mbMouseVisible( false ),
127 mbMouseAsPen( false ),
128 mbLockedPages( false ),
129 mbAlwaysOnTop( false ),
130 mbFullScreen( true ),
131 mbAnimationAllowed( true ),
132 mnPauseTimeout( 10 ),
133 mbShowPauseLogo( false ),
134 mbStartWithNavigator(false)
138 // ---------------------------------------------------------------------------
140 PresentationSettings::PresentationSettings( const PresentationSettings& r )
141 : maPresPage( r.maPresPage ),
142 mbAll( r.mbAll ),
143 mbEndless( r.mbEndless ),
144 mbCustomShow( r.mbCustomShow ),
145 mbManual( r.mbManual ),
146 mbMouseVisible( r.mbMouseVisible ),
147 mbMouseAsPen( r.mbMouseAsPen ),
148 mbLockedPages( r.mbLockedPages ),
149 mbAlwaysOnTop( r.mbAlwaysOnTop ),
150 mbFullScreen( r.mbFullScreen ),
151 mbAnimationAllowed( r.mbAnimationAllowed ),
152 mnPauseTimeout( r.mnPauseTimeout ),
153 mbShowPauseLogo( r.mbShowPauseLogo ),
154 mbStartWithNavigator( r.mbStartWithNavigator )
158 // ---------------------------------------------------------------------------
160 SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
161 : FmFormModel( SvtPathOptions().GetPalettePath(), NULL, pDrDocSh )
162 , mpOutliner(NULL)
163 , mpInternalOutliner(NULL)
164 , mpWorkStartupTimer(NULL)
165 , mpOnlineSpellingTimer(NULL)
166 , mpOnlineSpellingList(NULL)
167 , mpOnlineSearchItem(NULL)
168 , mpFrameViewList( new List() )
169 , mpCustomShowList(NULL)
170 , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh))
171 , mpCreatingTransferable( NULL )
172 , mbHasOnlineSpellErrors(FALSE)
173 , mbInitialOnlineSpellingEnabled(TRUE)
174 , mbNewOrLoadCompleted(FALSE)
175 , mbStartWithPresentation( false )
176 , meLanguage( LANGUAGE_SYSTEM )
177 , meLanguageCJK( LANGUAGE_SYSTEM )
178 , meLanguageCTL( LANGUAGE_SYSTEM )
179 , mePageNumType(SVX_ARABIC)
180 , mbAllocDocSh(FALSE)
181 , meDocType(eType)
182 , mpCharClass(NULL)
183 , mpLocale(NULL)
184 , mpDrawPageListWatcher(0)
185 , mpMasterPageListWatcher(0)
187 // #109538#
188 mpDrawPageListWatcher = ::std::auto_ptr<ImpDrawPageListWatcher>(
189 new ImpDrawPageListWatcher(*this));
190 mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>(
191 new ImpMasterPageListWatcher(*this));
193 SetObjectShell(pDrDocSh); // fuer das VCDrawModel
195 if (mpDocSh)
197 SetSwapGraphics(TRUE);
200 // Masseinheit (von App) und Massstab (von SdMod) setzen
201 INT32 nX, nY;
202 SdOptions* pOptions = SD_MOD()->GetSdOptions(meDocType);
203 pOptions->GetScale( nX, nY );
205 // #92067# Allow UI scale only for draw documents.
206 if( eType == DOCUMENT_TYPE_DRAW )
207 SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) ); // user-defined
208 else
209 SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) ); // default
211 SetScaleUnit(MAP_100TH_MM);
212 SetScaleFraction(Fraction(1, 1));
213 SetDefaultFontHeight(847); // 24p
215 pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
216 pItemPool->FreezeIdRanges();
217 SetTextDefaults();
219 // die DrawingEngine muss auch wissen, wo er ist
220 FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) );
222 // Dem DrawOutliner den StyleSheetPool setzen, damit Textobjekte richtig
223 // eingelesen werden koennen. Der Link zum StyleRequest-Handler des
224 // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle
225 // Vorlagen existieren.
226 SdrOutliner& rOutliner = GetDrawOutliner();
227 rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
228 SetCalcFieldValueHdl( &rOutliner );
230 // set linguistic options
232 const SvtLinguConfig aLinguConfig;
233 SvtLinguOptions aOptions;
234 aLinguConfig.GetOptions( aOptions );
236 SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage,
237 ::com::sun::star::i18n::ScriptType::LATIN), EE_CHAR_LANGUAGE );
238 SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK,
239 ::com::sun::star::i18n::ScriptType::ASIAN), EE_CHAR_LANGUAGE_CJK );
240 SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL,
241 ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL );
243 mbOnlineSpell = aOptions.bIsSpellAuto;
246 LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage );
247 mpLocale = new ::com::sun::star::lang::Locale( MsLangId::convertLanguageToLocale( eRealLanguage ));
248 mpCharClass = new CharClass( *mpLocale );
250 // If the current application language is a language that uses right-to-left text...
251 LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguage();
252 if( MsLangId::isRightToLeft( eRealCTLLanguage ) )
254 // ... then we have to set this as a default
255 SetDefaultWritingMode( ::com::sun::star::text::WritingMode_RL_TB );
258 // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text
259 if( ( LANGUAGE_KOREAN == eRealCTLLanguage ) || ( LANGUAGE_KOREAN_JOHAB == eRealCTLLanguage ) || ( LANGUAGE_JAPANESE == eRealCTLLanguage ) )
261 GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( FALSE, EE_PARA_ASIANCJKSPACING ) );
264 // DefTab und SpellOptions setzen
265 //OfaMiscCfg* pOfaMiscCfg = SFX_APP()->GetMiscConfig();
266 // Jetzt am Modul (SD)
267 USHORT nDefTab = pOptions->GetDefTab();
268 SetDefaultTabulator( nDefTab );
272 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
273 if ( xSpellChecker.is() )
274 rOutliner.SetSpeller( xSpellChecker );
276 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
277 if( xHyphenator.is() )
278 rOutliner.SetHyphenator( xHyphenator );
280 SetForbiddenCharsTable( new SvxForbiddenCharactersTable( ::comphelper::getProcessServiceFactory() ) );
282 catch(...)
284 DBG_ERROR("Can't get SpellChecker");
287 rOutliner.SetDefaultLanguage( Application::GetSettings().GetLanguage() );
289 if (mpDocSh)
291 SetLinkManager( new SvxLinkManager(mpDocSh) );
294 ULONG nCntrl = rOutliner.GetControlWord();
295 nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
296 nCntrl |= EE_CNTRL_URLSFXEXECUTE;
298 if (mbOnlineSpell)
299 nCntrl |= EE_CNTRL_ONLINESPELLING;
300 else
301 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
303 nCntrl &= ~ EE_CNTRL_ULSPACESUMMATION;
304 if ( meDocType != DOCUMENT_TYPE_IMPRESS )
305 SetSummationOfParagraphs( sal_False );
306 else
308 SetSummationOfParagraphs( pOptions->IsSummationOfParagraphs() );
309 if ( pOptions->IsSummationOfParagraphs() )
310 nCntrl |= EE_CNTRL_ULSPACESUMMATION;
312 rOutliner.SetControlWord(nCntrl);
314 // Initialize the printer independent layout mode.
315 SetPrinterIndependentLayout (pOptions->GetPrinterIndependentLayout());
317 // Dem HitTestOutliner den StyleSheetPool setzen.
318 // Der Link zum StyleRequest-Handler des
319 // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle
320 // Vorlagen existieren.
321 SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() );
322 pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() );
324 SetCalcFieldValueHdl( pHitTestOutliner );
328 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
329 if ( xSpellChecker.is() )
330 pHitTestOutliner->SetSpeller( xSpellChecker );
332 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
333 if( xHyphenator.is() )
334 pHitTestOutliner->SetHyphenator( xHyphenator );
336 catch(...)
338 DBG_ERROR("Can't get SpellChecker");
341 pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
343 ULONG nCntrl2 = pHitTestOutliner->GetControlWord();
344 nCntrl2 |= EE_CNTRL_ALLOWBIGOBJS;
345 nCntrl2 |= EE_CNTRL_URLSFXEXECUTE;
346 nCntrl2 &= ~EE_CNTRL_ONLINESPELLING;
348 nCntrl2 &= ~ EE_CNTRL_ULSPACESUMMATION;
349 if ( pOptions->IsSummationOfParagraphs() )
350 nCntrl2 |= EE_CNTRL_ULSPACESUMMATION;
352 pHitTestOutliner->SetControlWord( nCntrl2 );
354 /**************************************************************************
355 * Layer anlegen
357 * Es werden auf Pages und MasterPages folgende Default-Layer angelegt:
359 * Layer STR_LAYOUT : Standardlayer f�r alle Zeichenobjekte
361 * Layer STR_BCKGRND : Hintergrund der MasterPage
362 * (auf normalen Pages z.Z. keine Verwendung)
364 * Layer STR_BCKGRNDOBJ: Objekte auf dem Hintergrund der MasterPage
365 * (auf normalen Pages z.Z. keine Verwendung)
367 * Layer STR_CONTROLS : Standardlayer f�r Controls
369 **************************************************************************/
371 String aControlLayerName( SdResId(STR_LAYER_CONTROLS) );
373 SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
374 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_LAYOUT)) );
375 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRND)) );
376 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRNDOBJ)) );
377 rLayerAdmin.NewLayer( aControlLayerName );
378 rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_MEASURELINES)) );
380 rLayerAdmin.SetControlLayerName(aControlLayerName);
386 /*************************************************************************
388 |* Destruktor
390 \************************************************************************/
392 SdDrawDocument::~SdDrawDocument()
394 Broadcast(SdrHint(HINT_MODELCLEARED));
396 if (mpWorkStartupTimer)
398 if ( mpWorkStartupTimer->IsActive() )
399 mpWorkStartupTimer->Stop();
401 delete mpWorkStartupTimer;
402 mpWorkStartupTimer = NULL;
405 StopOnlineSpelling();
406 delete mpOnlineSearchItem;
407 mpOnlineSearchItem = NULL;
409 CloseBookmarkDoc();
410 SetAllocDocSh(FALSE);
412 // #116168#
413 ClearModel(sal_True);
415 if (pLinkManager)
417 // BaseLinks freigeben
418 if ( pLinkManager->GetLinks().Count() )
420 pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() );
423 delete pLinkManager;
424 pLinkManager = NULL;
427 ::sd::FrameView* pFrameView = NULL;
429 for (ULONG i = 0; i < mpFrameViewList->Count(); i++)
431 // Ggf. FrameViews loeschen
432 pFrameView =
433 static_cast< ::sd::FrameView*>(mpFrameViewList->GetObject(i));
435 if (pFrameView)
436 delete pFrameView;
439 delete mpFrameViewList;
440 mpFrameViewList = NULL;
442 if (mpCustomShowList)
444 for (ULONG j = 0; j < mpCustomShowList->Count(); j++)
446 // Ggf. CustomShows loeschen
447 SdCustomShow* pCustomShow = (SdCustomShow*) mpCustomShowList->GetObject(j);
448 delete pCustomShow;
451 delete mpCustomShowList;
452 mpCustomShowList = NULL;
455 delete mpOutliner;
456 mpOutliner = NULL;
458 delete mpInternalOutliner;
459 mpInternalOutliner = NULL;
461 delete mpLocale;
462 mpLocale = NULL;
464 delete mpCharClass;
465 mpCharClass = NULL;
468 /*************************************************************************
470 |* Diese Methode erzeugt ein neues Dokument (SdDrawDocument) und gibt einen
471 |* Zeiger darauf zurueck. Die Drawing Engine benutzt diese Methode um das
472 |* Dokument oder Teile davon ins Clipboard/DragServer stellen zu koennen.
474 \************************************************************************/
476 SdrModel* SdDrawDocument::AllocModel() const
478 SdDrawDocument* pNewModel = NULL;
480 if( mpCreatingTransferable )
482 // Dokument wird fuer Drag&Drop/Clipboard erzeugt, dafuer muss dem Dokument eine DocShell (SvPersist) bekannt sein
483 SfxObjectShell* pObj = NULL;
484 ::sd::DrawDocShell* pNewDocSh = NULL;
486 if( meDocType == DOCUMENT_TYPE_IMPRESS )
487 mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell(
488 SFX_CREATE_MODE_EMBEDDED, TRUE, meDocType ) );
489 else
490 mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell(
491 SFX_CREATE_MODE_EMBEDDED, TRUE, meDocType ) );
493 pNewDocSh = static_cast< ::sd::DrawDocShell*>( pObj = mpCreatingTransferable->GetDocShell() );
494 pNewDocSh->DoInitNew( NULL );
495 pNewModel = pNewDocSh->GetDoc();
497 // Nur fuer Clipboard notwendig,
498 // fuer Drag&Drop erfolgt dieses im DragServer
499 SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
500 SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pNewModel->GetStyleSheetPool();
502 pNewStylePool->CopyGraphicSheets(*pOldStylePool);
503 pNewStylePool->CopyCellSheets(*pOldStylePool);
504 pNewStylePool->CopyTableStyles(*pOldStylePool);
507 for (USHORT i = 0; i < GetMasterSdPageCount(PK_STANDARD); i++)
509 // Alle Layouts der MasterPage mitnehmen
510 String aOldLayoutName(((SdDrawDocument*) this)->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName());
511 aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
512 SdStyleSheetVector aCreatedSheets;
513 pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets );
516 pNewModel->NewOrLoadCompleted( DOC_LOADED ); // loaded from source document
518 else if( mbAllocDocSh )
520 // Es wird eine DocShell erzeugt, welche mit GetAllocedDocSh() zurueckgegeben wird
521 SdDrawDocument* pDoc = (SdDrawDocument*) this;
522 pDoc->SetAllocDocSh(FALSE);
523 pDoc->mxAllocedDocShRef = new ::sd::DrawDocShell(
524 SFX_CREATE_MODE_EMBEDDED, TRUE, meDocType);
525 pDoc->mxAllocedDocShRef->DoInitNew(NULL);
526 pNewModel = pDoc->mxAllocedDocShRef->GetDoc();
528 else
530 pNewModel = new SdDrawDocument(meDocType, NULL);
533 return pNewModel;
536 /*************************************************************************
538 |* Diese Methode erzeugt eine neue Seite (SdPage) und gibt einen Zeiger
539 |* darauf zurueck. Die Drawing Engine benutzt diese Methode beim Laden
540 |* zur Erzeugung von Seiten (deren Typ sie ja nicht kennt, da es ABLEITUNGEN
541 |* der SdrPage sind).
543 \************************************************************************/
545 SdrPage* SdDrawDocument::AllocPage(FASTBOOL bMasterPage)
547 return new SdPage(*this, NULL, (BOOL)bMasterPage);
550 /*************************************************************************
552 |* SetChanged(), das Model wurde geaendert
554 \************************************************************************/
556 void SdDrawDocument::SetChanged(sal_Bool bFlag)
558 if (mpDocSh)
560 if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified())
562 // weitergeben an Basisklasse
563 FmFormModel::SetChanged(bFlag);
565 // an ObjectShell weiterleiten
566 mpDocSh->SetModified(bFlag);
569 else
571 // weitergeben an Basisklasse
572 FmFormModel::SetChanged(bFlag);
576 /*************************************************************************
578 |* NbcSetChanged(), the model changed, don't call anybody else
580 \************************************************************************/
582 void SdDrawDocument::NbcSetChanged(sal_Bool bFlag)
584 // #100237# forward to baseclass
585 FmFormModel::SetChanged(bFlag);
588 /*************************************************************************
590 |* NewOrLoadCompleted
592 |* Wird gerufen, wenn das Dokument geladen wurde bzw. feststeht, dass es
593 |* nicht mehr geladen wird.
595 \************************************************************************/
597 void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode)
599 if (eMode == NEW_DOC)
601 // Neues Dokument:
602 // Praesentations- und Standardvorlagen erzeugen,
603 // Pool fuer virtuelle Controls erzeugen
604 CreateLayoutTemplates();
605 CreateDefaultCellStyles();
607 static_cast< SdStyleSheetPool* >( mxStyleSheetPool.get() )->CreatePseudosIfNecessary();
609 else if (eMode == DOC_LOADED)
611 // Dokument wurde geladen:
613 CheckMasterPages();
615 if ( GetMasterSdPageCount(PK_STANDARD) > 1 )
616 RemoveUnnecessaryMasterPages( NULL, TRUE, FALSE );
618 for ( USHORT i = 0; i < GetPageCount(); i++ )
620 // Check for correct layout names
621 SdPage* pPage = (SdPage*) GetPage( i );
623 if(pPage->TRG_HasMasterPage())
625 SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage();
627 if(rMaster.GetLayoutName() != pPage->GetLayoutName())
629 pPage->SetLayoutName(rMaster.GetLayoutName());
634 for ( USHORT nPage = 0; nPage < GetMasterPageCount(); nPage++)
636 // LayoutName and PageName must be the same
637 SdPage* pPage = (SdPage*) GetMasterPage( nPage );
639 String aName( pPage->GetLayoutName() );
640 aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ) );
642 if( aName != pPage->GetName() )
643 pPage->SetName( aName );
645 SdrObject* pPresObj = pPage->GetPresObj( PRESOBJ_BACKGROUND ) ;
647 if( pPage->GetPageKind() == PK_STANDARD )
649 DBG_ASSERT( pPresObj, "Masterpage without a background object!" );
650 if (pPresObj && pPresObj->GetOrdNum() != 0 )
651 pPage->NbcSetObjectOrdNum(pPresObj->GetOrdNum(),0);
653 else
655 DBG_ASSERT( pPresObj == NULL, "Non Standard Masterpage with a background object!\n(This assertion is ok for old binary files)" );
656 if( pPresObj )
658 pPage->RemoveObject( pPresObj->GetOrdNum() );
659 pPage->RemovePresObj(pPresObj);
660 SdrObject::Free( pPresObj );
665 // Sprachabhaengige Namen der StandardLayer erzeugen
666 RestoreLayerNames();
668 // Sprachabhaengige Namen der Vorlagen setzen
669 static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames();
671 // Ggf. fehlende Vorlagen erzeugen (es gab z.B. frueher keinen Subtitle)
672 static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary();
675 // Standardvorlage an der Drawing Engine setzen
676 String aName( SdResId(STR_STANDARD_STYLESHEET_NAME));
677 SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_GRAPHICS)));
679 // Draw-Outliner und Dokument Outliner initialisieren,
680 // aber nicht den globalen Outliner, den der ist ja nicht
681 // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler
682 ::Outliner& rDrawOutliner = GetDrawOutliner();
683 rDrawOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
684 ULONG nCntrl = rDrawOutliner.GetControlWord();
685 if (mbOnlineSpell)
686 nCntrl |= EE_CNTRL_ONLINESPELLING;
687 else
688 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
689 rDrawOutliner.SetControlWord(nCntrl);
691 // HitTest-Outliner und Dokument Outliner initialisieren,
692 // aber nicht den globalen Outliner, den der ist ja nicht
693 // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler
694 pHitTestOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
696 if(mpOutliner)
698 mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
700 if(mpInternalOutliner)
702 mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
705 if ( eMode == DOC_LOADED )
707 // Praesentationsobjekte muessen wieder Listener der entsprechenden
708 // Vorlagen werden
709 SdStyleSheetPool* pSPool = (SdStyleSheetPool*) GetStyleSheetPool();
710 USHORT nPage, nPageCount;
712 // #96323# create missing layout style sheets for broken documents
713 // that where created with the 5.2
714 nPageCount = GetMasterSdPageCount( PK_STANDARD );
715 for (nPage = 0; nPage < nPageCount; nPage++)
717 SdPage* pPage = GetMasterSdPage(nPage, PK_STANDARD);
718 pSPool->CreateLayoutStyleSheets( pPage->GetName(), sal_True );
721 // Standard- und Notizseiten:
722 for (nPage = 0; nPage < GetPageCount(); nPage++)
724 SdPage* pPage = (SdPage*)GetPage(nPage);
725 NewOrLoadCompleted( pPage, pSPool );
728 // Masterpages:
729 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
731 SdPage* pPage = (SdPage*)GetMasterPage(nPage);
733 NewOrLoadCompleted( pPage, pSPool );
735 // BackgroundObjekt vor Selektion schuetzen #62144#
736 SdrObject* pBackObj = pPage->GetPresObj(PRESOBJ_BACKGROUND);
737 if(pBackObj)
738 pBackObj->SetMarkProtect(TRUE);
742 mbNewOrLoadCompleted = TRUE;
744 /**************************************************************************
745 * Alle gelinkten Pages aktualisieren
746 **************************************************************************/
747 SdPage* pPage = NULL;
748 USHORT nMaxSdPages = GetSdPageCount(PK_STANDARD);
750 for (USHORT nSdPage=0; nSdPage < nMaxSdPages; nSdPage++)
752 pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD);
754 if (pPage && pPage->GetFileName().Len() && pPage->GetBookmarkName().Len())
756 pPage->SetModel(this);
760 UpdateAllLinks();
762 SetChanged( FALSE );
765 /** updates all links, only links in this document should by resolved */
766 void SdDrawDocument::UpdateAllLinks()
768 if ( !pDocLockedInsertingLinks && pLinkManager && pLinkManager->GetLinks().Count() )
770 pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved
772 pLinkManager->UpdateAllLinks(); // query box: update all links?
774 if( pDocLockedInsertingLinks == this )
775 pDocLockedInsertingLinks = NULL; // unlock inserting links
779 /** this loops over the presentation objectes of a page and repairs some new settings
780 from old binary files and resets all default strings for empty presentation objects.
782 void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool )
784 /* cl removed because not needed anymore since binfilter
785 SdrObjListIter aShapeIter( *pPage );
786 while( aShapeIter.IsMore() )
788 OutlinerParaObject* pOPO = aShapeIter.Next()->GetOutlinerParaObject();
789 if( pOPO )
791 if( pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
792 pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT );
794 pOPO->FinishLoad( pSPool );
799 const sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() );
800 if(!rPresentationShapes.isEmpty())
802 // Listen mit Titel- und Gliederungsvorlagen erstellen
803 String aName = pPage->GetLayoutName();
804 aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ));
806 List* pOutlineList = pSPool->CreateOutlineSheetList(aName);
807 SfxStyleSheet* pTitleSheet = (SfxStyleSheet*)
808 pSPool->GetTitleSheet(aName);
810 SdrObject* pObj = rPresentationShapes.getNextShape(0);
812 // jetzt nach Titel- und Gliederungstextobjekten suchen und
813 // Objekte zu Listenern machen
814 while(pObj)
816 if (pObj->GetObjInventor() == SdrInventor)
818 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
819 UINT16 nId = pObj->GetObjIdentifier();
821 if (nId == OBJ_TITLETEXT)
823 if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
824 pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT );
826 // TRUE: harte Attribute dabei nicht loeschen
827 if (pTitleSheet)
828 pObj->SetStyleSheet(pTitleSheet, TRUE);
830 else if (nId == OBJ_OUTLINETEXT)
832 if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
833 pOPO->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
835 for (USHORT nSheet = 0; nSheet < 10; nSheet++)
837 SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineList->GetObject(nSheet);
838 if (pSheet)
840 pObj->StartListening(*pSheet);
842 if( nSheet == 0)
843 // Textrahmen hoert auf StyleSheet der Ebene1
844 pObj->NbcSetStyleSheet(pSheet, TRUE);
849 if (pObj->ISA(SdrTextObj) && pObj->IsEmptyPresObj() && pPage)
851 PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj);
852 String aString( pPage->GetPresObjText(ePresObjKind) );
854 if (aString.Len())
856 sd::Outliner* pInternalOutl = GetInternalOutliner(TRUE);
857 pPage->SetObjText( (SdrTextObj*) pObj, pInternalOutl, ePresObjKind, aString );
858 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), TRUE );
859 pInternalOutl->Clear();
864 pObj = rPresentationShapes.getNextShape(pObj);
867 delete pOutlineList;
871 /*************************************************************************
873 |* Lokaler Outliner, welcher fuer den Gliederungsmodus verwendet wird
874 |* In diesen Outliner werden ggf. OutlinerViews inserted!
876 \************************************************************************/
878 ::sd::Outliner* SdDrawDocument::GetOutliner(BOOL bCreateOutliner)
880 if (!mpOutliner && bCreateOutliner)
882 mpOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
884 if (mpDocSh)
885 mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
887 mpOutliner->SetDefTab( nDefaultTabulator );
888 mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
891 return(mpOutliner);
895 /*************************************************************************
897 |* Interner Outliner, welcher fuer die Erzeugung von Textobjekten
898 |* verwendet wird.
899 |* In diesen Outliner werden keine OutlinerViews inserted!
901 \************************************************************************/
903 ::sd::Outliner* SdDrawDocument::GetInternalOutliner(BOOL bCreateOutliner)
905 if ( !mpInternalOutliner && bCreateOutliner )
907 mpInternalOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
908 // MT:
909 // Dieser Outliner wird nur fuer das Erzeugen spezieller Textobjekte
910 // verwendet. Da in diesen Textobjekten keine Portion-Informationen
911 // gespeichert werden muessen, kann/soll der Update-Mode immer FALSE bleiben.
912 mpInternalOutliner->SetUpdateMode( FALSE );
913 mpInternalOutliner->EnableUndo( FALSE );
915 if (mpDocSh)
916 mpInternalOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
918 mpInternalOutliner->SetDefTab( nDefaultTabulator );
919 mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
922 DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->GetUpdateMode() == FALSE ) , "InternalOutliner: UpdateMode = TRUE !" );
923 DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->IsUndoEnabled() == FALSE ), "InternalOutliner: Undo = TRUE !" );
925 // MT: Wer ihn vollmuellt, macht ihn auch gleich wieder leer:
926 // Vorteile:
927 // a) Keine unnoetigen Clear-Aufrufe
928 // b) Kein Muell im Speicher.
929 DBG_ASSERT( !mpInternalOutliner || ( ( mpInternalOutliner->GetParagraphCount() == 1 ) && ( mpInternalOutliner->GetText( mpInternalOutliner->GetParagraph( 0 ) ).Len() == 0 ) ), "InternalOutliner: Nicht leer!" );
931 return mpInternalOutliner;
934 /*************************************************************************
936 |* OnlineSpelling ein/aus
938 \************************************************************************/
940 void SdDrawDocument::SetOnlineSpell(BOOL bIn)
942 mbOnlineSpell = bIn;
943 ULONG nCntrl = 0;
945 if(mpOutliner)
947 nCntrl = mpOutliner->GetControlWord();
949 if(mbOnlineSpell)
950 nCntrl |= EE_CNTRL_ONLINESPELLING;
951 else
952 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
954 mpOutliner->SetControlWord(nCntrl);
957 if (mpInternalOutliner)
959 nCntrl = mpInternalOutliner->GetControlWord();
961 if (mbOnlineSpell)
962 nCntrl |= EE_CNTRL_ONLINESPELLING;
963 else
964 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
966 mpInternalOutliner->SetControlWord(nCntrl);
969 ::Outliner& rOutliner = GetDrawOutliner();
971 nCntrl = rOutliner.GetControlWord();
973 if (mbOnlineSpell)
974 nCntrl |= EE_CNTRL_ONLINESPELLING;
975 else
976 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
978 rOutliner.SetControlWord(nCntrl);
980 if (mbOnlineSpell)
982 StartOnlineSpelling();
984 else
986 StopOnlineSpelling();
991 /*************************************************************************
993 |* OnlineSpelling: Markierung ein/aus
995 \************************************************************************/
997 uno::Reference< uno::XInterface > SdDrawDocument::createUnoModel()
999 uno::Reference< uno::XInterface > xModel;
1003 if ( mpDocSh )
1004 xModel = mpDocSh->GetModel();
1006 catch( uno::RuntimeException& )
1010 return xModel;
1013 SvxNumType SdDrawDocument::GetPageNumType() const
1015 return mePageNumType;
1021 void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode)
1023 // #108104#
1024 // DBG_ASSERT (mpDocSh!=NULL, "No available document shell to set ref device at.");
1026 switch (nMode)
1028 case ::com::sun::star::document::PrinterIndependentLayout::DISABLED:
1029 case ::com::sun::star::document::PrinterIndependentLayout::ENABLED:
1030 // Just store supported modes and inform the doc shell.
1031 mnPrinterIndependentLayout = nMode;
1033 // #108104#
1034 // Since it is possible that a SdDrawDocument is constructed without a
1035 // SdDrawDocShell the pointer member mpDocSh needs to be tested
1036 // before the call is executed. This is e.-g. used for copy/paste.
1037 if(mpDocSh)
1039 mpDocSh->UpdateRefDevice ();
1042 break;
1044 default:
1045 // Ignore unknown values.
1046 break;
1050 sal_Int32 SdDrawDocument::GetPrinterIndependentLayout (void)
1052 return mnPrinterIndependentLayout;
1055 bool SdDrawDocument::IsStartWithPresentation() const
1057 return mbStartWithPresentation;
1060 void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation )
1062 mbStartWithPresentation = bStartWithPresentation;
1065 // #109538#
1066 void SdDrawDocument::PageListChanged()
1068 mpDrawPageListWatcher->Invalidate();
1071 // #109538#
1072 void SdDrawDocument::MasterPageListChanged()
1074 mpMasterPageListWatcher->Invalidate();
1077 void SdDrawDocument::SetCalcFieldValueHdl(::Outliner* pOutliner)
1079 pOutliner->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
1082 sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const rtl::OUString& rAuthor )
1084 // force current user to have first color
1085 if( maAnnotationAuthors.empty() )
1087 SvtUserOptions aUserOptions;
1088 maAnnotationAuthors.push_back( aUserOptions.GetFullName() );
1091 sal_uInt16 idx = 0;
1092 for( std::vector< OUString >::iterator iter( maAnnotationAuthors.begin() ); iter != maAnnotationAuthors.end(); iter++ )
1094 if( (*iter) == rAuthor )
1096 break;
1098 idx++;
1101 if( idx == maAnnotationAuthors.size() )
1103 maAnnotationAuthors.push_back( rAuthor );
1106 return idx;
1109 // eof