xref: /trunk/main/sd/source/core/drawdoc.cxx (revision 1b9d1397d93e567a9042ac64832efcc85d3fed81)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PageListWatcher.hxx"
28cdf0e10cSrcweir #include <com/sun/star/text/WritingMode.hpp>
29cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp>
30cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp>
31cdf0e10cSrcweir #include <editeng/forbiddencharacterstable.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <svx/svxids.hrc>
34cdf0e10cSrcweir #include <svl/srchitem.hxx>
35cdf0e10cSrcweir #include <editeng/eeitem.hxx>
36cdf0e10cSrcweir #include <editeng/scriptspaceitem.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <unotools/useroptions.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <sfx2/printer.hxx>
41cdf0e10cSrcweir #include <sfx2/app.hxx>
42cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
43cdf0e10cSrcweir #include <svx/dialogs.hrc>
44cdf0e10cSrcweir #include "Outliner.hxx"
45cdf0e10cSrcweir #include "app.hxx"
46cdf0e10cSrcweir #include <editeng/eeitem.hxx>
47cdf0e10cSrcweir #include <editeng/editstat.hxx>
48cdf0e10cSrcweir #include <editeng/fontitem.hxx>
49cdf0e10cSrcweir #include <svl/flagitem.hxx>
50cdf0e10cSrcweir #include <svx/svdoattr.hxx>
51cdf0e10cSrcweir #include <svx/svdotext.hxx>
52cdf0e10cSrcweir #include <editeng/bulitem.hxx>
53cdf0e10cSrcweir #include <editeng/numitem.hxx>
54cdf0e10cSrcweir #include <svx/svditer.hxx>
55cdf0e10cSrcweir #include <editeng/unolingu.hxx>
56cdf0e10cSrcweir #include <svl/itempool.hxx>
57cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
58cdf0e10cSrcweir #include <svx/xtable.hxx>
59cdf0e10cSrcweir #include <com/sun/star/linguistic2/XHyphenator.hpp>
60cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
61cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
62cdf0e10cSrcweir #include <editeng/outlobj.hxx>
63cdf0e10cSrcweir #include <unotools/saveopt.hxx>
64cdf0e10cSrcweir #include <comphelper/extract.hxx>
65cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
66cdf0e10cSrcweir #include <unotools/charclass.hxx>
67cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
68cdf0e10cSrcweir #ifndef _SVTOOLS_PATHOPTIONS_HXX_
69cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir #include <unotools/lingucfg.hxx>
72cdf0e10cSrcweir #include <unotools/linguprops.hxx>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #include "eetext.hxx"
75cdf0e10cSrcweir #include "drawdoc.hxx"
76cdf0e10cSrcweir #include "sdpage.hxx"
77cdf0e10cSrcweir #include "pglink.hxx"
78cdf0e10cSrcweir #include "sdattr.hxx"
79cdf0e10cSrcweir #include "glob.hrc"
80cdf0e10cSrcweir #include "glob.hxx"
81cdf0e10cSrcweir #include "stlpool.hxx"
82cdf0e10cSrcweir #include "sdiocmpt.hxx"
83cdf0e10cSrcweir #include "sdresid.hxx"
84cdf0e10cSrcweir #include "cusshow.hxx"
85cdf0e10cSrcweir #include "../ui/inc/DrawDocShell.hxx"
86cdf0e10cSrcweir #include "../ui/inc/GraphicDocShell.hxx"
87cdf0e10cSrcweir #include "../ui/inc/sdxfer.hxx"
88cdf0e10cSrcweir #include "../ui/inc/ViewShell.hxx"
89cdf0e10cSrcweir #include "../ui/inc/optsitem.hxx"
90cdf0e10cSrcweir #include "../ui/inc/FrameView.hxx"
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // #90477#
93cdf0e10cSrcweir #include <tools/tenccvt.hxx>
94cdf0e10cSrcweir 
95cdf0e10cSrcweir using ::rtl::OUString;
96cdf0e10cSrcweir using namespace ::sd;
97cdf0e10cSrcweir using namespace ::com::sun::star;
98cdf0e10cSrcweir using namespace ::com::sun::star::uno;
99cdf0e10cSrcweir using namespace ::com::sun::star::lang;
100cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
103cdf0e10cSrcweir 
104cdf0e10cSrcweir TYPEINIT1( SdDrawDocument, FmFormModel );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir SdDrawDocument* SdDrawDocument::pDocLockedInsertingLinks = NULL;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
109cdf0e10cSrcweir 
110cdf0e10cSrcweir PresentationSettings::PresentationSettings()
111cdf0e10cSrcweir :   mbAll( true ),
112cdf0e10cSrcweir     mbEndless( false ),
113cdf0e10cSrcweir     mbCustomShow(false),
114cdf0e10cSrcweir     mbManual( false ),
115cdf0e10cSrcweir     mbMouseVisible( false ),
116cdf0e10cSrcweir     mbMouseAsPen( false ),
117cdf0e10cSrcweir     mbLockedPages( false ),
118cdf0e10cSrcweir     mbAlwaysOnTop( false ),
119cdf0e10cSrcweir     mbFullScreen( true ),
120cdf0e10cSrcweir     mbAnimationAllowed( true ),
121cdf0e10cSrcweir     mnPauseTimeout( 10 ),
122cdf0e10cSrcweir     mbShowPauseLogo( false ),
123cdf0e10cSrcweir     mbStartWithNavigator(false)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir // ---------------------------------------------------------------------------
128cdf0e10cSrcweir 
129cdf0e10cSrcweir PresentationSettings::PresentationSettings( const PresentationSettings& r )
130cdf0e10cSrcweir :   maPresPage( r.maPresPage ),
131cdf0e10cSrcweir     mbAll( r.mbAll ),
132cdf0e10cSrcweir     mbEndless( r.mbEndless ),
133cdf0e10cSrcweir     mbCustomShow( r.mbCustomShow ),
134cdf0e10cSrcweir     mbManual( r.mbManual ),
135cdf0e10cSrcweir     mbMouseVisible( r.mbMouseVisible ),
136cdf0e10cSrcweir     mbMouseAsPen( r.mbMouseAsPen ),
137cdf0e10cSrcweir     mbLockedPages( r.mbLockedPages ),
138cdf0e10cSrcweir     mbAlwaysOnTop( r.mbAlwaysOnTop ),
139cdf0e10cSrcweir     mbFullScreen( r.mbFullScreen ),
140cdf0e10cSrcweir     mbAnimationAllowed( r.mbAnimationAllowed ),
141cdf0e10cSrcweir     mnPauseTimeout( r.mnPauseTimeout ),
142cdf0e10cSrcweir     mbShowPauseLogo( r.mbShowPauseLogo ),
143cdf0e10cSrcweir     mbStartWithNavigator( r.mbStartWithNavigator )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir // ---------------------------------------------------------------------------
148cdf0e10cSrcweir 
149cdf0e10cSrcweir SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
150cdf0e10cSrcweir : FmFormModel( SvtPathOptions().GetPalettePath(), NULL, pDrDocSh )
1510deba7fbSSteve Yin , bReadOnly(sal_False)
152cdf0e10cSrcweir , mpOutliner(NULL)
153cdf0e10cSrcweir , mpInternalOutliner(NULL)
154cdf0e10cSrcweir , mpWorkStartupTimer(NULL)
155cdf0e10cSrcweir , mpOnlineSpellingTimer(NULL)
156cdf0e10cSrcweir , mpOnlineSpellingList(NULL)
157cdf0e10cSrcweir , mpOnlineSearchItem(NULL)
158cdf0e10cSrcweir , mpFrameViewList( new List() )
159cdf0e10cSrcweir , mpCustomShowList(NULL)
160cdf0e10cSrcweir , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh))
161cdf0e10cSrcweir , mpCreatingTransferable( NULL )
162cdf0e10cSrcweir , mbHasOnlineSpellErrors(sal_False)
163cdf0e10cSrcweir , mbInitialOnlineSpellingEnabled(sal_True)
164cdf0e10cSrcweir , mbNewOrLoadCompleted(sal_False)
165cdf0e10cSrcweir , mbStartWithPresentation( false )
166cdf0e10cSrcweir , meLanguage( LANGUAGE_SYSTEM )
167cdf0e10cSrcweir , meLanguageCJK( LANGUAGE_SYSTEM )
168cdf0e10cSrcweir , meLanguageCTL( LANGUAGE_SYSTEM )
169cdf0e10cSrcweir , mePageNumType(SVX_ARABIC)
170cdf0e10cSrcweir , mbAllocDocSh(sal_False)
171cdf0e10cSrcweir , meDocType(eType)
172cdf0e10cSrcweir , mpCharClass(NULL)
173cdf0e10cSrcweir , mpLocale(NULL)
174cdf0e10cSrcweir , mpDrawPageListWatcher(0)
175cdf0e10cSrcweir , mpMasterPageListWatcher(0)
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     // #109538#
178cdf0e10cSrcweir     mpDrawPageListWatcher = ::std::auto_ptr<ImpDrawPageListWatcher>(
179cdf0e10cSrcweir         new ImpDrawPageListWatcher(*this));
180cdf0e10cSrcweir     mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>(
181cdf0e10cSrcweir         new ImpMasterPageListWatcher(*this));
182cdf0e10cSrcweir 
183ee62af74Smarcus     SetObjectShell(pDrDocSh);       // for the VCDrawModel
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     if (mpDocSh)
186cdf0e10cSrcweir     {
187cdf0e10cSrcweir         SetSwapGraphics(sal_True);
188cdf0e10cSrcweir     }
189cdf0e10cSrcweir 
190ee62af74Smarcus     // set measurement unit (of App) and scale (of SdMod)
191cdf0e10cSrcweir     sal_Int32 nX, nY;
192cdf0e10cSrcweir     SdOptions* pOptions = SD_MOD()->GetSdOptions(meDocType);
193cdf0e10cSrcweir     pOptions->GetScale( nX, nY );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     // #92067# Allow UI scale only for draw documents.
196cdf0e10cSrcweir     if( eType == DOCUMENT_TYPE_DRAW )
197cdf0e10cSrcweir         SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) );  // user-defined
198cdf0e10cSrcweir     else
199cdf0e10cSrcweir         SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) );    // default
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     SetScaleUnit(MAP_100TH_MM);
202cdf0e10cSrcweir     SetScaleFraction(Fraction(1, 1));
203cdf0e10cSrcweir     SetDefaultFontHeight(847);     // 24p
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
206cdf0e10cSrcweir     pItemPool->FreezeIdRanges();
207cdf0e10cSrcweir     SetTextDefaults();
208cdf0e10cSrcweir 
209ee62af74Smarcus     // also the DrawingEngine needs to know where it is
210cdf0e10cSrcweir     FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) );
211cdf0e10cSrcweir 
212ee62af74Smarcus     // Set the StyleSheetPool to the DrawOutliner, in order to read text objects
213ee62af74Smarcus     // correctly. The link to the StyleRequest handler of the document will be
214ee62af74Smarcus     // set first in NewOrLoadCompleted, because only then all templates exist.
215cdf0e10cSrcweir     SdrOutliner& rOutliner = GetDrawOutliner();
216cdf0e10cSrcweir     rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
217cdf0e10cSrcweir     SetCalcFieldValueHdl( &rOutliner );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     // set linguistic options
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         const SvtLinguConfig    aLinguConfig;
222cdf0e10cSrcweir         SvtLinguOptions         aOptions;
223cdf0e10cSrcweir         aLinguConfig.GetOptions( aOptions );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir         SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage,
226cdf0e10cSrcweir             ::com::sun::star::i18n::ScriptType::LATIN), EE_CHAR_LANGUAGE );
227cdf0e10cSrcweir         SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK,
228cdf0e10cSrcweir             ::com::sun::star::i18n::ScriptType::ASIAN), EE_CHAR_LANGUAGE_CJK );
229cdf0e10cSrcweir         SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL,
230cdf0e10cSrcweir             ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL );
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         mbOnlineSpell = aOptions.bIsSpellAuto;
233cdf0e10cSrcweir     }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage );
236cdf0e10cSrcweir     mpLocale = new ::com::sun::star::lang::Locale( MsLangId::convertLanguageToLocale( eRealLanguage ));
237cdf0e10cSrcweir     mpCharClass = new CharClass( *mpLocale );
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     // If the current application language is a language that uses right-to-left text...
240cdf0e10cSrcweir     LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguage();
241cdf0e10cSrcweir     if( MsLangId::isRightToLeft( eRealCTLLanguage ) )
242cdf0e10cSrcweir     {
243cdf0e10cSrcweir         // ... then we have to set this as a default
244cdf0e10cSrcweir         SetDefaultWritingMode( ::com::sun::star::text::WritingMode_RL_TB );
245cdf0e10cSrcweir     }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir     // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text
248cdf0e10cSrcweir     if( ( LANGUAGE_KOREAN  == eRealCTLLanguage ) || ( LANGUAGE_KOREAN_JOHAB == eRealCTLLanguage ) || ( LANGUAGE_JAPANESE == eRealCTLLanguage ) )
249cdf0e10cSrcweir     {
250cdf0e10cSrcweir         GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) );
251cdf0e10cSrcweir     }
252cdf0e10cSrcweir 
253ee62af74Smarcus     // set DefTab and SpellOptions
254ee62af74Smarcus     // now at the module (SD)
255cdf0e10cSrcweir     sal_uInt16 nDefTab = pOptions->GetDefTab();
256cdf0e10cSrcweir     SetDefaultTabulator( nDefTab );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     try
259cdf0e10cSrcweir     {
260cdf0e10cSrcweir         Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
261cdf0e10cSrcweir         if ( xSpellChecker.is() )
262cdf0e10cSrcweir             rOutliner.SetSpeller( xSpellChecker );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir         Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
265cdf0e10cSrcweir         if( xHyphenator.is() )
266cdf0e10cSrcweir             rOutliner.SetHyphenator( xHyphenator );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir         SetForbiddenCharsTable( new SvxForbiddenCharactersTable( ::comphelper::getProcessServiceFactory() ) );
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir     catch(...)
271cdf0e10cSrcweir     {
272cdf0e10cSrcweir         DBG_ERROR("Can't get SpellChecker");
273cdf0e10cSrcweir     }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir     rOutliner.SetDefaultLanguage( Application::GetSettings().GetLanguage() );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     if (mpDocSh)
278cdf0e10cSrcweir     {
279*1b9d1397SArrigo Marchiori         sfx2::LinkManager *linkMgr = new sfx2::LinkManager(mpDocSh);
280*1b9d1397SArrigo Marchiori         linkMgr->SetAutoAskUpdateAllLinks();
281*1b9d1397SArrigo Marchiori         SetLinkManager( linkMgr );
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     sal_uLong nCntrl = rOutliner.GetControlWord();
285cdf0e10cSrcweir     nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
286cdf0e10cSrcweir     nCntrl |= EE_CNTRL_URLSFXEXECUTE;
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     if (mbOnlineSpell)
289cdf0e10cSrcweir         nCntrl |= EE_CNTRL_ONLINESPELLING;
290cdf0e10cSrcweir     else
291cdf0e10cSrcweir         nCntrl &= ~EE_CNTRL_ONLINESPELLING;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     nCntrl &= ~ EE_CNTRL_ULSPACESUMMATION;
294cdf0e10cSrcweir     if ( meDocType != DOCUMENT_TYPE_IMPRESS )
295cdf0e10cSrcweir         SetSummationOfParagraphs( sal_False );
296cdf0e10cSrcweir     else
297cdf0e10cSrcweir     {
298cdf0e10cSrcweir         SetSummationOfParagraphs( pOptions->IsSummationOfParagraphs() );
299cdf0e10cSrcweir         if ( pOptions->IsSummationOfParagraphs() )
300cdf0e10cSrcweir             nCntrl |= EE_CNTRL_ULSPACESUMMATION;
301cdf0e10cSrcweir     }
302cdf0e10cSrcweir     rOutliner.SetControlWord(nCntrl);
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     // Initialize the printer independent layout mode.
305cdf0e10cSrcweir     SetPrinterIndependentLayout (pOptions->GetPrinterIndependentLayout());
306cdf0e10cSrcweir 
307ee62af74Smarcus     // Set the StyleSheetPool to the HitTestOutliner.
308ee62af74Smarcus     // The link to the StyleRequest handler of the document will be set
309ee62af74Smarcus     // first in NewOrLoadCompleted, because only then all templates exist.
310cdf0e10cSrcweir     SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() );
311cdf0e10cSrcweir     pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() );
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     SetCalcFieldValueHdl( pHitTestOutliner );
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     try
316cdf0e10cSrcweir     {
317cdf0e10cSrcweir         Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
318cdf0e10cSrcweir         if ( xSpellChecker.is() )
319cdf0e10cSrcweir             pHitTestOutliner->SetSpeller( xSpellChecker );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir         Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
322cdf0e10cSrcweir         if( xHyphenator.is() )
323cdf0e10cSrcweir             pHitTestOutliner->SetHyphenator( xHyphenator );
324cdf0e10cSrcweir     }
325cdf0e10cSrcweir     catch(...)
326cdf0e10cSrcweir     {
327cdf0e10cSrcweir         DBG_ERROR("Can't get SpellChecker");
328cdf0e10cSrcweir     }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     sal_uLong nCntrl2 = pHitTestOutliner->GetControlWord();
333cdf0e10cSrcweir     nCntrl2 |= EE_CNTRL_ALLOWBIGOBJS;
334cdf0e10cSrcweir     nCntrl2 |= EE_CNTRL_URLSFXEXECUTE;
335cdf0e10cSrcweir     nCntrl2 &= ~EE_CNTRL_ONLINESPELLING;
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     nCntrl2 &= ~ EE_CNTRL_ULSPACESUMMATION;
338cdf0e10cSrcweir     if ( pOptions->IsSummationOfParagraphs() )
339cdf0e10cSrcweir         nCntrl2 |= EE_CNTRL_ULSPACESUMMATION;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     pHitTestOutliner->SetControlWord( nCntrl2 );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir     /**************************************************************************
344ee62af74Smarcus     * Create layer
345cdf0e10cSrcweir     *
346ee62af74Smarcus     * The following default layer will created on Pages and MasterPages:
347cdf0e10cSrcweir     *
348ee62af74Smarcus     * Layer STR_LAYOUT  : Default layer for all drawing objects
349cdf0e10cSrcweir     *
350ee62af74Smarcus     * Layer STR_BCKGRND : Background of the MasterPage
351ee62af74Smarcus     *             (it's currently not used on normal Pages)
352cdf0e10cSrcweir     *
353ee62af74Smarcus     * Layer STR_BCKGRNDOBJ  : Objects on the background of the MasterPage
354ee62af74Smarcus     *             (it's currently not used on normal Pages)
355cdf0e10cSrcweir     *
356ee62af74Smarcus     * Layer STR_CONTROLS    : Default layer for Controls
357cdf0e10cSrcweir     *
358cdf0e10cSrcweir     **************************************************************************/
359cdf0e10cSrcweir     {
360cdf0e10cSrcweir         String aControlLayerName( SdResId(STR_LAYER_CONTROLS) );
361cdf0e10cSrcweir 
362cdf0e10cSrcweir         SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
363cdf0e10cSrcweir         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_LAYOUT)) );
364cdf0e10cSrcweir         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRND)) );
365cdf0e10cSrcweir         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRNDOBJ)) );
366cdf0e10cSrcweir         rLayerAdmin.NewLayer( aControlLayerName );
367cdf0e10cSrcweir         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_MEASURELINES)) );
368cdf0e10cSrcweir 
369cdf0e10cSrcweir         rLayerAdmin.SetControlLayerName(aControlLayerName);
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir /*************************************************************************
376cdf0e10cSrcweir |*
377ee62af74Smarcus |* Destructor
378cdf0e10cSrcweir |*
379cdf0e10cSrcweir \************************************************************************/
380cdf0e10cSrcweir 
381cdf0e10cSrcweir SdDrawDocument::~SdDrawDocument()
382cdf0e10cSrcweir {
383cdf0e10cSrcweir     Broadcast(SdrHint(HINT_MODELCLEARED));
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     if (mpWorkStartupTimer)
386cdf0e10cSrcweir     {
387cdf0e10cSrcweir         if ( mpWorkStartupTimer->IsActive() )
388cdf0e10cSrcweir             mpWorkStartupTimer->Stop();
389cdf0e10cSrcweir 
390cdf0e10cSrcweir         delete mpWorkStartupTimer;
391cdf0e10cSrcweir         mpWorkStartupTimer = NULL;
392cdf0e10cSrcweir     }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     StopOnlineSpelling();
395cdf0e10cSrcweir     delete mpOnlineSearchItem;
396cdf0e10cSrcweir     mpOnlineSearchItem = NULL;
397cdf0e10cSrcweir 
398cdf0e10cSrcweir     CloseBookmarkDoc();
399cdf0e10cSrcweir     SetAllocDocSh(sal_False);
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     // #116168#
402cdf0e10cSrcweir     ClearModel(sal_True);
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     if (pLinkManager)
405cdf0e10cSrcweir     {
406ee62af74Smarcus         // deallocate BaseLinks
407cdf0e10cSrcweir         if ( pLinkManager->GetLinks().Count() )
408cdf0e10cSrcweir         {
409cdf0e10cSrcweir             pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() );
410cdf0e10cSrcweir         }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir         delete pLinkManager;
413cdf0e10cSrcweir         pLinkManager = NULL;
414cdf0e10cSrcweir     }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir     ::sd::FrameView* pFrameView = NULL;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     for (sal_uLong i = 0; i < mpFrameViewList->Count(); i++)
419cdf0e10cSrcweir     {
420ee62af74Smarcus         // if necessary delete FrameViews
421cdf0e10cSrcweir         pFrameView =
422cdf0e10cSrcweir             static_cast< ::sd::FrameView*>(mpFrameViewList->GetObject(i));
423cdf0e10cSrcweir 
424cdf0e10cSrcweir         if (pFrameView)
425cdf0e10cSrcweir             delete pFrameView;
426cdf0e10cSrcweir     }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     delete mpFrameViewList;
429cdf0e10cSrcweir     mpFrameViewList = NULL;
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     if (mpCustomShowList)
432cdf0e10cSrcweir     {
433cdf0e10cSrcweir         for (sal_uLong j = 0; j < mpCustomShowList->Count(); j++)
434cdf0e10cSrcweir         {
435ee62af74Smarcus             // if necessary delete CustomShows
436cdf0e10cSrcweir             SdCustomShow* pCustomShow = (SdCustomShow*) mpCustomShowList->GetObject(j);
437cdf0e10cSrcweir             delete pCustomShow;
438cdf0e10cSrcweir         }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir         delete mpCustomShowList;
441cdf0e10cSrcweir         mpCustomShowList = NULL;
442cdf0e10cSrcweir     }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir     delete mpOutliner;
445cdf0e10cSrcweir     mpOutliner = NULL;
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     delete mpInternalOutliner;
448cdf0e10cSrcweir     mpInternalOutliner = NULL;
449cdf0e10cSrcweir 
450cdf0e10cSrcweir     delete mpLocale;
451cdf0e10cSrcweir     mpLocale = NULL;
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     delete mpCharClass;
454cdf0e10cSrcweir     mpCharClass = NULL;
455cdf0e10cSrcweir }
456cdf0e10cSrcweir 
457cdf0e10cSrcweir /*************************************************************************
458cdf0e10cSrcweir |*
459ee62af74Smarcus |* This methods creates a new document (SdDrawDocument) and gives back a
460ee62af74Smarcus |* pointer to it. The Drawing Engine uses this method to be able to put
461ee62af74Smarcus |* the document or parts of it into Clipboard/DragServer.
462cdf0e10cSrcweir |*
463cdf0e10cSrcweir \************************************************************************/
464cdf0e10cSrcweir 
465cdf0e10cSrcweir SdrModel* SdDrawDocument::AllocModel() const
466cdf0e10cSrcweir {
467cdf0e10cSrcweir     SdDrawDocument* pNewModel = NULL;
468cdf0e10cSrcweir 
469cdf0e10cSrcweir     if( mpCreatingTransferable )
470cdf0e10cSrcweir     {
471ee62af74Smarcus         // the document will created for Drag&Drop/Clipboard,
472ee62af74Smarcus         // for this the document has to know a DocShell (SvPersist)
473cdf0e10cSrcweir         SfxObjectShell*   pObj = NULL;
474cdf0e10cSrcweir         ::sd::DrawDocShell*     pNewDocSh = NULL;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir         if( meDocType == DOCUMENT_TYPE_IMPRESS )
477cdf0e10cSrcweir             mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell(
478cdf0e10cSrcweir                 SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) );
479cdf0e10cSrcweir         else
480cdf0e10cSrcweir             mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell(
481cdf0e10cSrcweir                 SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir         pNewDocSh = static_cast< ::sd::DrawDocShell*>( pObj = mpCreatingTransferable->GetDocShell() );
484cdf0e10cSrcweir         pNewDocSh->DoInitNew( NULL );
485cdf0e10cSrcweir         pNewModel = pNewDocSh->GetDoc();
486cdf0e10cSrcweir 
487ee62af74Smarcus         // only necessary for Clipboard,
488ee62af74Smarcus         // for Drag&Drop this will happen in DragServer
489cdf0e10cSrcweir         SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
490cdf0e10cSrcweir         SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pNewModel->GetStyleSheetPool();
491cdf0e10cSrcweir 
492cdf0e10cSrcweir         pNewStylePool->CopyGraphicSheets(*pOldStylePool);
493cdf0e10cSrcweir         pNewStylePool->CopyCellSheets(*pOldStylePool);
494cdf0e10cSrcweir         pNewStylePool->CopyTableStyles(*pOldStylePool);
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 
497cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < GetMasterSdPageCount(PK_STANDARD); i++)
498cdf0e10cSrcweir         {
499ee62af74Smarcus             // take all layouts of the MasterPage
500cdf0e10cSrcweir             String aOldLayoutName(((SdDrawDocument*) this)->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName());
501cdf0e10cSrcweir             aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
502cdf0e10cSrcweir             SdStyleSheetVector aCreatedSheets;
503cdf0e10cSrcweir             pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets );
504cdf0e10cSrcweir         }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir         pNewModel->NewOrLoadCompleted( DOC_LOADED );  // loaded from source document
507cdf0e10cSrcweir     }
508cdf0e10cSrcweir     else if( mbAllocDocSh )
509cdf0e10cSrcweir     {
510ee62af74Smarcus         // a DocShell will be created which will be returned with GetAllocedDocSh()
511cdf0e10cSrcweir         SdDrawDocument* pDoc = (SdDrawDocument*) this;
512cdf0e10cSrcweir         pDoc->SetAllocDocSh(sal_False);
513cdf0e10cSrcweir         pDoc->mxAllocedDocShRef = new ::sd::DrawDocShell(
514cdf0e10cSrcweir             SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType);
515cdf0e10cSrcweir         pDoc->mxAllocedDocShRef->DoInitNew(NULL);
516cdf0e10cSrcweir         pNewModel = pDoc->mxAllocedDocShRef->GetDoc();
517cdf0e10cSrcweir     }
518cdf0e10cSrcweir     else
519cdf0e10cSrcweir     {
520cdf0e10cSrcweir         pNewModel = new SdDrawDocument(meDocType, NULL);
521cdf0e10cSrcweir     }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir     return pNewModel;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir /*************************************************************************
527cdf0e10cSrcweir |*
528ee62af74Smarcus |* This methods creates a new page (SdPage) and gives back a pointer to it.
529ee62af74Smarcus |* The Drawing Engine uses this method when loading to create pages (whose
530ee62af74Smarcus |* types are not knowed for it because these are DERIVATIONS of SdrPage).
531cdf0e10cSrcweir |*
532cdf0e10cSrcweir \************************************************************************/
533cdf0e10cSrcweir 
534cdf0e10cSrcweir SdrPage* SdDrawDocument::AllocPage(FASTBOOL bMasterPage)
535cdf0e10cSrcweir {
536cdf0e10cSrcweir     return new SdPage(*this, NULL, (sal_Bool)bMasterPage);
537cdf0e10cSrcweir }
538cdf0e10cSrcweir 
539cdf0e10cSrcweir /*************************************************************************
540cdf0e10cSrcweir |*
541ee62af74Smarcus |* SetChanged(), the modele was changed
542cdf0e10cSrcweir |*
543cdf0e10cSrcweir \************************************************************************/
544cdf0e10cSrcweir 
545cdf0e10cSrcweir void SdDrawDocument::SetChanged(sal_Bool bFlag)
546cdf0e10cSrcweir {
547cdf0e10cSrcweir     if (mpDocSh)
548cdf0e10cSrcweir     {
549cdf0e10cSrcweir         if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified())
550cdf0e10cSrcweir         {
551ee62af74Smarcus             // forward to baseclass
552cdf0e10cSrcweir             FmFormModel::SetChanged(bFlag);
553cdf0e10cSrcweir 
554ee62af74Smarcus             // pass to ObjectShell
555cdf0e10cSrcweir             mpDocSh->SetModified(bFlag);
556cdf0e10cSrcweir         }
557cdf0e10cSrcweir     }
558cdf0e10cSrcweir     else
559cdf0e10cSrcweir     {
560ee62af74Smarcus         // forward to baseclass
561cdf0e10cSrcweir         FmFormModel::SetChanged(bFlag);
562cdf0e10cSrcweir     }
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir /*************************************************************************
566cdf0e10cSrcweir |*
567cdf0e10cSrcweir |* NbcSetChanged(), the model changed, don't call anybody else
568cdf0e10cSrcweir |*
569cdf0e10cSrcweir \************************************************************************/
570cdf0e10cSrcweir 
571cdf0e10cSrcweir void SdDrawDocument::NbcSetChanged(sal_Bool bFlag)
572cdf0e10cSrcweir {
573cdf0e10cSrcweir     // #100237# forward to baseclass
574cdf0e10cSrcweir     FmFormModel::SetChanged(bFlag);
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir /*************************************************************************
578cdf0e10cSrcweir |*
579cdf0e10cSrcweir |* NewOrLoadCompleted
580cdf0e10cSrcweir |*
581ee62af74Smarcus |* Will be called when the document was loaded respectively when it is
582ee62af74Smarcus |* certain that it will not be loaded any longer.
583cdf0e10cSrcweir |*
584cdf0e10cSrcweir \************************************************************************/
585cdf0e10cSrcweir 
586cdf0e10cSrcweir void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode)
587cdf0e10cSrcweir {
588cdf0e10cSrcweir     if (eMode == NEW_DOC)
589cdf0e10cSrcweir     {
590ee62af74Smarcus         // new document:
591ee62af74Smarcus         // create Presentation and default templates,
592ee62af74Smarcus         // create pool for virtual controls
593cdf0e10cSrcweir         CreateLayoutTemplates();
594cdf0e10cSrcweir         CreateDefaultCellStyles();
595cdf0e10cSrcweir 
596cdf0e10cSrcweir         static_cast< SdStyleSheetPool* >( mxStyleSheetPool.get() )->CreatePseudosIfNecessary();
597cdf0e10cSrcweir     }
598cdf0e10cSrcweir     else if (eMode == DOC_LOADED)
599cdf0e10cSrcweir     {
600ee62af74Smarcus             // document was loaded:
601cdf0e10cSrcweir 
602cdf0e10cSrcweir         CheckMasterPages();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir         if ( GetMasterSdPageCount(PK_STANDARD) > 1 )
605cdf0e10cSrcweir             RemoveUnnecessaryMasterPages( NULL, sal_True, sal_False );
606cdf0e10cSrcweir 
607cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < GetPageCount(); i++ )
608cdf0e10cSrcweir         {
609cdf0e10cSrcweir             // Check for correct layout names
610cdf0e10cSrcweir             SdPage* pPage = (SdPage*) GetPage( i );
611cdf0e10cSrcweir 
612cdf0e10cSrcweir             if(pPage->TRG_HasMasterPage())
613cdf0e10cSrcweir             {
614cdf0e10cSrcweir                 SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage();
615cdf0e10cSrcweir 
616cdf0e10cSrcweir                 if(rMaster.GetLayoutName() != pPage->GetLayoutName())
617cdf0e10cSrcweir                 {
618cdf0e10cSrcweir                     pPage->SetLayoutName(rMaster.GetLayoutName());
619cdf0e10cSrcweir                 }
620cdf0e10cSrcweir             }
621cdf0e10cSrcweir         }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir         for ( sal_uInt16 nPage = 0; nPage < GetMasterPageCount(); nPage++)
624cdf0e10cSrcweir         {
625cdf0e10cSrcweir             // LayoutName and PageName must be the same
626cdf0e10cSrcweir             SdPage* pPage = (SdPage*) GetMasterPage( nPage );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir             String aName( pPage->GetLayoutName() );
629cdf0e10cSrcweir             aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ) );
630cdf0e10cSrcweir 
631cdf0e10cSrcweir             if( aName != pPage->GetName() )
632cdf0e10cSrcweir                 pPage->SetName( aName );
633cdf0e10cSrcweir         }
634cdf0e10cSrcweir 
635ee62af74Smarcus         // create language-dependent names of the default layer
636cdf0e10cSrcweir         RestoreLayerNames();
637cdf0e10cSrcweir 
638ee62af74Smarcus         // set language-dependent names of the templates
639cdf0e10cSrcweir         static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames();
640cdf0e10cSrcweir 
641ee62af74Smarcus         // if necessary create missing templates (e.g., formerly there was no Subtitle)
642cdf0e10cSrcweir         static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary();
643cdf0e10cSrcweir     }
644cdf0e10cSrcweir 
645ee62af74Smarcus     // set default template at the Drawing Engine
646cdf0e10cSrcweir     String aName( SdResId(STR_STANDARD_STYLESHEET_NAME));
647cdf0e10cSrcweir     SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_GRAPHICS)));
648cdf0e10cSrcweir 
6499e9dd2d5SArmin Le Grand     // #119287# Set default StyleSheet for SdrGrafObj and SdrOle2Obj
6509e9dd2d5SArmin Le Grand     SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(String( SdResId(STR_POOLSHEET_OBJNOLINENOFILL)), SD_STYLE_FAMILY_GRAPHICS)));
6519e9dd2d5SArmin Le Grand 
652ee62af74Smarcus     // initialize Draw-Outliner and Document Outliner,
653ee62af74Smarcus     // but not the global Outliner because it is not document-specific
654ee62af74Smarcus     // like StyleSheetPool and StyleRequestHandler
655cdf0e10cSrcweir     ::Outliner& rDrawOutliner = GetDrawOutliner();
656cdf0e10cSrcweir     rDrawOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
657cdf0e10cSrcweir     sal_uLong nCntrl = rDrawOutliner.GetControlWord();
658cdf0e10cSrcweir     if (mbOnlineSpell)
659cdf0e10cSrcweir         nCntrl |= EE_CNTRL_ONLINESPELLING;
660cdf0e10cSrcweir     else
661cdf0e10cSrcweir         nCntrl &= ~EE_CNTRL_ONLINESPELLING;
662cdf0e10cSrcweir     rDrawOutliner.SetControlWord(nCntrl);
663cdf0e10cSrcweir 
664ee62af74Smarcus     // initialize HitTest-Outliner and Document Outliner,
665ee62af74Smarcus     // but not the global Outliner because it is not document-specific
666ee62af74Smarcus     // like StyleSheetPool and StyleRequestHandler
667cdf0e10cSrcweir     pHitTestOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
668cdf0e10cSrcweir 
669cdf0e10cSrcweir     if(mpOutliner)
670cdf0e10cSrcweir     {
671cdf0e10cSrcweir         mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
672cdf0e10cSrcweir     }
673cdf0e10cSrcweir     if(mpInternalOutliner)
674cdf0e10cSrcweir     {
675cdf0e10cSrcweir         mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
676cdf0e10cSrcweir     }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir     if ( eMode == DOC_LOADED )
679cdf0e10cSrcweir     {
680ee62af74Smarcus         // presentation objects have to be Listener again of the respective templates
681cdf0e10cSrcweir         SdStyleSheetPool* pSPool = (SdStyleSheetPool*) GetStyleSheetPool();
682cdf0e10cSrcweir         sal_uInt16 nPage, nPageCount;
683cdf0e10cSrcweir 
684cdf0e10cSrcweir         // #96323# create missing layout style sheets for broken documents
685cdf0e10cSrcweir         //         that where created with the 5.2
686cdf0e10cSrcweir         nPageCount = GetMasterSdPageCount( PK_STANDARD );
687cdf0e10cSrcweir         for (nPage = 0; nPage < nPageCount; nPage++)
688cdf0e10cSrcweir         {
689cdf0e10cSrcweir             SdPage* pPage = GetMasterSdPage(nPage, PK_STANDARD);
690cdf0e10cSrcweir             pSPool->CreateLayoutStyleSheets( pPage->GetName(), sal_True );
691cdf0e10cSrcweir         }
692cdf0e10cSrcweir 
693ee62af74Smarcus         // Default and note pages:
694cdf0e10cSrcweir         for (nPage = 0; nPage < GetPageCount(); nPage++)
695cdf0e10cSrcweir         {
696cdf0e10cSrcweir             SdPage* pPage = (SdPage*)GetPage(nPage);
697cdf0e10cSrcweir             NewOrLoadCompleted( pPage, pSPool );
698cdf0e10cSrcweir         }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir         // Masterpages:
701cdf0e10cSrcweir         for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
702cdf0e10cSrcweir         {
703cdf0e10cSrcweir             SdPage* pPage = (SdPage*)GetMasterPage(nPage);
704cdf0e10cSrcweir 
705cdf0e10cSrcweir             NewOrLoadCompleted( pPage, pSPool );
706cdf0e10cSrcweir         }
707cdf0e10cSrcweir     }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir     mbNewOrLoadCompleted = sal_True;
710cdf0e10cSrcweir 
711cdf0e10cSrcweir     /**************************************************************************
712ee62af74Smarcus     * Update all linked Pages
713cdf0e10cSrcweir     **************************************************************************/
714cdf0e10cSrcweir     SdPage* pPage = NULL;
715cdf0e10cSrcweir     sal_uInt16 nMaxSdPages = GetSdPageCount(PK_STANDARD);
716cdf0e10cSrcweir 
717cdf0e10cSrcweir     for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++)
718cdf0e10cSrcweir     {
719cdf0e10cSrcweir         pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD);
720cdf0e10cSrcweir 
721cdf0e10cSrcweir         if (pPage && pPage->GetFileName().Len() && pPage->GetBookmarkName().Len())
722cdf0e10cSrcweir         {
723cdf0e10cSrcweir             pPage->SetModel(this);
724cdf0e10cSrcweir         }
725cdf0e10cSrcweir     }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     UpdateAllLinks();
728cdf0e10cSrcweir 
729cdf0e10cSrcweir     SetChanged( sal_False );
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir /** updates all links, only links in this document should by resolved */
733cdf0e10cSrcweir void SdDrawDocument::UpdateAllLinks()
734cdf0e10cSrcweir {
735cdf0e10cSrcweir     if ( !pDocLockedInsertingLinks && pLinkManager && pLinkManager->GetLinks().Count() )
736cdf0e10cSrcweir     {
737cdf0e10cSrcweir         pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved
738cdf0e10cSrcweir 
739cdf0e10cSrcweir         pLinkManager->UpdateAllLinks();  // query box: update all links?
740cdf0e10cSrcweir 
741cdf0e10cSrcweir         if( pDocLockedInsertingLinks == this )
742cdf0e10cSrcweir             pDocLockedInsertingLinks = NULL;  // unlock inserting links
743cdf0e10cSrcweir     }
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir /** this loops over the presentation objectes of a page and repairs some new settings
747cdf0e10cSrcweir     from old binary files and resets all default strings for empty presentation objects.
748cdf0e10cSrcweir */
749cdf0e10cSrcweir void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool )
750cdf0e10cSrcweir {
751cdf0e10cSrcweir /* cl removed because not needed anymore since binfilter
752cdf0e10cSrcweir     SdrObjListIter aShapeIter( *pPage );
753cdf0e10cSrcweir     while( aShapeIter.IsMore() )
754cdf0e10cSrcweir     {
755cdf0e10cSrcweir         OutlinerParaObject* pOPO = aShapeIter.Next()->GetOutlinerParaObject();
756cdf0e10cSrcweir         if( pOPO )
757cdf0e10cSrcweir         {
758cdf0e10cSrcweir             if( pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
759cdf0e10cSrcweir                 pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT );
760cdf0e10cSrcweir 
761cdf0e10cSrcweir             pOPO->FinishLoad( pSPool );
762cdf0e10cSrcweir         }
763cdf0e10cSrcweir     }
764cdf0e10cSrcweir */
765cdf0e10cSrcweir 
766cdf0e10cSrcweir     const sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() );
767cdf0e10cSrcweir     if(!rPresentationShapes.isEmpty())
768cdf0e10cSrcweir     {
769ee62af74Smarcus         // create lists with title and outline templates
770cdf0e10cSrcweir         String aName = pPage->GetLayoutName();
771cdf0e10cSrcweir         aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ));
772cdf0e10cSrcweir 
773cdf0e10cSrcweir         List* pOutlineList = pSPool->CreateOutlineSheetList(aName);
774cdf0e10cSrcweir         SfxStyleSheet* pTitleSheet = (SfxStyleSheet*)
775cdf0e10cSrcweir                                         pSPool->GetTitleSheet(aName);
776cdf0e10cSrcweir 
777cdf0e10cSrcweir         SdrObject* pObj = rPresentationShapes.getNextShape(0);
778cdf0e10cSrcweir 
779ee62af74Smarcus         // now search for title and outline text objects and
780ee62af74Smarcus         // change objects into Listener
781cdf0e10cSrcweir         while(pObj)
782cdf0e10cSrcweir         {
783cdf0e10cSrcweir             if (pObj->GetObjInventor() == SdrInventor)
784cdf0e10cSrcweir             {
785cdf0e10cSrcweir                 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
786cdf0e10cSrcweir                 sal_uInt16 nId = pObj->GetObjIdentifier();
787cdf0e10cSrcweir 
788cdf0e10cSrcweir                 if (nId == OBJ_TITLETEXT)
789cdf0e10cSrcweir                 {
790cdf0e10cSrcweir                     if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
791cdf0e10cSrcweir                         pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT );
792cdf0e10cSrcweir 
793ee62af74Smarcus                     // sal_True: in doing so do not delete hard attributes
794cdf0e10cSrcweir                     if (pTitleSheet)
795cdf0e10cSrcweir                         pObj->SetStyleSheet(pTitleSheet, sal_True);
796cdf0e10cSrcweir                 }
797cdf0e10cSrcweir                 else if (nId == OBJ_OUTLINETEXT)
798cdf0e10cSrcweir                 {
799cdf0e10cSrcweir                     if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
800cdf0e10cSrcweir                         pOPO->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
801cdf0e10cSrcweir 
802cdf0e10cSrcweir                     for (sal_uInt16 nSheet = 0; nSheet < 10; nSheet++)
803cdf0e10cSrcweir                     {
804cdf0e10cSrcweir                         SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineList->GetObject(nSheet);
805cdf0e10cSrcweir                         if (pSheet)
806cdf0e10cSrcweir                         {
807cdf0e10cSrcweir                             pObj->StartListening(*pSheet);
808cdf0e10cSrcweir 
809cdf0e10cSrcweir                             if( nSheet == 0)
810ee62af74Smarcus                                 // text frame listen to StyleSheet of Layer1
811cdf0e10cSrcweir                                 pObj->NbcSetStyleSheet(pSheet, sal_True);
812cdf0e10cSrcweir                         }
813cdf0e10cSrcweir                     }
814cdf0e10cSrcweir                 }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir                 if (pObj->ISA(SdrTextObj) && pObj->IsEmptyPresObj() && pPage)
817cdf0e10cSrcweir                 {
818cdf0e10cSrcweir                     PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj);
819cdf0e10cSrcweir                     String aString( pPage->GetPresObjText(ePresObjKind) );
820cdf0e10cSrcweir 
821cdf0e10cSrcweir                     if (aString.Len())
822cdf0e10cSrcweir                     {
823cdf0e10cSrcweir                         sd::Outliner* pInternalOutl = GetInternalOutliner(sal_True);
824cdf0e10cSrcweir                         pPage->SetObjText( (SdrTextObj*) pObj, pInternalOutl, ePresObjKind, aString );
825cdf0e10cSrcweir                         pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), sal_True );
826cdf0e10cSrcweir                         pInternalOutl->Clear();
827cdf0e10cSrcweir                     }
828cdf0e10cSrcweir                 }
829cdf0e10cSrcweir             }
830cdf0e10cSrcweir 
831cdf0e10cSrcweir             pObj = rPresentationShapes.getNextShape(pObj);
832cdf0e10cSrcweir         }
833cdf0e10cSrcweir 
834cdf0e10cSrcweir         delete pOutlineList;
835cdf0e10cSrcweir     }
836cdf0e10cSrcweir }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir /*************************************************************************
839cdf0e10cSrcweir |*
840ee62af74Smarcus |* Local Outliner that is used for the outline mode.
841ee62af74Smarcus |* If necessary, insert OutlinerViews into this outliner !
842cdf0e10cSrcweir |*
843cdf0e10cSrcweir \************************************************************************/
844cdf0e10cSrcweir 
845cdf0e10cSrcweir ::sd::Outliner* SdDrawDocument::GetOutliner(sal_Bool bCreateOutliner)
846cdf0e10cSrcweir {
847cdf0e10cSrcweir     if (!mpOutliner && bCreateOutliner)
848cdf0e10cSrcweir     {
849cdf0e10cSrcweir         mpOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
850cdf0e10cSrcweir 
851cdf0e10cSrcweir         if (mpDocSh)
852cdf0e10cSrcweir             mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
853cdf0e10cSrcweir 
854cdf0e10cSrcweir         mpOutliner->SetDefTab( nDefaultTabulator );
855cdf0e10cSrcweir         mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
856cdf0e10cSrcweir     }
857cdf0e10cSrcweir 
858cdf0e10cSrcweir     return(mpOutliner);
859cdf0e10cSrcweir }
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 
862cdf0e10cSrcweir /*************************************************************************
863cdf0e10cSrcweir |*
864ee62af74Smarcus |* Internal Outliner that is used for creating text objects.
865ee62af74Smarcus |* No OutlinerViews will be inserted into this Outliner!
866cdf0e10cSrcweir |*
867cdf0e10cSrcweir \************************************************************************/
868cdf0e10cSrcweir 
869cdf0e10cSrcweir ::sd::Outliner* SdDrawDocument::GetInternalOutliner(sal_Bool bCreateOutliner)
870cdf0e10cSrcweir {
871cdf0e10cSrcweir     if ( !mpInternalOutliner && bCreateOutliner )
872cdf0e10cSrcweir     {
873cdf0e10cSrcweir         mpInternalOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
874cdf0e10cSrcweir         // MT:
875ee62af74Smarcus         // This Outliner is used to create special text objects only.
876ee62af74Smarcus         // As no portion information have to be saved in these text objects,
877ee62af74Smarcus         // the update mode can/should stay always sal_False.
878cdf0e10cSrcweir         mpInternalOutliner->SetUpdateMode( sal_False );
879cdf0e10cSrcweir         mpInternalOutliner->EnableUndo( sal_False );
880cdf0e10cSrcweir 
881cdf0e10cSrcweir         if (mpDocSh)
882cdf0e10cSrcweir             mpInternalOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
883cdf0e10cSrcweir 
884cdf0e10cSrcweir         mpInternalOutliner->SetDefTab( nDefaultTabulator );
885cdf0e10cSrcweir         mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
886cdf0e10cSrcweir     }
887cdf0e10cSrcweir 
888cdf0e10cSrcweir     DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->GetUpdateMode() == sal_False ) , "InternalOutliner: UpdateMode = sal_True !" );
889cdf0e10cSrcweir     DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->IsUndoEnabled() == sal_False ), "InternalOutliner: Undo = sal_True !" );
890cdf0e10cSrcweir 
891ee62af74Smarcus     // MT: Who fills it with spam has to empty it right after:
892ee62af74Smarcus     // Advantages:
893ee62af74Smarcus     // a) No uncessary clear calls.
894ee62af74Smarcus     // b) No spam in memory.
895cdf0e10cSrcweir     DBG_ASSERT( !mpInternalOutliner || ( ( mpInternalOutliner->GetParagraphCount() == 1 ) && ( mpInternalOutliner->GetText( mpInternalOutliner->GetParagraph( 0 ) ).Len() == 0 ) ), "InternalOutliner: Nicht leer!" );
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     return mpInternalOutliner;
898cdf0e10cSrcweir }
899cdf0e10cSrcweir 
900cdf0e10cSrcweir /*************************************************************************
901cdf0e10cSrcweir |*
902ee62af74Smarcus |* OnlineSpelling on/off
903cdf0e10cSrcweir |*
904cdf0e10cSrcweir \************************************************************************/
905cdf0e10cSrcweir 
906cdf0e10cSrcweir void SdDrawDocument::SetOnlineSpell(sal_Bool bIn)
907cdf0e10cSrcweir {
908cdf0e10cSrcweir     mbOnlineSpell = bIn;
909cdf0e10cSrcweir     sal_uLong nCntrl = 0;
910cdf0e10cSrcweir 
911cdf0e10cSrcweir     if(mpOutliner)
912cdf0e10cSrcweir     {
913cdf0e10cSrcweir         nCntrl = mpOutliner->GetControlWord();
914cdf0e10cSrcweir 
915cdf0e10cSrcweir         if(mbOnlineSpell)
916cdf0e10cSrcweir             nCntrl |= EE_CNTRL_ONLINESPELLING;
917cdf0e10cSrcweir         else
918cdf0e10cSrcweir             nCntrl &= ~EE_CNTRL_ONLINESPELLING;
919cdf0e10cSrcweir 
920cdf0e10cSrcweir         mpOutliner->SetControlWord(nCntrl);
921cdf0e10cSrcweir     }
922cdf0e10cSrcweir 
923cdf0e10cSrcweir     if (mpInternalOutliner)
924cdf0e10cSrcweir     {
925cdf0e10cSrcweir         nCntrl = mpInternalOutliner->GetControlWord();
926cdf0e10cSrcweir 
927cdf0e10cSrcweir         if (mbOnlineSpell)
928cdf0e10cSrcweir             nCntrl |= EE_CNTRL_ONLINESPELLING;
929cdf0e10cSrcweir         else
930cdf0e10cSrcweir             nCntrl &= ~EE_CNTRL_ONLINESPELLING;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir         mpInternalOutliner->SetControlWord(nCntrl);
933cdf0e10cSrcweir     }
934cdf0e10cSrcweir 
935cdf0e10cSrcweir     ::Outliner& rOutliner = GetDrawOutliner();
936cdf0e10cSrcweir 
937cdf0e10cSrcweir     nCntrl = rOutliner.GetControlWord();
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     if (mbOnlineSpell)
940cdf0e10cSrcweir         nCntrl |= EE_CNTRL_ONLINESPELLING;
941cdf0e10cSrcweir     else
942cdf0e10cSrcweir         nCntrl &= ~EE_CNTRL_ONLINESPELLING;
943cdf0e10cSrcweir 
944cdf0e10cSrcweir     rOutliner.SetControlWord(nCntrl);
945cdf0e10cSrcweir 
946cdf0e10cSrcweir     if (mbOnlineSpell)
947cdf0e10cSrcweir     {
948cdf0e10cSrcweir         StartOnlineSpelling();
949cdf0e10cSrcweir     }
950cdf0e10cSrcweir     else
951cdf0e10cSrcweir     {
952cdf0e10cSrcweir         StopOnlineSpelling();
953cdf0e10cSrcweir     }
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 
957cdf0e10cSrcweir /*************************************************************************
958cdf0e10cSrcweir |*
959ee62af74Smarcus |* OnlineSpelling: Marking on/off
960cdf0e10cSrcweir |*
961cdf0e10cSrcweir \************************************************************************/
962cdf0e10cSrcweir 
963cdf0e10cSrcweir uno::Reference< uno::XInterface > SdDrawDocument::createUnoModel()
964cdf0e10cSrcweir {
965cdf0e10cSrcweir     uno::Reference< uno::XInterface > xModel;
966cdf0e10cSrcweir 
967cdf0e10cSrcweir     try
968cdf0e10cSrcweir     {
969cdf0e10cSrcweir         if ( mpDocSh )
970cdf0e10cSrcweir             xModel = mpDocSh->GetModel();
971cdf0e10cSrcweir     }
972cdf0e10cSrcweir     catch( uno::RuntimeException& )
973cdf0e10cSrcweir     {
974cdf0e10cSrcweir     }
975cdf0e10cSrcweir 
976cdf0e10cSrcweir     return xModel;
977cdf0e10cSrcweir }
978cdf0e10cSrcweir 
979cdf0e10cSrcweir SvxNumType SdDrawDocument::GetPageNumType() const
980cdf0e10cSrcweir {
981cdf0e10cSrcweir     return mePageNumType;
982cdf0e10cSrcweir }
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 
987cdf0e10cSrcweir void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode)
988cdf0e10cSrcweir {
989cdf0e10cSrcweir     // #108104#
990cdf0e10cSrcweir     // DBG_ASSERT (mpDocSh!=NULL, "No available document shell to set ref device at.");
991cdf0e10cSrcweir 
992cdf0e10cSrcweir     switch (nMode)
993cdf0e10cSrcweir     {
994cdf0e10cSrcweir         case ::com::sun::star::document::PrinterIndependentLayout::DISABLED:
995cdf0e10cSrcweir         case ::com::sun::star::document::PrinterIndependentLayout::ENABLED:
996cdf0e10cSrcweir             // Just store supported modes and inform the doc shell.
997cdf0e10cSrcweir             mnPrinterIndependentLayout = nMode;
998cdf0e10cSrcweir 
999cdf0e10cSrcweir             // #108104#
1000cdf0e10cSrcweir             // Since it is possible that a SdDrawDocument is constructed without a
1001cdf0e10cSrcweir             // SdDrawDocShell the pointer member mpDocSh needs to be tested
1002cdf0e10cSrcweir             // before the call is executed. This is e.-g. used for copy/paste.
1003cdf0e10cSrcweir             if(mpDocSh)
1004cdf0e10cSrcweir             {
1005cdf0e10cSrcweir                 mpDocSh->UpdateRefDevice ();
1006cdf0e10cSrcweir             }
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir             break;
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir         default:
1011cdf0e10cSrcweir             // Ignore unknown values.
1012cdf0e10cSrcweir             break;
1013cdf0e10cSrcweir     }
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir sal_Int32 SdDrawDocument::GetPrinterIndependentLayout (void)
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir     return mnPrinterIndependentLayout;
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir bool SdDrawDocument::IsStartWithPresentation() const
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir     return mbStartWithPresentation;
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation )
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir     mbStartWithPresentation = bStartWithPresentation;
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir // #109538#
1032cdf0e10cSrcweir void SdDrawDocument::PageListChanged()
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir     mpDrawPageListWatcher->Invalidate();
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir // #109538#
1038cdf0e10cSrcweir void SdDrawDocument::MasterPageListChanged()
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir     mpMasterPageListWatcher->Invalidate();
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir void SdDrawDocument::SetCalcFieldValueHdl(::Outliner* pOutliner)
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir     pOutliner->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const rtl::OUString& rAuthor )
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir     // force current user to have first color
1051cdf0e10cSrcweir     if( maAnnotationAuthors.empty() )
1052cdf0e10cSrcweir     {
1053cdf0e10cSrcweir         SvtUserOptions aUserOptions;
1054cdf0e10cSrcweir         maAnnotationAuthors.push_back( aUserOptions.GetFullName() );
1055cdf0e10cSrcweir     }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir     sal_uInt16 idx = 0;
1058cdf0e10cSrcweir     for( std::vector< OUString >::iterator iter( maAnnotationAuthors.begin() ); iter != maAnnotationAuthors.end(); iter++ )
1059cdf0e10cSrcweir     {
1060cdf0e10cSrcweir         if( (*iter) == rAuthor )
1061cdf0e10cSrcweir         {
1062cdf0e10cSrcweir             break;
1063cdf0e10cSrcweir         }
1064cdf0e10cSrcweir         idx++;
1065cdf0e10cSrcweir     }
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir     if( idx == maAnnotationAuthors.size() )
1068cdf0e10cSrcweir     {
1069cdf0e10cSrcweir         maAnnotationAuthors.push_back( rAuthor );
1070cdf0e10cSrcweir     }
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir     return idx;
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir // eof
1076