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