Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "PageListWatcher.hxx"
22 : #include <com/sun/star/text/WritingMode.hpp>
23 : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
24 : #include <com/sun/star/i18n/ScriptType.hpp>
25 : #include <editeng/forbiddencharacterstable.hxx>
26 :
27 : #include <svx/svxids.hrc>
28 : #include <svl/srchitem.hxx>
29 : #include <editeng/eeitem.hxx>
30 : #include <editeng/scriptspaceitem.hxx>
31 :
32 : #include <unotools/useroptions.hxx>
33 :
34 : #include <sfx2/printer.hxx>
35 : #include <sfx2/app.hxx>
36 : #include <sfx2/linkmgr.hxx>
37 : #include <svx/dialogs.hrc>
38 : #include "Outliner.hxx"
39 : #include "app.hxx"
40 : #include <editeng/editstat.hxx>
41 : #include <editeng/fontitem.hxx>
42 : #include <svl/flagitem.hxx>
43 : #include <svx/svdoattr.hxx>
44 : #include <svx/svdotext.hxx>
45 : #include <editeng/bulitem.hxx>
46 : #include <editeng/numitem.hxx>
47 : #include <svx/svditer.hxx>
48 : #include <editeng/unolingu.hxx>
49 : #include <svl/itempool.hxx>
50 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 : #include <svx/xtable.hxx>
52 : #include <com/sun/star/linguistic2/XHyphenator.hpp>
53 : #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
54 : #include <com/sun/star/beans/XPropertySet.hpp>
55 : #include <editeng/outlobj.hxx>
56 : #include <unotools/saveopt.hxx>
57 : #include <comphelper/extract.hxx>
58 : #include <i18npool/mslangid.hxx>
59 : #include <i18npool/languagetag.hxx>
60 : #include <unotools/charclass.hxx>
61 : #include <comphelper/processfactory.hxx>
62 : #include <unotools/pathoptions.hxx>
63 : #include <unotools/lingucfg.hxx>
64 : #include <unotools/linguprops.hxx>
65 :
66 : #include "eetext.hxx"
67 : #include "drawdoc.hxx"
68 : #include "sdpage.hxx"
69 : #include "pglink.hxx"
70 : #include "sdattr.hxx"
71 : #include "glob.hrc"
72 : #include "glob.hxx"
73 : #include "stlpool.hxx"
74 : #include "sdiocmpt.hxx"
75 : #include "sdresid.hxx"
76 : #include "cusshow.hxx"
77 : #include "customshowlist.hxx"
78 : #include "../ui/inc/DrawDocShell.hxx"
79 : #include "../ui/inc/GraphicDocShell.hxx"
80 : #include "../ui/inc/sdxfer.hxx"
81 : #include "../ui/inc/ViewShell.hxx"
82 : #include "../ui/inc/optsitem.hxx"
83 : #include "../ui/inc/FrameView.hxx"
84 :
85 : #include <tools/tenccvt.hxx>
86 :
87 : using ::rtl::OUString;
88 : using namespace ::sd;
89 : using namespace ::com::sun::star;
90 : using namespace ::com::sun::star::uno;
91 : using namespace ::com::sun::star::lang;
92 : using namespace ::com::sun::star::linguistic2;
93 :
94 : //////////////////////////////////////////////////////////////////////////////
95 :
96 0 : TYPEINIT1( SdDrawDocument, FmFormModel );
97 :
98 : SdDrawDocument* SdDrawDocument::pDocLockedInsertingLinks = NULL;
99 :
100 : //////////////////////////////////////////////////////////////////////////////
101 :
102 20 : PresentationSettings::PresentationSettings()
103 : : mbAll( true ),
104 : mbEndless( false ),
105 : mbCustomShow(false),
106 : mbManual( false ),
107 : mbMouseVisible( false ),
108 : mbMouseAsPen( false ),
109 : mbLockedPages( false ),
110 : mbAlwaysOnTop( false ),
111 : mbFullScreen( true ),
112 : mbAnimationAllowed( true ),
113 : mnPauseTimeout( 10 ),
114 : mbShowPauseLogo( false ),
115 20 : mbStartWithNavigator(false)
116 : {
117 20 : }
118 :
119 : // ---------------------------------------------------------------------------
120 :
121 0 : PresentationSettings::PresentationSettings( const PresentationSettings& r )
122 : : maPresPage( r.maPresPage ),
123 : mbAll( r.mbAll ),
124 : mbEndless( r.mbEndless ),
125 : mbCustomShow( r.mbCustomShow ),
126 : mbManual( r.mbManual ),
127 : mbMouseVisible( r.mbMouseVisible ),
128 : mbMouseAsPen( r.mbMouseAsPen ),
129 : mbLockedPages( r.mbLockedPages ),
130 : mbAlwaysOnTop( r.mbAlwaysOnTop ),
131 : mbFullScreen( r.mbFullScreen ),
132 : mbAnimationAllowed( r.mbAnimationAllowed ),
133 : mnPauseTimeout( r.mnPauseTimeout ),
134 : mbShowPauseLogo( r.mbShowPauseLogo ),
135 0 : mbStartWithNavigator( r.mbStartWithNavigator )
136 : {
137 0 : }
138 :
139 : // ---------------------------------------------------------------------------
140 :
141 20 : SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
142 40 : : FmFormModel( SvtPathOptions().GetPalettePath(), NULL, pDrDocSh )
143 : , mpOutliner(NULL)
144 : , mpInternalOutliner(NULL)
145 : , mpWorkStartupTimer(NULL)
146 : , mpOnlineSpellingTimer(NULL)
147 : , mpOnlineSpellingList(NULL)
148 : , mpOnlineSearchItem(NULL)
149 : , mpCustomShowList(NULL)
150 : , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh))
151 : , mpCreatingTransferable( NULL )
152 : , mbHasOnlineSpellErrors(sal_False)
153 : , mbInitialOnlineSpellingEnabled(sal_True)
154 : , mbNewOrLoadCompleted(sal_False)
155 : , mbStartWithPresentation( false )
156 : , meLanguage( LANGUAGE_SYSTEM )
157 : , meLanguageCJK( LANGUAGE_SYSTEM )
158 : , meLanguageCTL( LANGUAGE_SYSTEM )
159 : , mePageNumType(SVX_ARABIC)
160 : , mbAllocDocSh(sal_False)
161 : , meDocType(eType)
162 : , mpCharClass(NULL)
163 : , mpLocale(NULL)
164 : , mpDrawPageListWatcher(0)
165 40 : , mpMasterPageListWatcher(0)
166 : {
167 : mpDrawPageListWatcher = ::std::auto_ptr<ImpDrawPageListWatcher>(
168 20 : new ImpDrawPageListWatcher(*this));
169 : mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>(
170 20 : new ImpMasterPageListWatcher(*this));
171 :
172 20 : SetObjectShell(pDrDocSh); // fuer das VCDrawModel
173 :
174 20 : if (mpDocSh)
175 : {
176 18 : SetSwapGraphics(sal_True);
177 : }
178 :
179 : // Masseinheit (von App) und Massstab (von SdMod) setzen
180 : sal_Int32 nX, nY;
181 20 : SdOptions* pOptions = SD_MOD()->GetSdOptions(meDocType);
182 20 : pOptions->GetScale( nX, nY );
183 :
184 : // Allow UI scale only for draw documents.
185 20 : if( eType == DOCUMENT_TYPE_DRAW )
186 0 : SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) ); // user-defined
187 : else
188 20 : SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) ); // default
189 :
190 20 : SetScaleUnit(MAP_100TH_MM);
191 20 : SetScaleFraction(Fraction(1, 1));
192 20 : SetDefaultFontHeight(847); // 24p
193 :
194 20 : pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
195 20 : pItemPool->FreezeIdRanges();
196 20 : SetTextDefaults();
197 :
198 : // die DrawingEngine muss auch wissen, wo er ist
199 20 : FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) );
200 :
201 : // Dem DrawOutliner den StyleSheetPool setzen, damit Textobjekte richtig
202 : // eingelesen werden koennen. Der Link zum StyleRequest-Handler des
203 : // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle
204 : // Vorlagen existieren.
205 20 : SdrOutliner& rOutliner = GetDrawOutliner();
206 20 : rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
207 20 : SetCalcFieldValueHdl( &rOutliner );
208 :
209 : // set linguistic options
210 : {
211 20 : const SvtLinguConfig aLinguConfig;
212 20 : SvtLinguOptions aOptions;
213 20 : aLinguConfig.GetOptions( aOptions );
214 :
215 : SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage,
216 20 : ::com::sun::star::i18n::ScriptType::LATIN), EE_CHAR_LANGUAGE );
217 : SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK,
218 20 : ::com::sun::star::i18n::ScriptType::ASIAN), EE_CHAR_LANGUAGE_CJK );
219 : SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL,
220 20 : ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL );
221 :
222 20 : mbOnlineSpell = aOptions.bIsSpellAuto;
223 : }
224 :
225 20 : LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage );
226 20 : LanguageTag aLanguageTag( eRealLanguage);
227 20 : mpLocale = new ::com::sun::star::lang::Locale( aLanguageTag.getLocale());
228 20 : mpCharClass = new CharClass( aLanguageTag );
229 :
230 : // If the current application language is a language that uses right-to-left text...
231 20 : LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
232 20 : if( MsLangId::isRightToLeft( eRealCTLLanguage ) )
233 : {
234 : // ... then we have to set this as a default
235 0 : SetDefaultWritingMode( ::com::sun::star::text::WritingMode_RL_TB );
236 : }
237 :
238 : // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text
239 20 : if (MsLangId::isKorean(eRealCTLLanguage) || (LANGUAGE_JAPANESE == eRealCTLLanguage))
240 : {
241 0 : GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) );
242 : }
243 :
244 : // DefTab und SpellOptions setzen
245 : // Jetzt am Modul (SD)
246 20 : sal_uInt16 nDefTab = pOptions->GetDefTab();
247 20 : SetDefaultTabulator( nDefTab );
248 :
249 : try
250 : {
251 20 : Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
252 20 : if ( xSpellChecker.is() )
253 20 : rOutliner.SetSpeller( xSpellChecker );
254 :
255 20 : Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
256 20 : if( xHyphenator.is() )
257 20 : rOutliner.SetHyphenator( xHyphenator );
258 :
259 20 : SetForbiddenCharsTable( new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() ) );
260 : }
261 0 : catch(...)
262 : {
263 : OSL_FAIL("Can't get SpellChecker");
264 : }
265 :
266 20 : rOutliner.SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
267 :
268 20 : if (mpDocSh)
269 : {
270 18 : SetLinkManager( new sfx2::LinkManager(mpDocSh) );
271 : }
272 :
273 20 : sal_uLong nCntrl = rOutliner.GetControlWord();
274 20 : nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
275 20 : nCntrl |= EE_CNTRL_URLSFXEXECUTE;
276 :
277 20 : if (mbOnlineSpell)
278 20 : nCntrl |= EE_CNTRL_ONLINESPELLING;
279 : else
280 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
281 :
282 20 : nCntrl &= ~ EE_CNTRL_ULSPACESUMMATION;
283 20 : if ( meDocType != DOCUMENT_TYPE_IMPRESS )
284 0 : SetSummationOfParagraphs( sal_False );
285 : else
286 : {
287 20 : SetSummationOfParagraphs( pOptions->IsSummationOfParagraphs() );
288 20 : if ( pOptions->IsSummationOfParagraphs() )
289 0 : nCntrl |= EE_CNTRL_ULSPACESUMMATION;
290 : }
291 20 : rOutliner.SetControlWord(nCntrl);
292 :
293 : // Initialize the printer independent layout mode.
294 20 : SetPrinterIndependentLayout (pOptions->GetPrinterIndependentLayout());
295 :
296 : // Dem HitTestOutliner den StyleSheetPool setzen.
297 : // Der Link zum StyleRequest-Handler des
298 : // Dokuments wird erst in NewOrLoadCompleted gesetzt, da erst dann alle
299 : // Vorlagen existieren.
300 20 : SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() );
301 20 : pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() );
302 :
303 20 : SetCalcFieldValueHdl( pHitTestOutliner );
304 :
305 : try
306 : {
307 20 : Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
308 20 : if ( xSpellChecker.is() )
309 20 : pHitTestOutliner->SetSpeller( xSpellChecker );
310 :
311 20 : Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
312 20 : if( xHyphenator.is() )
313 20 : pHitTestOutliner->SetHyphenator( xHyphenator );
314 : }
315 0 : catch(...)
316 : {
317 : OSL_FAIL("Can't get SpellChecker");
318 : }
319 :
320 20 : pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
321 :
322 20 : sal_uLong nCntrl2 = pHitTestOutliner->GetControlWord();
323 20 : nCntrl2 |= EE_CNTRL_ALLOWBIGOBJS;
324 20 : nCntrl2 |= EE_CNTRL_URLSFXEXECUTE;
325 20 : nCntrl2 &= ~EE_CNTRL_ONLINESPELLING;
326 :
327 20 : nCntrl2 &= ~ EE_CNTRL_ULSPACESUMMATION;
328 20 : if ( pOptions->IsSummationOfParagraphs() )
329 0 : nCntrl2 |= EE_CNTRL_ULSPACESUMMATION;
330 :
331 20 : pHitTestOutliner->SetControlWord( nCntrl2 );
332 :
333 : /**************************************************************************
334 : * Layer anlegen
335 : *
336 : * Es werden auf Pages und MasterPages folgende Default-Layer angelegt:
337 : *
338 : * Layer STR_LAYOUT : Standardlayer f�r alle Zeichenobjekte
339 : *
340 : * Layer STR_BCKGRND : Hintergrund der MasterPage
341 : * (auf normalen Pages z.Z. keine Verwendung)
342 : *
343 : * Layer STR_BCKGRNDOBJ: Objekte auf dem Hintergrund der MasterPage
344 : * (auf normalen Pages z.Z. keine Verwendung)
345 : *
346 : * Layer STR_CONTROLS : Standardlayer f�r Controls
347 : *
348 : **************************************************************************/
349 : {
350 20 : String aControlLayerName( SdResId(STR_LAYER_CONTROLS) );
351 :
352 20 : SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
353 20 : rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_LAYOUT)) );
354 20 : rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRND)) );
355 20 : rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRNDOBJ)) );
356 20 : rLayerAdmin.NewLayer( aControlLayerName );
357 20 : rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_MEASURELINES)) );
358 :
359 20 : rLayerAdmin.SetControlLayerName(aControlLayerName);
360 20 : }
361 :
362 :
363 20 : }
364 :
365 : /*************************************************************************
366 : |*
367 : |* Destruktor
368 : |*
369 : \************************************************************************/
370 :
371 54 : SdDrawDocument::~SdDrawDocument()
372 : {
373 18 : Broadcast(SdrHint(HINT_MODELCLEARED));
374 :
375 18 : if (mpWorkStartupTimer)
376 : {
377 0 : if ( mpWorkStartupTimer->IsActive() )
378 0 : mpWorkStartupTimer->Stop();
379 :
380 0 : delete mpWorkStartupTimer;
381 0 : mpWorkStartupTimer = NULL;
382 : }
383 :
384 18 : StopOnlineSpelling();
385 18 : delete mpOnlineSearchItem;
386 18 : mpOnlineSearchItem = NULL;
387 :
388 18 : CloseBookmarkDoc();
389 18 : SetAllocDocSh(sal_False);
390 :
391 18 : ClearModel(sal_True);
392 :
393 18 : if (pLinkManager)
394 : {
395 : // BaseLinks freigeben
396 16 : if ( !pLinkManager->GetLinks().empty() )
397 : {
398 0 : pLinkManager->Remove( 0, pLinkManager->GetLinks().size() );
399 : }
400 :
401 16 : delete pLinkManager;
402 16 : pLinkManager = NULL;
403 : }
404 :
405 18 : std::vector<sd::FrameView*>::iterator pIter;
406 25 : for ( pIter = maFrameViewList.begin(); pIter != maFrameViewList.end(); ++pIter )
407 7 : delete *pIter;
408 :
409 18 : if (mpCustomShowList)
410 : {
411 1 : for (sal_uLong j = 0; j < mpCustomShowList->size(); j++)
412 : {
413 : // Ggf. CustomShows loeschen
414 0 : SdCustomShow* pCustomShow = (*mpCustomShowList)[j];
415 0 : delete pCustomShow;
416 : }
417 :
418 1 : delete mpCustomShowList;
419 1 : mpCustomShowList = NULL;
420 : }
421 :
422 18 : delete mpOutliner;
423 18 : mpOutliner = NULL;
424 :
425 18 : delete mpInternalOutliner;
426 18 : mpInternalOutliner = NULL;
427 :
428 18 : delete mpLocale;
429 18 : mpLocale = NULL;
430 :
431 18 : delete mpCharClass;
432 18 : mpCharClass = NULL;
433 36 : }
434 :
435 : /*************************************************************************
436 : |*
437 : |* Diese Methode erzeugt ein neues Dokument (SdDrawDocument) und gibt einen
438 : |* Zeiger darauf zurueck. Die Drawing Engine benutzt diese Methode um das
439 : |* Dokument oder Teile davon ins Clipboard/DragServer stellen zu koennen.
440 : |*
441 : \************************************************************************/
442 :
443 0 : SdrModel* SdDrawDocument::AllocModel() const
444 : {
445 0 : SdDrawDocument* pNewModel = NULL;
446 :
447 0 : if( mpCreatingTransferable )
448 : {
449 : // Dokument wird fuer Drag&Drop/Clipboard erzeugt, dafuer muss dem Dokument eine DocShell (SvPersist) bekannt sein
450 0 : SfxObjectShell* pObj = NULL;
451 0 : ::sd::DrawDocShell* pNewDocSh = NULL;
452 :
453 0 : if( meDocType == DOCUMENT_TYPE_IMPRESS )
454 : mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell(
455 0 : SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) );
456 : else
457 : mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell(
458 0 : SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) );
459 :
460 0 : pNewDocSh = static_cast< ::sd::DrawDocShell*>( pObj = mpCreatingTransferable->GetDocShell() );
461 0 : pNewDocSh->DoInitNew( NULL );
462 0 : pNewModel = pNewDocSh->GetDoc();
463 :
464 : // Nur fuer Clipboard notwendig,
465 : // fuer Drag&Drop erfolgt dieses im DragServer
466 0 : SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
467 0 : SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pNewModel->GetStyleSheetPool();
468 :
469 0 : pNewStylePool->CopyGraphicSheets(*pOldStylePool);
470 0 : pNewStylePool->CopyCellSheets(*pOldStylePool);
471 0 : pNewStylePool->CopyTableStyles(*pOldStylePool);
472 :
473 :
474 0 : for (sal_uInt16 i = 0; i < GetMasterSdPageCount(PK_STANDARD); i++)
475 : {
476 : // Alle Layouts der MasterPage mitnehmen
477 0 : String aOldLayoutName(((SdDrawDocument*) this)->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName());
478 0 : aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
479 0 : SdStyleSheetVector aCreatedSheets;
480 0 : pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets );
481 0 : }
482 :
483 0 : pNewModel->NewOrLoadCompleted( DOC_LOADED ); // loaded from source document
484 : }
485 0 : else if( mbAllocDocSh )
486 : {
487 : // Es wird eine DocShell erzeugt, welche mit GetAllocedDocSh() zurueckgegeben wird
488 0 : SdDrawDocument* pDoc = (SdDrawDocument*) this;
489 0 : pDoc->SetAllocDocSh(sal_False);
490 : pDoc->mxAllocedDocShRef = new ::sd::DrawDocShell(
491 0 : SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType);
492 0 : pDoc->mxAllocedDocShRef->DoInitNew(NULL);
493 0 : pNewModel = pDoc->mxAllocedDocShRef->GetDoc();
494 : }
495 : else
496 : {
497 0 : pNewModel = new SdDrawDocument(meDocType, NULL);
498 : }
499 :
500 0 : return pNewModel;
501 : }
502 :
503 : /*************************************************************************
504 : |*
505 : |* Diese Methode erzeugt eine neue Seite (SdPage) und gibt einen Zeiger
506 : |* darauf zurueck. Die Drawing Engine benutzt diese Methode beim Laden
507 : |* zur Erzeugung von Seiten (deren Typ sie ja nicht kennt, da es ABLEITUNGEN
508 : |* der SdrPage sind).
509 : |*
510 : \************************************************************************/
511 :
512 136 : SdrPage* SdDrawDocument::AllocPage(bool bMasterPage)
513 : {
514 136 : return new SdPage(*this, NULL, bMasterPage);
515 : }
516 :
517 : /*************************************************************************
518 : |*
519 : |* SetChanged(), das Model wurde geaendert
520 : |*
521 : \************************************************************************/
522 :
523 15136 : void SdDrawDocument::SetChanged(sal_Bool bFlag)
524 : {
525 15136 : if (mpDocSh)
526 : {
527 15116 : if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified())
528 : {
529 : // weitergeben an Basisklasse
530 0 : FmFormModel::SetChanged(bFlag);
531 :
532 : // an ObjectShell weiterleiten
533 0 : mpDocSh->SetModified(bFlag);
534 : }
535 : }
536 : else
537 : {
538 : // weitergeben an Basisklasse
539 20 : FmFormModel::SetChanged(bFlag);
540 : }
541 15136 : }
542 :
543 : /*************************************************************************
544 : |*
545 : |* NbcSetChanged(), the model changed, don't call anybody else
546 : |*
547 : \************************************************************************/
548 :
549 36 : void SdDrawDocument::NbcSetChanged(sal_Bool bFlag)
550 : {
551 : // forward to baseclass
552 36 : FmFormModel::SetChanged(bFlag);
553 36 : }
554 :
555 : /*************************************************************************
556 : |*
557 : |* NewOrLoadCompleted
558 : |*
559 : |* Wird gerufen, wenn das Dokument geladen wurde bzw. feststeht, dass es
560 : |* nicht mehr geladen wird.
561 : |*
562 : \************************************************************************/
563 :
564 13 : void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode)
565 : {
566 13 : if (eMode == NEW_DOC)
567 : {
568 : // Neues Dokument:
569 : // Praesentations- und Standardvorlagen erzeugen,
570 : // Pool fuer virtuelle Controls erzeugen
571 13 : CreateLayoutTemplates();
572 13 : CreateDefaultCellStyles();
573 :
574 13 : static_cast< SdStyleSheetPool* >( mxStyleSheetPool.get() )->CreatePseudosIfNecessary();
575 : }
576 0 : else if (eMode == DOC_LOADED)
577 : {
578 : // Dokument wurde geladen:
579 :
580 0 : CheckMasterPages();
581 :
582 0 : if ( GetMasterSdPageCount(PK_STANDARD) > 1 )
583 0 : RemoveUnnecessaryMasterPages( NULL, sal_True, sal_False );
584 :
585 0 : for ( sal_uInt16 i = 0; i < GetPageCount(); i++ )
586 : {
587 : // Check for correct layout names
588 0 : SdPage* pPage = (SdPage*) GetPage( i );
589 :
590 0 : if(pPage->TRG_HasMasterPage())
591 : {
592 0 : SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage();
593 :
594 0 : if(rMaster.GetLayoutName() != pPage->GetLayoutName())
595 : {
596 0 : pPage->SetLayoutName(rMaster.GetLayoutName());
597 : }
598 : }
599 : }
600 :
601 0 : for ( sal_uInt16 nPage = 0; nPage < GetMasterPageCount(); nPage++)
602 : {
603 : // LayoutName and PageName must be the same
604 0 : SdPage* pPage = (SdPage*) GetMasterPage( nPage );
605 :
606 0 : String aName( pPage->GetLayoutName() );
607 0 : aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ) );
608 :
609 0 : if( aName != pPage->GetName() )
610 0 : pPage->SetName( aName );
611 0 : }
612 :
613 : // Sprachabhaengige Namen der StandardLayer erzeugen
614 0 : RestoreLayerNames();
615 :
616 : // Sprachabhaengige Namen der Vorlagen setzen
617 0 : static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames();
618 :
619 : // Ggf. fehlende Vorlagen erzeugen (es gab z.B. frueher keinen Subtitle)
620 0 : static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary();
621 : }
622 :
623 : // Standardvorlage an der Drawing Engine setzen
624 13 : String aName( SdResId(STR_STANDARD_STYLESHEET_NAME));
625 13 : SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_GRAPHICS)));
626 :
627 : // Draw-Outliner und Dokument Outliner initialisieren,
628 : // aber nicht den globalen Outliner, den der ist ja nicht
629 : // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler
630 13 : ::Outliner& rDrawOutliner = GetDrawOutliner();
631 13 : rDrawOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
632 13 : sal_uLong nCntrl = rDrawOutliner.GetControlWord();
633 13 : if (mbOnlineSpell)
634 13 : nCntrl |= EE_CNTRL_ONLINESPELLING;
635 : else
636 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
637 13 : rDrawOutliner.SetControlWord(nCntrl);
638 :
639 : // HitTest-Outliner und Dokument Outliner initialisieren,
640 : // aber nicht den globalen Outliner, den der ist ja nicht
641 : // dokumentspezifisch wie StyleSheetPool und StyleRequestHandler
642 13 : pHitTestOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
643 :
644 13 : if(mpOutliner)
645 : {
646 0 : mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
647 : }
648 13 : if(mpInternalOutliner)
649 : {
650 1 : mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
651 : }
652 :
653 13 : if ( eMode == DOC_LOADED )
654 : {
655 : // Praesentationsobjekte muessen wieder Listener der entsprechenden
656 : // Vorlagen werden
657 0 : SdStyleSheetPool* pSPool = (SdStyleSheetPool*) GetStyleSheetPool();
658 : sal_uInt16 nPage, nPageCount;
659 :
660 : // create missing layout style sheets for broken documents
661 : // that where created with the 5.2
662 0 : nPageCount = GetMasterSdPageCount( PK_STANDARD );
663 0 : for (nPage = 0; nPage < nPageCount; nPage++)
664 : {
665 0 : SdPage* pPage = GetMasterSdPage(nPage, PK_STANDARD);
666 0 : pSPool->CreateLayoutStyleSheets( pPage->GetName(), sal_True );
667 : }
668 :
669 : // Standard- und Notizseiten:
670 0 : for (nPage = 0; nPage < GetPageCount(); nPage++)
671 : {
672 0 : SdPage* pPage = (SdPage*)GetPage(nPage);
673 0 : NewOrLoadCompleted( pPage, pSPool );
674 : }
675 :
676 : // Masterpages:
677 0 : for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
678 : {
679 0 : SdPage* pPage = (SdPage*)GetMasterPage(nPage);
680 :
681 0 : NewOrLoadCompleted( pPage, pSPool );
682 : }
683 : }
684 :
685 13 : mbNewOrLoadCompleted = sal_True;
686 :
687 : /**************************************************************************
688 : * Alle gelinkten Pages aktualisieren
689 : **************************************************************************/
690 13 : SdPage* pPage = NULL;
691 13 : sal_uInt16 nMaxSdPages = GetSdPageCount(PK_STANDARD);
692 :
693 14 : for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++)
694 : {
695 1 : pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD);
696 :
697 1 : if (pPage && pPage->GetFileName().Len() && pPage->GetBookmarkName().Len())
698 : {
699 0 : pPage->SetModel(this);
700 : }
701 : }
702 :
703 13 : UpdateAllLinks();
704 :
705 13 : SetChanged( sal_False );
706 13 : }
707 :
708 : /** updates all links, only links in this document should by resolved */
709 15 : void SdDrawDocument::UpdateAllLinks()
710 : {
711 15 : if ( !pDocLockedInsertingLinks && pLinkManager && !pLinkManager->GetLinks().empty() )
712 : {
713 0 : pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved
714 :
715 0 : pLinkManager->UpdateAllLinks(); // query box: update all links?
716 :
717 0 : if( pDocLockedInsertingLinks == this )
718 0 : pDocLockedInsertingLinks = NULL; // unlock inserting links
719 : }
720 15 : }
721 :
722 : /** this loops over the presentation objectes of a page and repairs some new settings
723 : from old binary files and resets all default strings for empty presentation objects.
724 : */
725 0 : void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool )
726 : {
727 0 : const sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() );
728 0 : if(!rPresentationShapes.isEmpty())
729 : {
730 : // Listen mit Titel- und Gliederungsvorlagen erstellen
731 0 : String aName = pPage->GetLayoutName();
732 0 : aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ));
733 :
734 0 : std::vector<SfxStyleSheetBase*> aOutlineList;
735 0 : pSPool->CreateOutlineSheetList(aName,aOutlineList);
736 :
737 0 : SfxStyleSheet* pTitleSheet = (SfxStyleSheet*)pSPool->GetTitleSheet(aName);
738 :
739 0 : SdrObject* pObj = rPresentationShapes.getNextShape(0);
740 :
741 : // jetzt nach Titel- und Gliederungstextobjekten suchen und
742 : // Objekte zu Listenern machen
743 0 : while(pObj)
744 : {
745 0 : if (pObj->GetObjInventor() == SdrInventor)
746 : {
747 0 : OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
748 0 : sal_uInt16 nId = pObj->GetObjIdentifier();
749 :
750 0 : if (nId == OBJ_TITLETEXT)
751 : {
752 0 : if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
753 0 : pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT );
754 :
755 : // sal_True: harte Attribute dabei nicht loeschen
756 0 : if (pTitleSheet)
757 0 : pObj->SetStyleSheet(pTitleSheet, sal_True);
758 : }
759 0 : else if (nId == OBJ_OUTLINETEXT)
760 : {
761 0 : if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
762 0 : pOPO->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
763 :
764 0 : std::vector<SfxStyleSheetBase*>::iterator iter;
765 0 : for (iter = aOutlineList.begin(); iter != aOutlineList.end(); ++iter)
766 : {
767 0 : SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(*iter);
768 :
769 0 : if (pSheet)
770 : {
771 0 : pObj->StartListening(*pSheet);
772 :
773 0 : if( iter == aOutlineList.begin())
774 : // Textrahmen hoert auf StyleSheet der Ebene1
775 0 : pObj->NbcSetStyleSheet(pSheet, sal_True);
776 : }
777 : }
778 : }
779 :
780 0 : if (pObj->ISA(SdrTextObj) && pObj->IsEmptyPresObj() && pPage)
781 : {
782 0 : PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj);
783 0 : String aString( pPage->GetPresObjText(ePresObjKind) );
784 :
785 0 : if (aString.Len())
786 : {
787 0 : sd::Outliner* pInternalOutl = GetInternalOutliner(sal_True);
788 0 : pPage->SetObjText( (SdrTextObj*) pObj, pInternalOutl, ePresObjKind, aString );
789 0 : pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), sal_True );
790 0 : pInternalOutl->Clear();
791 0 : }
792 : }
793 : }
794 :
795 0 : pObj = rPresentationShapes.getNextShape(pObj);
796 0 : }
797 : }
798 0 : }
799 :
800 : /*************************************************************************
801 : |*
802 : |* Lokaler Outliner, welcher fuer den Gliederungsmodus verwendet wird
803 : |* In diesen Outliner werden ggf. OutlinerViews inserted!
804 : |*
805 : \************************************************************************/
806 :
807 28 : ::sd::Outliner* SdDrawDocument::GetOutliner(sal_Bool bCreateOutliner)
808 : {
809 28 : if (!mpOutliner && bCreateOutliner)
810 : {
811 0 : mpOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
812 :
813 0 : if (mpDocSh)
814 0 : mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
815 :
816 0 : mpOutliner->SetDefTab( nDefaultTabulator );
817 0 : mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
818 : }
819 :
820 28 : return(mpOutliner);
821 : }
822 :
823 :
824 : /*************************************************************************
825 : |*
826 : |* Interner Outliner, welcher fuer die Erzeugung von Textobjekten
827 : |* verwendet wird.
828 : |* In diesen Outliner werden keine OutlinerViews inserted!
829 : |*
830 : \************************************************************************/
831 :
832 247 : ::sd::Outliner* SdDrawDocument::GetInternalOutliner(sal_Bool bCreateOutliner)
833 : {
834 247 : if ( !mpInternalOutliner && bCreateOutliner )
835 : {
836 11 : mpInternalOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
837 : // MT:
838 : // Dieser Outliner wird nur fuer das Erzeugen spezieller Textobjekte
839 : // verwendet. Da in diesen Textobjekten keine Portion-Informationen
840 : // gespeichert werden muessen, kann/soll der Update-Mode immer sal_False bleiben.
841 11 : mpInternalOutliner->SetUpdateMode( sal_False );
842 11 : mpInternalOutliner->EnableUndo( sal_False );
843 :
844 11 : if (mpDocSh)
845 11 : mpInternalOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
846 :
847 11 : mpInternalOutliner->SetDefTab( nDefaultTabulator );
848 11 : mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
849 : }
850 :
851 : DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->GetUpdateMode() == sal_False ) , "InternalOutliner: UpdateMode = sal_True !" );
852 : DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->IsUndoEnabled() == sal_False ), "InternalOutliner: Undo = sal_True !" );
853 :
854 : // MT: Wer ihn vollmuellt, macht ihn auch gleich wieder leer:
855 : // Vorteile:
856 : // a) Keine unnoetigen Clear-Aufrufe
857 : // b) Kein Muell im Speicher.
858 : DBG_ASSERT( !mpInternalOutliner || ( ( mpInternalOutliner->GetParagraphCount() == 1 ) && ( mpInternalOutliner->GetText( mpInternalOutliner->GetParagraph( 0 ) ).Len() == 0 ) ), "InternalOutliner: Nicht leer!" );
859 :
860 247 : return mpInternalOutliner;
861 : }
862 :
863 : /*************************************************************************
864 : |*
865 : |* OnlineSpelling ein/aus
866 : |*
867 : \************************************************************************/
868 :
869 0 : void SdDrawDocument::SetOnlineSpell(sal_Bool bIn)
870 : {
871 0 : mbOnlineSpell = bIn;
872 0 : sal_uLong nCntrl = 0;
873 :
874 0 : if(mpOutliner)
875 : {
876 0 : nCntrl = mpOutliner->GetControlWord();
877 :
878 0 : if(mbOnlineSpell)
879 0 : nCntrl |= EE_CNTRL_ONLINESPELLING;
880 : else
881 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
882 :
883 0 : mpOutliner->SetControlWord(nCntrl);
884 : }
885 :
886 0 : if (mpInternalOutliner)
887 : {
888 0 : nCntrl = mpInternalOutliner->GetControlWord();
889 :
890 0 : if (mbOnlineSpell)
891 0 : nCntrl |= EE_CNTRL_ONLINESPELLING;
892 : else
893 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
894 :
895 0 : mpInternalOutliner->SetControlWord(nCntrl);
896 : }
897 :
898 0 : ::Outliner& rOutliner = GetDrawOutliner();
899 :
900 0 : nCntrl = rOutliner.GetControlWord();
901 :
902 0 : if (mbOnlineSpell)
903 0 : nCntrl |= EE_CNTRL_ONLINESPELLING;
904 : else
905 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
906 :
907 0 : rOutliner.SetControlWord(nCntrl);
908 :
909 0 : if (mbOnlineSpell)
910 : {
911 0 : StartOnlineSpelling();
912 : }
913 : else
914 : {
915 0 : StopOnlineSpelling();
916 : }
917 0 : }
918 :
919 :
920 : /*************************************************************************
921 : |*
922 : |* OnlineSpelling: Markierung ein/aus
923 : |*
924 : \************************************************************************/
925 :
926 11 : uno::Reference< uno::XInterface > SdDrawDocument::createUnoModel()
927 : {
928 11 : uno::Reference< uno::XInterface > xModel;
929 :
930 : try
931 : {
932 11 : if ( mpDocSh )
933 11 : xModel = mpDocSh->GetModel();
934 : }
935 0 : catch( uno::RuntimeException& )
936 : {
937 : }
938 :
939 11 : return xModel;
940 : }
941 :
942 46 : SvxNumType SdDrawDocument::GetPageNumType() const
943 : {
944 46 : return mePageNumType;
945 : }
946 :
947 :
948 :
949 :
950 22 : void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode)
951 : {
952 22 : switch (nMode)
953 : {
954 : case ::com::sun::star::document::PrinterIndependentLayout::DISABLED:
955 : case ::com::sun::star::document::PrinterIndependentLayout::ENABLED:
956 : // Just store supported modes and inform the doc shell.
957 22 : mnPrinterIndependentLayout = nMode;
958 :
959 : // Since it is possible that a SdDrawDocument is constructed without a
960 : // SdDrawDocShell the pointer member mpDocSh needs to be tested
961 : // before the call is executed. This is e.-g. used for copy/paste.
962 22 : if(mpDocSh)
963 : {
964 20 : mpDocSh->UpdateRefDevice ();
965 : }
966 :
967 22 : break;
968 :
969 : default:
970 : // Ignore unknown values.
971 0 : break;
972 : }
973 22 : }
974 :
975 46 : sal_Int32 SdDrawDocument::GetPrinterIndependentLayout (void)
976 : {
977 46 : return mnPrinterIndependentLayout;
978 : }
979 :
980 0 : bool SdDrawDocument::IsStartWithPresentation() const
981 : {
982 0 : return mbStartWithPresentation;
983 : }
984 :
985 0 : void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation )
986 : {
987 0 : mbStartWithPresentation = bStartWithPresentation;
988 0 : }
989 :
990 216 : void SdDrawDocument::PageListChanged()
991 : {
992 216 : mpDrawPageListWatcher->Invalidate();
993 216 : }
994 :
995 80 : void SdDrawDocument::MasterPageListChanged()
996 : {
997 80 : mpMasterPageListWatcher->Invalidate();
998 80 : }
999 :
1000 40 : void SdDrawDocument::SetCalcFieldValueHdl(::Outliner* pOutliner)
1001 : {
1002 40 : pOutliner->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
1003 40 : }
1004 :
1005 0 : sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const rtl::OUString& rAuthor )
1006 : {
1007 : // force current user to have first color
1008 0 : if( maAnnotationAuthors.empty() )
1009 : {
1010 0 : SvtUserOptions aUserOptions;
1011 0 : maAnnotationAuthors.push_back( aUserOptions.GetFullName() );
1012 : }
1013 :
1014 0 : sal_uInt16 idx = 0;
1015 0 : for( std::vector< OUString >::iterator iter( maAnnotationAuthors.begin() ); iter != maAnnotationAuthors.end(); iter++ )
1016 : {
1017 0 : if( (*iter) == rAuthor )
1018 : {
1019 0 : break;
1020 : }
1021 0 : idx++;
1022 : }
1023 :
1024 0 : if( idx == maAnnotationAuthors.size() )
1025 : {
1026 0 : maAnnotationAuthors.push_back( rAuthor );
1027 : }
1028 :
1029 0 : return idx;
1030 9 : }
1031 :
1032 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|