merge the formfield patch from ooo-build
[ooovba.git] / svx / source / svdraw / svdmodel.cxx
blob991582d84b191541bae9aecb6ecc952e6a2df4d3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdmodel.cxx,v $
10 * $Revision: 1.82 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <svx/svdmodel.hxx>
36 #include <rtl/uuid.h>
37 #include <com/sun/star/lang/XComponent.hpp>
38 #include <osl/endian.h>
39 #include <rtl/logfile.hxx>
40 #include <math.h>
41 #include <tools/urlobj.hxx>
42 #include <unotools/ucbstreamhelper.hxx>
44 #include <tools/string.hxx>
45 #include <svtools/whiter.hxx>
46 #include <svx/xit.hxx>
47 #include <svx/xbtmpit.hxx>
48 #include <svx/xlndsit.hxx>
49 #include <svx/xlnedit.hxx>
50 #include <svx/xflgrit.hxx>
51 #include <svx/xflftrit.hxx>
52 #include <svx/xflhtit.hxx>
53 #include <svx/xlnstit.hxx>
55 #include "svditext.hxx"
56 #include <svx/editeng.hxx> // Fuer EditEngine::CreatePool()
58 #include <svx/xtable.hxx>
60 #include "svditer.hxx"
61 #include <svx/svdtrans.hxx>
62 #include <svx/svdpage.hxx>
63 #include <svx/svdlayer.hxx>
64 #include <svx/svdundo.hxx>
65 #include <svx/svdpool.hxx>
66 #include <svx/svdobj.hxx>
67 #include <svx/svdotext.hxx> // fuer ReformatAllTextObjects und CalcFieldValue
68 #include <svx/svdetc.hxx>
69 #include <svx/svdoutl.hxx>
70 #include <svx/svdoole2.hxx>
71 #include "svdglob.hxx" // Stringcache
72 #include "svdstr.hrc" // Objektname
73 #include "svdoutlinercache.hxx"
76 #include "asiancfg.hxx"
77 #include "fontitem.hxx"
78 #include <svx/colritem.hxx>
79 #include <svx/fhgtitem.hxx>
80 #include <svtools/style.hxx>
81 #include <tools/bigint.hxx>
82 #include <svx/numitem.hxx>
83 #include <bulitem.hxx>
84 #include <svx/outlobj.hxx>
85 #include "forbiddencharacterstable.hxx"
86 #include <svtools/zforlist.hxx>
87 #include <comphelper/processfactory.hxx>
89 // #90477#
90 #include <tools/tenccvt.hxx>
91 #include <svtools/syslocale.hxx>
93 // #95114#
94 #include <vcl/svapp.hxx>
95 #include <svx/sdr/properties/properties.hxx>
96 #include <svx/eeitem.hxx>
97 #include <svtools/itemset.hxx>
99 using namespace ::com::sun::star;
100 using namespace ::com::sun::star::uno;
101 using namespace ::com::sun::star::lang;
103 ////////////////////////////////////////////////////////////////////////////////////////////////////
105 struct SdrModelImpl
107 SfxUndoManager* mpUndoManager;
108 SdrUndoFactory* mpUndoFactory;
109 bool mbAllowShapePropertyChangeListener;
112 ////////////////////////////////////////////////////////////////////////////////////////////////////
114 DBG_NAME(SdrModel)
115 TYPEINIT1(SdrModel,SfxBroadcaster);
116 void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbeddedHelper,
117 bool bUseExtColorTable, bool bLoadRefCounts)
119 mpImpl = new SdrModelImpl;
120 mpImpl->mpUndoManager=0;
121 mpImpl->mpUndoFactory=0;
122 mpImpl->mbAllowShapePropertyChangeListener=false;
123 mbInDestruction=false;
124 aObjUnit=SdrEngineDefaults::GetMapFraction();
125 eObjUnit=SdrEngineDefaults::GetMapUnit();
126 eUIUnit=FUNIT_MM;
127 aUIScale=Fraction(1,1);
128 nUIUnitKomma=0;
129 bUIOnlyKomma=FALSE;
130 pLayerAdmin=NULL;
131 pItemPool=pPool;
132 bMyPool=FALSE;
133 m_pEmbeddedHelper=_pEmbeddedHelper;
134 pDrawOutliner=NULL;
135 pHitTestOutliner=NULL;
136 pRefOutDev=NULL;
137 nProgressAkt=0;
138 nProgressMax=0;
139 nProgressOfs=0;
140 pDefaultStyleSheet=NULL;
141 pLinkManager=NULL;
142 pUndoStack=NULL;
143 pRedoStack=NULL;
144 nMaxUndoCount=16;
145 pAktUndoGroup=NULL;
146 nUndoLevel=0;
147 mbUndoEnabled=true;
148 nProgressPercent=0;
149 nLoadVersion=0;
150 bExtColorTable=FALSE;
151 mbChanged = sal_False;
152 bInfoChanged=FALSE;
153 bPagNumsDirty=FALSE;
154 bMPgNumsDirty=FALSE;
155 bPageNotValid=FALSE;
156 bSavePortable=FALSE;
157 bSaveCompressed=FALSE;
158 bSaveNative=FALSE;
159 bSwapGraphics=FALSE;
160 nSwapGraphicsMode=SDR_SWAPGRAPHICSMODE_DEFAULT;
161 bSaveOLEPreview=FALSE;
162 bPasteResize=FALSE;
163 bNoBitmapCaching=FALSE;
164 bReadOnly=FALSE;
165 nStreamCompressMode=COMPRESSMODE_NONE;
166 nStreamNumberFormat=NUMBERFORMAT_INT_BIGENDIAN;
167 nDefaultTabulator=0;
168 pColorTable=NULL;
169 pDashList=NULL;
170 pLineEndList=NULL;
171 pHatchList=NULL;
172 pGradientList=NULL;
173 pBitmapList=NULL;
174 mpNumberFormatter = NULL;
175 bTransparentTextFrames=FALSE;
176 bStarDrawPreviewMode = FALSE;
177 nStarDrawPreviewMasterPageNum = SDRPAGE_NOTFOUND;
178 pModelStorage = NULL;
179 mpForbiddenCharactersTable = NULL;
180 mbModelLocked = FALSE;
181 mpOutlinerCache = NULL;
182 mbKernAsianPunctuation = sal_False;
183 mbAddExtLeading = sal_False;
185 SvxAsianConfig aAsian;
186 mnCharCompressType = aAsian.GetCharDistanceCompression();
188 #ifdef OSL_LITENDIAN
189 nStreamNumberFormat=NUMBERFORMAT_INT_LITTLEENDIAN;
190 #endif
191 bExtColorTable=bUseExtColorTable;
193 if ( pPool == NULL )
195 pItemPool=new SdrItemPool(0L, bLoadRefCounts);
196 // Der Outliner hat keinen eigenen Pool, deshalb den der EditEngine
197 SfxItemPool* pOutlPool=EditEngine::CreatePool( bLoadRefCounts );
198 // OutlinerPool als SecondaryPool des SdrPool
199 pItemPool->SetSecondaryPool(pOutlPool);
200 // Merken, dass ich mir die beiden Pools selbst gemacht habe
201 bMyPool=TRUE;
203 pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
205 // SJ: #95129# using static SdrEngineDefaults only if default SvxFontHeight item is not available
206 const SfxPoolItem* pPoolItem = pItemPool->GetPoolDefaultItem( EE_CHAR_FONTHEIGHT );
207 if ( pPoolItem )
208 nDefTextHgt = ((SvxFontHeightItem*)pPoolItem)->GetHeight();
209 else
210 nDefTextHgt = SdrEngineDefaults::GetFontHeight();
212 SetTextDefaults();
213 pLayerAdmin=new SdrLayerAdmin;
214 pLayerAdmin->SetModel(this);
215 ImpSetUIUnit();
217 // den DrawOutliner OnDemand erzeugen geht noch nicht, weil ich den Pool
218 // sonst nicht kriege (erst ab 302!)
219 pDrawOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
220 ImpSetOutlinerDefaults(pDrawOutliner, TRUE);
222 pHitTestOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
223 ImpSetOutlinerDefaults(pHitTestOutliner, TRUE);
225 ImpCreateTables();
228 SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
229 maMaPag(1024,32,32),
230 maPages(1024,32,32)
232 #ifdef TIMELOG
233 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
234 #endif
236 DBG_CTOR(SdrModel,NULL);
237 ImpCtor(pPool,pPers,FALSE, (FASTBOOL)bLoadRefCounts);
240 SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
241 maMaPag(1024,32,32),
242 maPages(1024,32,32),
243 aTablePath(rPath)
245 #ifdef TIMELOG
246 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
247 #endif
249 DBG_CTOR(SdrModel,NULL);
250 ImpCtor(pPool,pPers,FALSE, (FASTBOOL)bLoadRefCounts);
253 SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, FASTBOOL bUseExtColorTable, sal_Bool bLoadRefCounts):
254 maMaPag(1024,32,32),
255 maPages(1024,32,32)
257 #ifdef TIMELOG
258 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
259 #endif
261 DBG_CTOR(SdrModel,NULL);
262 ImpCtor(pPool,pPers,bUseExtColorTable, (FASTBOOL)bLoadRefCounts);
265 SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, FASTBOOL bUseExtColorTable, sal_Bool bLoadRefCounts):
266 maMaPag(1024,32,32),
267 maPages(1024,32,32),
268 aTablePath(rPath)
270 #ifdef TIMELOG
271 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
272 #endif
274 DBG_CTOR(SdrModel,NULL);
275 ImpCtor(pPool,pPers,bUseExtColorTable, (FASTBOOL)bLoadRefCounts);
278 SdrModel::SdrModel(const SdrModel& /*rSrcModel*/):
279 SfxBroadcaster(),
280 tools::WeakBase< SdrModel >(),
281 maMaPag(1024,32,32),
282 maPages(1024,32,32)
284 #ifdef TIMELOG
285 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
286 #endif
288 // noch nicht implementiert
289 DBG_ERROR("SdrModel::CopyCtor() ist noch nicht implementiert");
292 SdrModel::~SdrModel()
294 #ifdef TIMELOG
295 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::~SdrModel(...)" );
296 #endif
298 DBG_DTOR(SdrModel,NULL);
300 mbInDestruction = true;
302 Broadcast(SdrHint(HINT_MODELCLEARED));
304 delete mpOutlinerCache;
306 ClearUndoBuffer();
307 #ifdef DBG_UTIL
308 if(pAktUndoGroup)
310 ByteString aStr("Im Dtor des SdrModel steht noch ein offenes Undo rum: \"");
312 aStr += ByteString(pAktUndoGroup->GetComment(), gsl_getSystemTextEncoding());
313 aStr += '\"';
315 DBG_ERROR(aStr.GetBuffer());
317 #endif
318 if (pAktUndoGroup!=NULL)
319 delete pAktUndoGroup;
321 // #116168#
322 ClearModel(sal_True);
324 delete pLayerAdmin;
326 // Den DrawOutliner erst nach dem ItemPool loeschen, da
327 // der ItemPool Items des DrawOutliners referenziert !!! (<- das war mal)
328 // Wg. Problem bei Malte Reihenfolge wieder umgestellt.
329 // Loeschen des Outliners vor dem loeschen des ItemPools
330 delete pHitTestOutliner;
331 delete pDrawOutliner;
333 // delete StyleSheetPool, derived classes should not do this since
334 // the DrawingEngine may need it in its destrctor (SB)
335 if( mxStyleSheetPool.is() )
337 Reference< XComponent > xComponent( dynamic_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY );
338 if( xComponent.is() ) try
340 xComponent->dispose();
342 catch( RuntimeException& )
345 mxStyleSheetPool.clear();
348 if (bMyPool)
350 // Pools loeschen, falls es meine sind
351 SfxItemPool* pOutlPool=pItemPool->GetSecondaryPool();
352 SfxItemPool::Free(pItemPool);
353 // Der OutlinerPool muss nach dem ItemPool plattgemacht werden, da der
354 // ItemPool SetItems enthaelt die ihrerseits Items des OutlinerPools
355 // referenzieren (Joe)
356 SfxItemPool::Free(pOutlPool);
359 if( mpForbiddenCharactersTable )
360 mpForbiddenCharactersTable->release();
362 // Tabellen, Listen und Paletten loeschen
363 if (!bExtColorTable)
364 delete pColorTable;
365 delete pDashList;
366 delete pLineEndList;
367 delete pHatchList;
368 delete pGradientList;
369 delete pBitmapList;
371 if(mpNumberFormatter)
372 delete mpNumberFormatter;
374 delete mpImpl->mpUndoFactory;
375 delete mpImpl;
378 bool SdrModel::IsInDestruction() const
380 return mbInDestruction;
383 const SvNumberFormatter& SdrModel::GetNumberFormatter() const
385 if(!mpNumberFormatter)
387 // use cast here since from outside view this IS a const method
388 ((SdrModel*)this)->mpNumberFormatter = new SvNumberFormatter(
389 ::comphelper::getProcessServiceFactory(), LANGUAGE_SYSTEM);
392 return *mpNumberFormatter;
395 // noch nicht implementiert:
396 void SdrModel::operator=(const SdrModel& /*rSrcModel*/)
398 DBG_ERROR("SdrModel::operator=() ist noch nicht implementiert");
401 FASTBOOL SdrModel::operator==(const SdrModel& /*rCmpModel*/) const
403 DBG_ERROR("SdrModel::operator==() ist noch nicht implementiert");
404 return FALSE;
407 void SdrModel::SetSwapGraphics( FASTBOOL bSwap )
409 bSwapGraphics = bSwap;
412 FASTBOOL SdrModel::IsReadOnly() const
414 return bReadOnly;
417 void SdrModel::SetReadOnly(FASTBOOL bYes)
419 bReadOnly=bYes;
422 ////////////////////////////////////////////////////////////////////////////////////////////////////
424 void SdrModel::SetMaxUndoActionCount(ULONG nAnz)
426 if (nAnz<1) nAnz=1;
427 nMaxUndoCount=nAnz;
428 if (pUndoStack!=NULL) {
429 while (pUndoStack->Count()>nMaxUndoCount) {
430 delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count());
435 void SdrModel::ClearUndoBuffer()
437 if (pUndoStack!=NULL) {
438 while (pUndoStack->Count()!=0) {
439 delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()-1);
441 delete pUndoStack;
442 pUndoStack=NULL;
444 if (pRedoStack!=NULL) {
445 while (pRedoStack->Count()!=0) {
446 delete (SfxUndoAction*) pRedoStack->Remove(pRedoStack->Count()-1);
448 delete pRedoStack;
449 pRedoStack=NULL;
453 FASTBOOL SdrModel::Undo()
455 FASTBOOL bRet=FALSE;
456 if( mpImpl->mpUndoManager )
458 DBG_ERROR("svx::SdrModel::Undo(), method not supported with application undo manager!");
460 else
462 SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
463 if(pDo!=NULL)
465 const bool bWasUndoEnabled = mbUndoEnabled;
466 mbUndoEnabled = false;
467 pDo->Undo();
468 if(pRedoStack==NULL)
469 pRedoStack=new Container(1024,16,16);
470 pRedoStack->Insert(pUndoStack->Remove((ULONG)0),(ULONG)0);
471 mbUndoEnabled = bWasUndoEnabled;
474 return bRet;
477 FASTBOOL SdrModel::Redo()
479 FASTBOOL bRet=FALSE;
480 if( mpImpl->mpUndoManager )
482 DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!");
484 else
486 SfxUndoAction* pDo=(SfxUndoAction*)GetRedoAction(0);
487 if(pDo!=NULL)
489 const bool bWasUndoEnabled = mbUndoEnabled;
490 mbUndoEnabled = false;
491 pDo->Redo();
492 if(pUndoStack==NULL)
493 pUndoStack=new Container(1024,16,16);
494 pUndoStack->Insert(pRedoStack->Remove((ULONG)0),(ULONG)0);
495 mbUndoEnabled = bWasUndoEnabled;
498 return bRet;
501 FASTBOOL SdrModel::Repeat(SfxRepeatTarget& rView)
503 FASTBOOL bRet=FALSE;
504 if( mpImpl->mpUndoManager )
506 DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!");
508 else
510 SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
511 if(pDo!=NULL)
513 if(pDo->CanRepeat(rView))
515 pDo->Repeat(rView);
516 bRet=TRUE;
520 return bRet;
523 void SdrModel::ImpPostUndoAction(SdrUndoAction* pUndo)
525 DBG_ASSERT( mpImpl->mpUndoManager == 0, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" );
526 if( IsUndoEnabled() )
528 if (aUndoLink.IsSet())
530 aUndoLink.Call(pUndo);
532 else
534 if (pUndoStack==NULL)
535 pUndoStack=new Container(1024,16,16);
536 pUndoStack->Insert(pUndo,(ULONG)0);
537 while (pUndoStack->Count()>nMaxUndoCount)
539 delete (SfxUndoAction*)pUndoStack->Remove(pUndoStack->Count()-1);
541 if (pRedoStack!=NULL)
542 pRedoStack->Clear();
545 else
547 delete pUndo;
551 void SdrModel::BegUndo()
553 if( mpImpl->mpUndoManager )
555 const String aEmpty;
556 mpImpl->mpUndoManager->EnterListAction(aEmpty,aEmpty);
557 nUndoLevel++;
559 else if( IsUndoEnabled() )
561 if(pAktUndoGroup==NULL)
563 pAktUndoGroup = new SdrUndoGroup(*this);
564 nUndoLevel=1;
566 else
568 nUndoLevel++;
573 void SdrModel::BegUndo(const XubString& rComment)
575 if( mpImpl->mpUndoManager )
577 const String aEmpty;
578 mpImpl->mpUndoManager->EnterListAction( rComment, aEmpty );
579 nUndoLevel++;
581 else if( IsUndoEnabled() )
583 BegUndo();
584 if (nUndoLevel==1)
586 pAktUndoGroup->SetComment(rComment);
591 void SdrModel::BegUndo(const XubString& rComment, const XubString& rObjDescr, SdrRepeatFunc eFunc)
593 if( mpImpl->mpUndoManager )
595 String aComment(rComment);
596 if( aComment.Len() && rObjDescr.Len() )
598 String aSearchString(RTL_CONSTASCII_USTRINGPARAM("%1"));
599 aComment.SearchAndReplace(aSearchString, rObjDescr);
601 const String aEmpty;
602 mpImpl->mpUndoManager->EnterListAction( aComment,aEmpty );
603 nUndoLevel++;
605 else if( IsUndoEnabled() )
607 BegUndo();
608 if (nUndoLevel==1)
610 pAktUndoGroup->SetComment(rComment);
611 pAktUndoGroup->SetObjDescription(rObjDescr);
612 pAktUndoGroup->SetRepeatFunction(eFunc);
617 void SdrModel::BegUndo(SdrUndoGroup* pUndoGrp)
619 if( mpImpl->mpUndoManager )
621 DBG_ERROR("svx::SdrModel::BegUndo(), method not supported with application undo manager!" );
622 nUndoLevel++;
624 else if( IsUndoEnabled() )
626 if (pAktUndoGroup==NULL)
628 pAktUndoGroup=pUndoGrp;
629 nUndoLevel=1;
631 else
633 delete pUndoGrp;
634 nUndoLevel++;
637 else
639 delete pUndoGrp;
643 void SdrModel::EndUndo()
645 DBG_ASSERT(nUndoLevel!=0,"SdrModel::EndUndo(): UndoLevel is already 0!");
646 if( mpImpl->mpUndoManager )
648 if( nUndoLevel )
650 nUndoLevel--;
651 mpImpl->mpUndoManager->LeaveListAction();
654 else
656 if(pAktUndoGroup!=NULL && IsUndoEnabled())
658 nUndoLevel--;
659 if(nUndoLevel==0)
661 if(pAktUndoGroup->GetActionCount()!=0)
663 SdrUndoAction* pUndo=pAktUndoGroup;
664 pAktUndoGroup=NULL;
665 ImpPostUndoAction(pUndo);
667 else
669 // was empty
670 delete pAktUndoGroup;
671 pAktUndoGroup=NULL;
678 void SdrModel::SetUndoComment(const XubString& rComment)
680 DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is on level 0!");
682 if( mpImpl->mpUndoManager )
684 DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
686 else if( IsUndoEnabled() )
688 if(nUndoLevel==1)
690 pAktUndoGroup->SetComment(rComment);
695 void SdrModel::SetUndoComment(const XubString& rComment, const XubString& rObjDescr)
697 DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is 0!");
698 if( mpImpl->mpUndoManager )
700 DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
702 else
704 if (nUndoLevel==1)
706 pAktUndoGroup->SetComment(rComment);
707 pAktUndoGroup->SetObjDescription(rObjDescr);
712 void SdrModel::AddUndo(SdrUndoAction* pUndo)
714 if( mpImpl->mpUndoManager )
716 mpImpl->mpUndoManager->AddUndoAction( pUndo );
718 else if( !IsUndoEnabled() )
720 delete pUndo;
722 else
724 if (pAktUndoGroup!=NULL)
726 pAktUndoGroup->AddAction(pUndo);
728 else
730 ImpPostUndoAction(pUndo);
735 void SdrModel::EnableUndo( bool bEnable )
737 if( mpImpl->mpUndoManager )
739 mpImpl->mpUndoManager->EnableUndo( bEnable );
741 else
743 mbUndoEnabled = bEnable;
747 bool SdrModel::IsUndoEnabled() const
749 if( mpImpl->mpUndoManager )
751 return mpImpl->mpUndoManager->IsUndoEnabled();
753 else
755 return mbUndoEnabled;
759 ////////////////////////////////////////////////////////////////////////////////////////////////////
761 void SdrModel::ImpCreateTables()
763 // der Writer hat seinen eigenen ColorTable
764 if (!bExtColorTable) pColorTable=new XColorTable(aTablePath,(XOutdevItemPool*)pItemPool);
765 pDashList =new XDashList (aTablePath,(XOutdevItemPool*)pItemPool);
766 pLineEndList =new XLineEndList (aTablePath,(XOutdevItemPool*)pItemPool);
767 pHatchList =new XHatchList (aTablePath,(XOutdevItemPool*)pItemPool);
768 pGradientList=new XGradientList(aTablePath,(XOutdevItemPool*)pItemPool);
769 pBitmapList =new XBitmapList (aTablePath,(XOutdevItemPool*)pItemPool);
772 // #116168#
773 void SdrModel::ClearModel(sal_Bool bCalledFromDestructor)
775 if(bCalledFromDestructor)
777 mbInDestruction = true;
780 sal_Int32 i;
781 // delete all drawing pages
782 sal_Int32 nAnz=GetPageCount();
783 for (i=nAnz-1; i>=0; i--)
785 DeletePage( (USHORT)i );
787 maPages.Clear();
788 // #109538#
789 PageListChanged();
791 // delete all Masterpages
792 nAnz=GetMasterPageCount();
793 for(i=nAnz-1; i>=0; i--)
795 DeleteMasterPage( (USHORT)i );
797 maMaPag.Clear();
798 // #109538#
799 MasterPageListChanged();
801 pLayerAdmin->ClearLayer();
804 SdrModel* SdrModel::AllocModel() const
806 SdrModel* pModel=new SdrModel;
807 pModel->SetScaleUnit(eObjUnit,aObjUnit);
808 return pModel;
811 SdrPage* SdrModel::AllocPage(FASTBOOL bMasterPage)
813 return new SdrPage(*this,bMasterPage);
816 void SdrModel::SetTextDefaults() const
818 SetTextDefaults( pItemPool, nDefTextHgt );
821 void ImpGetDefaultFontsLanguage( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex)
823 const USHORT nItemCnt = 3;
824 static struct {
825 USHORT nFntType, nLanguage;
826 } aOutTypeArr[ nItemCnt ] = {
827 { DEFAULTFONT_LATIN_TEXT, LANGUAGE_ENGLISH_US },
828 { DEFAULTFONT_CJK_TEXT, LANGUAGE_ENGLISH_US },
829 { DEFAULTFONT_CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA }
831 SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex };
833 for( USHORT n = 0; n < nItemCnt; ++n )
835 Font aFnt( OutputDevice::GetDefaultFont(
836 aOutTypeArr[ n ].nFntType, aOutTypeArr[ n ].nLanguage,
837 DEFAULTFONT_FLAGS_ONLYONE, 0 ));
838 SvxFontItem* pI = aItemArr[ n ];
839 pI->GetFamily() = aFnt.GetFamily();
840 pI->GetFamilyName() = aFnt.GetName();
841 pI->GetStyleName().Erase();
842 pI->GetPitch() = aFnt.GetPitch();
843 pI->GetCharSet() = aFnt.GetCharSet();
847 void SdrModel::SetTextDefaults( SfxItemPool* pItemPool, ULONG nDefTextHgt )
849 // #95114# set application-language specific dynamic pool language defaults
850 SvxFontItem aSvxFontItem( EE_CHAR_FONTINFO) ;
851 SvxFontItem aSvxFontItemCJK(EE_CHAR_FONTINFO_CJK);
852 SvxFontItem aSvxFontItemCTL(EE_CHAR_FONTINFO_CTL);
853 sal_uInt16 nLanguage(Application::GetSettings().GetLanguage());
855 // get DEFAULTFONT_LATIN_TEXT and set at pool as dynamic default
856 Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
857 aSvxFontItem.GetFamily() = aFont.GetFamily();
858 aSvxFontItem.GetFamilyName() = aFont.GetName();
859 aSvxFontItem.GetStyleName().Erase();
860 aSvxFontItem.GetPitch() = aFont.GetPitch();
861 aSvxFontItem.GetCharSet() = aFont.GetCharSet();
862 pItemPool->SetPoolDefaultItem(aSvxFontItem);
864 // get DEFAULTFONT_CJK_TEXT and set at pool as dynamic default
865 Font aFontCJK(OutputDevice::GetDefaultFont(DEFAULTFONT_CJK_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
866 aSvxFontItemCJK.GetFamily() = aFontCJK.GetFamily();
867 aSvxFontItemCJK.GetFamilyName() = aFontCJK.GetName();
868 aSvxFontItemCJK.GetStyleName().Erase();
869 aSvxFontItemCJK.GetPitch() = aFontCJK.GetPitch();
870 aSvxFontItemCJK.GetCharSet() = aFontCJK.GetCharSet();
871 pItemPool->SetPoolDefaultItem(aSvxFontItemCJK);
873 // get DEFAULTFONT_CTL_TEXT and set at pool as dynamic default
874 Font aFontCTL(OutputDevice::GetDefaultFont(DEFAULTFONT_CTL_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
875 aSvxFontItemCTL.GetFamily() = aFontCTL.GetFamily();
876 aSvxFontItemCTL.GetFamilyName() = aFontCTL.GetName();
877 aSvxFontItemCTL.GetStyleName().Erase();
878 aSvxFontItemCTL.GetPitch() = aFontCTL.GetPitch();
879 aSvxFontItemCTL.GetCharSet() = aFontCTL.GetCharSet();
880 pItemPool->SetPoolDefaultItem(aSvxFontItemCTL);
882 // set dynamic FontHeight defaults
883 pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT ) );
884 pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
885 pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
887 // set FontColor defaults
888 pItemPool->SetPoolDefaultItem( SvxColorItem(SdrEngineDefaults::GetFontColor(), EE_CHAR_COLOR) );
891 SdrOutliner& SdrModel::GetDrawOutliner(const SdrTextObj* pObj) const
893 pDrawOutliner->SetTextObj(pObj);
894 return *pDrawOutliner;
897 boost::shared_ptr< SdrOutliner > SdrModel::CreateDrawOutliner(const SdrTextObj* pObj)
899 boost::shared_ptr< SdrOutliner > xDrawOutliner( SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this ) );
900 ImpSetOutlinerDefaults(xDrawOutliner.get(), TRUE);
901 xDrawOutliner->SetTextObj(pObj);
902 return xDrawOutliner;
905 const SdrTextObj* SdrModel::GetFormattingTextObj() const
907 if (pDrawOutliner!=NULL) {
908 return pDrawOutliner->GetTextObj();
910 return NULL;
913 void SdrModel::ImpSetOutlinerDefaults( SdrOutliner* pOutliner, BOOL bInit )
915 /**************************************************************************
916 * Initialisierung der Outliner fuer Textausgabe und HitTest
917 **************************************************************************/
918 if( bInit )
920 pOutliner->EraseVirtualDevice();
921 pOutliner->SetUpdateMode(FALSE);
922 pOutliner->SetEditTextObjectPool(pItemPool);
923 pOutliner->SetDefTab(nDefaultTabulator);
926 pOutliner->SetRefDevice(GetRefDevice());
927 pOutliner->SetForbiddenCharsTable(GetForbiddenCharsTable());
928 pOutliner->SetAsianCompressionMode( mnCharCompressType );
929 pOutliner->SetKernAsianPunctuation( IsKernAsianPunctuation() );
930 pOutliner->SetAddExtLeading( IsAddExtLeading() );
932 if ( !GetRefDevice() )
934 MapMode aMapMode(eObjUnit, Point(0,0), aObjUnit, aObjUnit);
935 pOutliner->SetRefMapMode(aMapMode);
939 void SdrModel::SetRefDevice(OutputDevice* pDev)
941 pRefOutDev=pDev;
942 ImpSetOutlinerDefaults( pDrawOutliner );
943 ImpSetOutlinerDefaults( pHitTestOutliner );
944 RefDeviceChanged();
947 void SdrModel::ImpReformatAllTextObjects()
949 if( isLocked() )
950 return;
952 USHORT nAnz=GetMasterPageCount();
953 USHORT nNum;
954 for (nNum=0; nNum<nAnz; nNum++) {
955 GetMasterPage(nNum)->ReformatAllTextObjects();
957 nAnz=GetPageCount();
958 for (nNum=0; nNum<nAnz; nNum++) {
959 GetPage(nNum)->ReformatAllTextObjects();
963 /** #103122#
964 steps over all available pages and sends notify messages to
965 all edge objects that are connected to other objects so that
966 they may reposition itselfs
968 void SdrModel::ImpReformatAllEdgeObjects()
970 if( isLocked() )
971 return;
973 sal_uInt16 nAnz=GetMasterPageCount();
974 sal_uInt16 nNum;
975 for (nNum=0; nNum<nAnz; nNum++)
977 GetMasterPage(nNum)->ReformatAllEdgeObjects();
979 nAnz=GetPageCount();
980 for (nNum=0; nNum<nAnz; nNum++)
982 GetPage(nNum)->ReformatAllEdgeObjects();
986 SvStream* SdrModel::GetDocumentStream(SdrDocumentStreamInfo& /*rStreamInfo*/) const
988 return NULL;
991 // Die Vorlagenattribute der Zeichenobjekte in harte Attribute verwandeln.
992 void SdrModel::BurnInStyleSheetAttributes()
994 USHORT nAnz=GetMasterPageCount();
995 USHORT nNum;
996 for (nNum=0; nNum<nAnz; nNum++) {
997 GetMasterPage(nNum)->BurnInStyleSheetAttributes();
999 nAnz=GetPageCount();
1000 for (nNum=0; nNum<nAnz; nNum++) {
1001 GetPage(nNum)->BurnInStyleSheetAttributes();
1005 void SdrModel::RefDeviceChanged()
1007 Broadcast(SdrHint(HINT_REFDEVICECHG));
1008 ImpReformatAllTextObjects();
1011 void SdrModel::SetDefaultFontHeight(ULONG nVal)
1013 if (nVal!=nDefTextHgt) {
1014 nDefTextHgt=nVal;
1015 Broadcast(SdrHint(HINT_DEFFONTHGTCHG));
1016 ImpReformatAllTextObjects();
1020 void SdrModel::SetDefaultTabulator(USHORT nVal)
1022 if (nDefaultTabulator!=nVal) {
1023 nDefaultTabulator=nVal;
1024 Outliner& rOutliner=GetDrawOutliner();
1025 rOutliner.SetDefTab(nVal);
1026 Broadcast(SdrHint(HINT_DEFAULTTABCHG));
1027 ImpReformatAllTextObjects();
1031 void SdrModel::ImpSetUIUnit()
1033 if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator())
1035 aUIScale = Fraction(1,1);
1038 // set start values
1039 nUIUnitKomma = 0;
1040 sal_Int64 nMul(1);
1041 sal_Int64 nDiv(1);
1043 // normalize on meters resp. inch
1044 switch (eObjUnit)
1046 case MAP_100TH_MM : nUIUnitKomma+=5; break;
1047 case MAP_10TH_MM : nUIUnitKomma+=4; break;
1048 case MAP_MM : nUIUnitKomma+=3; break;
1049 case MAP_CM : nUIUnitKomma+=2; break;
1050 case MAP_1000TH_INCH: nUIUnitKomma+=3; break;
1051 case MAP_100TH_INCH : nUIUnitKomma+=2; break;
1052 case MAP_10TH_INCH : nUIUnitKomma+=1; break;
1053 case MAP_INCH : nUIUnitKomma+=0; break;
1054 case MAP_POINT : nDiv=72; break; // 1Pt = 1/72"
1055 case MAP_TWIP : nDiv=144; nUIUnitKomma++; break; // 1Twip = 1/1440"
1056 case MAP_PIXEL : break;
1057 case MAP_SYSFONT : break;
1058 case MAP_APPFONT : break;
1059 case MAP_RELATIVE : break;
1060 default: break;
1061 } // switch
1063 // 1 mile = 8 furlong = 63.360" = 1.609.344,0mm
1064 // 1 furlong = 10 chains = 7.920" = 201.168,0mm
1065 // 1 chain = 4 poles = 792" = 20.116,8mm
1066 // 1 pole = 5 1/2 yd = 198" = 5.029,2mm
1067 // 1 yd = 3 ft = 36" = 914,4mm
1068 // 1 ft = 12 " = 1" = 304,8mm
1069 switch (eUIUnit)
1071 case FUNIT_NONE : break;
1072 // Metrisch
1073 case FUNIT_100TH_MM: nUIUnitKomma-=5; break;
1074 case FUNIT_MM : nUIUnitKomma-=3; break;
1075 case FUNIT_CM : nUIUnitKomma-=2; break;
1076 case FUNIT_M : nUIUnitKomma+=0; break;
1077 case FUNIT_KM : nUIUnitKomma+=3; break;
1078 // Inch
1079 case FUNIT_TWIP : nMul=144; nUIUnitKomma--; break; // 1Twip = 1/1440"
1080 case FUNIT_POINT : nMul=72; break; // 1Pt = 1/72"
1081 case FUNIT_PICA : nMul=6; break; // 1Pica = 1/6" ?
1082 case FUNIT_INCH : break; // 1" = 1"
1083 case FUNIT_FOOT : nDiv*=12; break; // 1Ft = 12"
1084 case FUNIT_MILE : nDiv*=6336; nUIUnitKomma++; break; // 1mile = 63360"
1085 // sonstiges
1086 case FUNIT_CUSTOM : break;
1087 case FUNIT_PERCENT: nUIUnitKomma+=2; break;
1088 } // switch
1090 // check if mapping is from metric to inch and adapt
1091 const bool bMapInch(IsInch(eObjUnit));
1092 const bool bUIMetr(IsMetric(eUIUnit));
1094 if (bMapInch && bUIMetr)
1096 nUIUnitKomma += 4;
1097 nMul *= 254;
1100 // check if mapping is from inch to metric and adapt
1101 const bool bMapMetr(IsMetric(eObjUnit));
1102 const bool bUIInch(IsInch(eUIUnit));
1104 if (bMapMetr && bUIInch)
1106 nUIUnitKomma -= 4;
1107 nDiv *= 254;
1110 // use temporary fraction for reduction (fallback to 32bit here),
1111 // may need to be changed in the future, too
1112 if(1 != nMul || 1 != nDiv)
1114 const Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv));
1115 nMul = aTemp.GetNumerator();
1116 nDiv = aTemp.GetDenominator();
1119 // #i89872# take Unit of Measurement into account
1120 if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator())
1122 // divide by UIScale
1123 nMul *= aUIScale.GetDenominator();
1124 nDiv *= aUIScale.GetNumerator();
1127 // shorten trailing zeroes for dividend
1128 while(0 == (nMul % 10))
1130 nUIUnitKomma--;
1131 nMul /= 10;
1134 // shorten trailing zeroes for divisor
1135 while(0 == (nDiv % 10))
1137 nUIUnitKomma++;
1138 nDiv /= 10;
1141 // end preparations, set member values
1142 aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv));
1143 bUIOnlyKomma = (nMul == nDiv);
1144 TakeUnitStr(eUIUnit, aUIUnitStr);
1147 void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac)
1149 if (eObjUnit!=eMap || aObjUnit!=rFrac) {
1150 eObjUnit=eMap;
1151 aObjUnit=rFrac;
1152 pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
1153 ImpSetUIUnit();
1154 ImpSetOutlinerDefaults( pDrawOutliner );
1155 ImpSetOutlinerDefaults( pHitTestOutliner );
1156 ImpReformatAllTextObjects(); // #40424#
1160 void SdrModel::SetScaleUnit(MapUnit eMap)
1162 if (eObjUnit!=eMap) {
1163 eObjUnit=eMap;
1164 pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
1165 ImpSetUIUnit();
1166 ImpSetOutlinerDefaults( pDrawOutliner );
1167 ImpSetOutlinerDefaults( pHitTestOutliner );
1168 ImpReformatAllTextObjects(); // #40424#
1172 void SdrModel::SetScaleFraction(const Fraction& rFrac)
1174 if (aObjUnit!=rFrac) {
1175 aObjUnit=rFrac;
1176 ImpSetUIUnit();
1177 ImpSetOutlinerDefaults( pDrawOutliner );
1178 ImpSetOutlinerDefaults( pHitTestOutliner );
1179 ImpReformatAllTextObjects(); // #40424#
1183 void SdrModel::SetUIUnit(FieldUnit eUnit)
1185 if (eUIUnit!=eUnit) {
1186 eUIUnit=eUnit;
1187 ImpSetUIUnit();
1188 ImpReformatAllTextObjects(); // #40424#
1192 void SdrModel::SetUIScale(const Fraction& rScale)
1194 if (aUIScale!=rScale) {
1195 aUIScale=rScale;
1196 ImpSetUIUnit();
1197 ImpReformatAllTextObjects(); // #40424#
1201 void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale)
1203 if (eUIUnit!=eUnit || aUIScale!=rScale) {
1204 eUIUnit=eUnit;
1205 aUIScale=rScale;
1206 ImpSetUIUnit();
1207 ImpReformatAllTextObjects(); // #40424#
1211 void SdrModel::TakeUnitStr(FieldUnit eUnit, XubString& rStr)
1213 switch(eUnit)
1215 default:
1216 case FUNIT_NONE :
1217 case FUNIT_CUSTOM :
1219 rStr = String();
1220 break;
1222 case FUNIT_100TH_MM:
1224 sal_Char aText[] = "/100mm";
1225 rStr = UniString(aText, sizeof(aText-1));
1226 break;
1228 case FUNIT_MM :
1230 sal_Char aText[] = "mm";
1231 rStr = UniString(aText, sizeof(aText-1));
1232 break;
1234 case FUNIT_CM :
1236 sal_Char aText[] = "cm";
1237 rStr = UniString(aText, sizeof(aText-1));
1238 break;
1240 case FUNIT_M :
1242 rStr = String();
1243 rStr += sal_Unicode('m');
1244 break;
1246 case FUNIT_KM :
1248 sal_Char aText[] = "km";
1249 rStr = UniString(aText, sizeof(aText-1));
1250 break;
1252 case FUNIT_TWIP :
1254 sal_Char aText[] = "twip";
1255 rStr = UniString(aText, sizeof(aText-1));
1256 break;
1258 case FUNIT_POINT :
1260 sal_Char aText[] = "pt";
1261 rStr = UniString(aText, sizeof(aText-1));
1262 break;
1264 case FUNIT_PICA :
1266 sal_Char aText[] = "pica";
1267 rStr = UniString(aText, sizeof(aText-1));
1268 break;
1270 case FUNIT_INCH :
1272 rStr = String();
1273 rStr += sal_Unicode('"');
1274 break;
1276 case FUNIT_FOOT :
1278 sal_Char aText[] = "ft";
1279 rStr = UniString(aText, sizeof(aText-1));
1280 break;
1282 case FUNIT_MILE :
1284 sal_Char aText[] = "mile(s)";
1285 rStr = UniString(aText, sizeof(aText-1));
1286 break;
1288 case FUNIT_PERCENT:
1290 rStr = String();
1291 rStr += sal_Unicode('%');
1292 break;
1297 void SdrModel::TakeMetricStr(long nVal, XubString& rStr, FASTBOOL bNoUnitChars, sal_Int32 nNumDigits) const
1299 // #i22167#
1300 // change to double precision usage to not loose decimal places after comma
1301 const bool bNegative(nVal < 0L);
1302 SvtSysLocale aSysLoc;
1303 const LocaleDataWrapper& rLoc(aSysLoc.GetLocaleData());
1304 double fLocalValue(double(nVal) * double(aUIUnitFact));
1306 if(bNegative)
1308 fLocalValue = -fLocalValue;
1311 if( -1 == nNumDigits )
1313 nNumDigits = rLoc.getNumDigits();
1316 sal_Int32 nKomma(nUIUnitKomma);
1318 if(nKomma > nNumDigits)
1320 const sal_Int32 nDiff(nKomma - nNumDigits);
1321 const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
1323 fLocalValue /= fFactor;
1324 nKomma = nNumDigits;
1326 else if(nKomma < nNumDigits)
1328 const sal_Int32 nDiff(nNumDigits - nKomma);
1329 const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
1331 fLocalValue *= fFactor;
1332 nKomma = nNumDigits;
1335 rStr = UniString::CreateFromInt32(static_cast<sal_Int32>(fLocalValue + 0.5));
1337 if(nKomma < 0)
1339 // Negatives Komma bedeutet: Nullen dran
1340 sal_Int32 nAnz(-nKomma);
1342 for(sal_Int32 i=0; i<nAnz; i++)
1343 rStr += sal_Unicode('0');
1345 nKomma = 0;
1348 // #83257# the second condition needs to be <= since inside this loop
1349 // also the leading zero is inserted.
1350 if(nKomma > 0 && rStr.Len() <= nKomma)
1352 // Fuer Komma evtl. vorne Nullen dran
1353 sal_Int32 nAnz(nKomma - rStr.Len());
1355 if(nAnz >= 0 && rLoc.isNumLeadingZero())
1356 nAnz++;
1358 for(sal_Int32 i=0; i<nAnz; i++)
1359 rStr.Insert(sal_Unicode('0'), 0);
1362 sal_Unicode cDec( rLoc.getNumDecimalSep().GetChar(0) );
1364 // KommaChar einfuegen
1365 sal_Int32 nVorKomma(rStr.Len() - nKomma);
1367 if(nKomma > 0)
1368 rStr.Insert(cDec, (xub_StrLen) nVorKomma);
1370 if(!rLoc.isNumTrailingZeros())
1372 while(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == sal_Unicode('0'))
1373 rStr.Erase(rStr.Len() - 1);
1375 if(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == cDec)
1376 rStr.Erase(rStr.Len() - 1);
1379 // ggf. Trennpunkte bei jedem Tausender einfuegen
1380 if( nVorKomma > 3 )
1382 String aThoSep( rLoc.getNumThousandSep() );
1383 if ( aThoSep.Len() > 0 )
1385 sal_Unicode cTho( aThoSep.GetChar(0) );
1386 sal_Int32 i(nVorKomma - 3);
1388 while(i > 0) // #78311#
1390 rStr.Insert(cTho, (xub_StrLen)i);
1391 i -= 3;
1396 if(!rStr.Len())
1398 rStr = String();
1399 rStr += sal_Unicode('0');
1402 if(bNegative)
1404 rStr.Insert(sal_Unicode('-'), 0);
1407 if(!bNoUnitChars)
1408 rStr += aUIUnitStr;
1411 void SdrModel::TakeWinkStr(long nWink, XubString& rStr, FASTBOOL bNoDegChar) const
1413 BOOL bNeg(nWink < 0);
1415 if(bNeg)
1416 nWink = -nWink;
1418 rStr = UniString::CreateFromInt32(nWink);
1420 SvtSysLocale aSysLoc;
1421 const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
1422 xub_StrLen nAnz(2);
1424 if(rLoc.isNumLeadingZero())
1425 nAnz++;
1427 while(rStr.Len() < nAnz)
1428 rStr.Insert(sal_Unicode('0'), 0);
1430 rStr.Insert(rLoc.getNumDecimalSep().GetChar(0), rStr.Len() - 2);
1432 if(bNeg)
1433 rStr.Insert(sal_Unicode('-'), 0);
1435 if(!bNoDegChar)
1436 rStr += DEGREE_CHAR;
1439 void SdrModel::TakePercentStr(const Fraction& rVal, XubString& rStr, FASTBOOL bNoPercentChar) const
1441 INT32 nMul(rVal.GetNumerator());
1442 INT32 nDiv(rVal.GetDenominator());
1443 BOOL bNeg(nMul < 0);
1445 if(nDiv < 0)
1446 bNeg = !bNeg;
1448 if(nMul < 0)
1449 nMul = -nMul;
1451 if(nDiv < 0)
1452 nDiv = -nDiv;
1454 nMul *= 100;
1455 nMul += nDiv/2;
1456 nMul /= nDiv;
1458 rStr = UniString::CreateFromInt32(nMul);
1460 if(bNeg)
1461 rStr.Insert(sal_Unicode('-'), 0);
1463 if(!bNoPercentChar)
1464 rStr += sal_Unicode('%');
1467 void SdrModel::SetChanged(sal_Bool bFlg)
1469 mbChanged = bFlg;
1472 void SdrModel::RecalcPageNums(FASTBOOL bMaster)
1474 Container& rPL=*(bMaster ? &maMaPag : &maPages);
1475 USHORT nAnz=USHORT(rPL.Count());
1476 USHORT i;
1477 for (i=0; i<nAnz; i++) {
1478 SdrPage* pPg=(SdrPage*)(rPL.GetObject(i));
1479 pPg->SetPageNum(i);
1481 if (bMaster) bMPgNumsDirty=FALSE;
1482 else bPagNumsDirty=FALSE;
1485 void SdrModel::InsertPage(SdrPage* pPage, USHORT nPos)
1487 USHORT nAnz=GetPageCount();
1488 if (nPos>nAnz) nPos=nAnz;
1489 maPages.Insert(pPage,nPos);
1490 // #109538#
1491 PageListChanged();
1492 pPage->SetInserted(TRUE);
1493 pPage->SetPageNum(nPos);
1494 pPage->SetModel(this);
1495 if (nPos<nAnz) bPagNumsDirty=TRUE;
1496 SetChanged();
1497 SdrHint aHint(HINT_PAGEORDERCHG);
1498 aHint.SetPage(pPage);
1499 Broadcast(aHint);
1502 void SdrModel::DeletePage(USHORT nPgNum)
1504 SdrPage* pPg=RemovePage(nPgNum);
1505 delete pPg;
1508 SdrPage* SdrModel::RemovePage(USHORT nPgNum)
1510 SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum);
1511 // #109538#
1512 PageListChanged();
1513 if (pPg!=NULL) {
1514 pPg->SetInserted(FALSE);
1516 bPagNumsDirty=TRUE;
1517 SetChanged();
1518 SdrHint aHint(HINT_PAGEORDERCHG);
1519 aHint.SetPage(pPg);
1520 Broadcast(aHint);
1521 return pPg;
1524 void SdrModel::MovePage(USHORT nPgNum, USHORT nNewPos)
1526 SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum);
1527 // #109538#
1528 PageListChanged();
1529 if (pPg!=NULL) {
1530 pPg->SetInserted(FALSE);
1531 InsertPage(pPg,nNewPos);
1535 void SdrModel::InsertMasterPage(SdrPage* pPage, USHORT nPos)
1537 USHORT nAnz=GetMasterPageCount();
1538 if (nPos>nAnz) nPos=nAnz;
1539 maMaPag.Insert(pPage,nPos);
1540 // #109538#
1541 MasterPageListChanged();
1542 pPage->SetInserted(TRUE);
1543 pPage->SetPageNum(nPos);
1544 pPage->SetModel(this);
1545 if (nPos<nAnz) {
1546 bMPgNumsDirty=TRUE;
1548 SetChanged();
1549 SdrHint aHint(HINT_PAGEORDERCHG);
1550 aHint.SetPage(pPage);
1551 Broadcast(aHint);
1554 void SdrModel::DeleteMasterPage(USHORT nPgNum)
1556 SdrPage* pPg=RemoveMasterPage(nPgNum);
1557 if (pPg!=NULL) delete pPg;
1560 SdrPage* SdrModel::RemoveMasterPage(USHORT nPgNum)
1562 SdrPage* pRetPg=(SdrPage*)maMaPag.Remove(nPgNum);
1563 // #109538#
1564 MasterPageListChanged();
1566 if(pRetPg)
1568 // Nun die Verweise der normalen Zeichenseiten auf die entfernte MasterPage loeschen
1569 sal_uInt16 nPageAnz(GetPageCount());
1571 for(sal_uInt16 np(0); np < nPageAnz; np++)
1573 GetPage(np)->TRG_ImpMasterPageRemoved(*pRetPg);
1576 pRetPg->SetInserted(FALSE);
1579 bMPgNumsDirty=TRUE;
1580 SetChanged();
1581 SdrHint aHint(HINT_PAGEORDERCHG);
1582 aHint.SetPage(pRetPg);
1583 Broadcast(aHint);
1584 return pRetPg;
1587 void SdrModel::MoveMasterPage(USHORT nPgNum, USHORT nNewPos)
1589 SdrPage* pPg=(SdrPage*)maMaPag.Remove(nPgNum);
1590 // #109538#
1591 MasterPageListChanged();
1592 if (pPg!=NULL) {
1593 pPg->SetInserted(FALSE);
1594 maMaPag.Insert(pPg,nNewPos);
1595 // #109538#
1596 MasterPageListChanged();
1598 bMPgNumsDirty=TRUE;
1599 SetChanged();
1600 SdrHint aHint(HINT_PAGEORDERCHG);
1601 aHint.SetPage(pPg);
1602 Broadcast(aHint);
1605 ////////////////////////////////////////////////////////////////////////////////////////////////////
1607 FASTBOOL SdrModel::CheckConsistence() const
1609 FASTBOOL bRet=TRUE;
1610 #ifdef DBG_UTIL
1611 DBG_CHKTHIS(SdrModel,NULL);
1612 #endif
1613 return bRet;
1616 ////////////////////////////////////////////////////////////////////////////////////////////////////
1618 // #48289#
1619 void SdrModel::CopyPages(USHORT nFirstPageNum, USHORT nLastPageNum,
1620 USHORT nDestPos,
1621 FASTBOOL bUndo, FASTBOOL bMoveNoCopy)
1623 if( bUndo && !IsUndoEnabled() )
1624 bUndo = false;
1626 if( bUndo )
1627 BegUndo(ImpGetResStr(STR_UndoMergeModel));
1629 USHORT nPageAnz=GetPageCount();
1630 USHORT nMaxPage=nPageAnz;
1632 if (nMaxPage!=0)
1633 nMaxPage--;
1634 if (nFirstPageNum>nMaxPage)
1635 nFirstPageNum=nMaxPage;
1636 if (nLastPageNum>nMaxPage)
1637 nLastPageNum =nMaxPage;
1638 FASTBOOL bReverse=nLastPageNum<nFirstPageNum;
1639 if (nDestPos>nPageAnz)
1640 nDestPos=nPageAnz;
1642 // Zunaechst die Zeiger der betroffenen Seiten in einem Array sichern
1643 USHORT nPageNum=nFirstPageNum;
1644 USHORT nCopyAnz=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1;
1645 SdrPage** pPagePtrs=new SdrPage*[nCopyAnz];
1646 USHORT nCopyNum;
1647 for(nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
1649 pPagePtrs[nCopyNum]=GetPage(nPageNum);
1650 if (bReverse)
1651 nPageNum--;
1652 else
1653 nPageNum++;
1656 // Jetzt die Seiten kopieren
1657 USHORT nDestNum=nDestPos;
1658 for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
1660 SdrPage* pPg=pPagePtrs[nCopyNum];
1661 USHORT nPageNum2=pPg->GetPageNum();
1662 if (!bMoveNoCopy)
1664 const SdrPage* pPg1=GetPage(nPageNum2);
1665 pPg=pPg1->Clone();
1666 InsertPage(pPg,nDestNum);
1667 if (bUndo)
1668 AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg));
1669 nDestNum++;
1671 else
1673 // Move ist nicht getestet!
1674 if (nDestNum>nPageNum2)
1675 nDestNum--;
1677 if(bUndo)
1678 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum));
1680 pPg=RemovePage(nPageNum2);
1681 InsertPage(pPg,nDestNum);
1682 nDestNum++;
1685 if(bReverse)
1686 nPageNum2--;
1687 else
1688 nPageNum2++;
1691 delete[] pPagePtrs;
1692 if(bUndo)
1693 EndUndo();
1696 void SdrModel::Merge(SdrModel& rSourceModel,
1697 USHORT nFirstPageNum, USHORT nLastPageNum,
1698 USHORT nDestPos,
1699 FASTBOOL bMergeMasterPages, FASTBOOL bAllMasterPages,
1700 FASTBOOL bUndo, FASTBOOL bTreadSourceAsConst)
1702 if (&rSourceModel==this)
1703 { // #48289#
1704 CopyPages(nFirstPageNum,nLastPageNum,nDestPos,bUndo,!bTreadSourceAsConst);
1705 return;
1708 if( bUndo && !IsUndoEnabled() )
1709 bUndo = false;
1711 if (bUndo)
1712 BegUndo(ImpGetResStr(STR_UndoMergeModel));
1714 USHORT nSrcPageAnz=rSourceModel.GetPageCount();
1715 USHORT nSrcMasterPageAnz=rSourceModel.GetMasterPageCount();
1716 USHORT nDstMasterPageAnz=GetMasterPageCount();
1717 FASTBOOL bInsPages=(nFirstPageNum<nSrcPageAnz || nLastPageNum<nSrcPageAnz);
1718 USHORT nMaxSrcPage=nSrcPageAnz; if (nMaxSrcPage!=0) nMaxSrcPage--;
1719 if (nFirstPageNum>nMaxSrcPage) nFirstPageNum=nMaxSrcPage;
1720 if (nLastPageNum>nMaxSrcPage) nLastPageNum =nMaxSrcPage;
1721 FASTBOOL bReverse=nLastPageNum<nFirstPageNum;
1723 USHORT* pMasterMap=NULL;
1724 FASTBOOL* pMasterNeed=NULL;
1725 USHORT nMasterNeed=0;
1726 if (bMergeMasterPages && nSrcMasterPageAnz!=0) {
1727 // Feststellen, welche MasterPages aus rSrcModel benoetigt werden
1728 pMasterMap=new USHORT[nSrcMasterPageAnz];
1729 pMasterNeed=new FASTBOOL[nSrcMasterPageAnz];
1730 memset(pMasterMap,0xFF,nSrcMasterPageAnz*sizeof(USHORT));
1731 if (bAllMasterPages) {
1732 memset(pMasterNeed,TRUE,nSrcMasterPageAnz*sizeof(FASTBOOL));
1733 } else {
1734 memset(pMasterNeed,FALSE,nSrcMasterPageAnz*sizeof(FASTBOOL));
1735 USHORT nAnf= bReverse ? nLastPageNum : nFirstPageNum;
1736 USHORT nEnd= bReverse ? nFirstPageNum : nLastPageNum;
1737 for (USHORT i=nAnf; i<=nEnd; i++) {
1738 const SdrPage* pPg=rSourceModel.GetPage(i);
1739 if(pPg->TRG_HasMasterPage())
1741 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
1742 sal_uInt16 nMPgNum(rMasterPage.GetPageNum());
1744 if(nMPgNum < nSrcMasterPageAnz)
1746 pMasterNeed[nMPgNum] = TRUE;
1751 // Nun das Mapping der MasterPages bestimmen
1752 USHORT nAktMaPagNum=nDstMasterPageAnz;
1753 for (USHORT i=0; i<nSrcMasterPageAnz; i++) {
1754 if (pMasterNeed[i]) {
1755 pMasterMap[i]=nAktMaPagNum;
1756 nAktMaPagNum++;
1757 nMasterNeed++;
1762 // rueberholen der Masterpages
1763 if (pMasterMap!=NULL && pMasterNeed!=NULL && nMasterNeed!=0) {
1764 for (USHORT i=nSrcMasterPageAnz; i>0;) {
1765 i--;
1766 if (pMasterNeed[i]) {
1767 SdrPage* pPg=NULL;
1768 if (bTreadSourceAsConst) {
1769 const SdrPage* pPg1=rSourceModel.GetMasterPage(i);
1770 pPg=pPg1->Clone();
1771 } else {
1772 pPg=rSourceModel.RemoveMasterPage(i);
1774 if (pPg!=NULL) {
1775 // und alle ans einstige Ende des DstModel reinschieben.
1776 // nicht InsertMasterPage() verwenden da die Sache
1777 // inkonsistent ist bis alle drin sind
1778 maMaPag.Insert(pPg,nDstMasterPageAnz);
1779 // #109538#
1780 MasterPageListChanged();
1781 pPg->SetInserted(TRUE);
1782 pPg->SetModel(this);
1783 bMPgNumsDirty=TRUE;
1784 if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
1785 } else {
1786 DBG_ERROR("SdrModel::Merge(): MasterPage im SourceModel nicht gefunden");
1792 // rueberholen der Zeichenseiten
1793 if (bInsPages) {
1794 USHORT nSourcePos=nFirstPageNum;
1795 USHORT nMergeCount=USHORT(Abs((long)((long)nFirstPageNum-nLastPageNum))+1);
1796 if (nDestPos>GetPageCount()) nDestPos=GetPageCount();
1797 while (nMergeCount>0) {
1798 SdrPage* pPg=NULL;
1799 if (bTreadSourceAsConst) {
1800 const SdrPage* pPg1=rSourceModel.GetPage(nSourcePos);
1801 pPg=pPg1->Clone();
1802 } else {
1803 pPg=rSourceModel.RemovePage(nSourcePos);
1805 if (pPg!=NULL) {
1806 InsertPage(pPg,nDestPos);
1807 if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
1808 // und nun zu den MasterPageDescriptoren
1810 if(pPg->TRG_HasMasterPage())
1812 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
1813 sal_uInt16 nMaPgNum(rMasterPage.GetPageNum());
1815 if (bMergeMasterPages)
1817 sal_uInt16 nNeuNum(0xFFFF);
1819 if(pMasterMap)
1821 nNeuNum = pMasterMap[nMaPgNum];
1824 if(nNeuNum != 0xFFFF)
1826 if(bUndo)
1828 AddUndo(GetSdrUndoFactory().CreateUndoPageChangeMasterPage(*pPg));
1831 pPg->TRG_SetMasterPage(*GetMasterPage(nNeuNum));
1833 DBG_ASSERT(nNeuNum!=0xFFFF,"SdrModel::Merge(): Irgendwas ist krumm beim Mappen der MasterPages");
1834 } else {
1835 if (nMaPgNum>=nDstMasterPageAnz) {
1836 // Aha, die ist ausserbalb des urspruenglichen Bereichs der Masterpages des DstModel
1837 pPg->TRG_ClearMasterPage();
1842 } else {
1843 DBG_ERROR("SdrModel::Merge(): Zeichenseite im SourceModel nicht gefunden");
1845 nDestPos++;
1846 if (bReverse) nSourcePos--;
1847 else if (bTreadSourceAsConst) nSourcePos++;
1848 nMergeCount--;
1852 delete [] pMasterMap;
1853 delete [] pMasterNeed;
1855 bMPgNumsDirty=TRUE;
1856 bPagNumsDirty=TRUE;
1858 SetChanged();
1859 // Fehlt: Mergen und Mapping der Layer
1860 // an den Objekten sowie an den MasterPageDescriptoren
1861 if (bUndo) EndUndo();
1864 void SdrModel::SetStarDrawPreviewMode(BOOL bPreview)
1866 if (!bPreview && bStarDrawPreviewMode && GetPageCount())
1868 // Das Zuruecksetzen ist nicht erlaubt, da das Model ev. nicht vollstaendig geladen wurde
1869 DBG_ASSERT(FALSE,"SdrModel::SetStarDrawPreviewMode(): Zuruecksetzen nicht erlaubt, da Model ev. nicht vollstaendig");
1871 else
1873 bStarDrawPreviewMode = bPreview;
1877 uno::Reference< uno::XInterface > SdrModel::getUnoModel()
1879 if( !mxUnoModel.is() )
1880 mxUnoModel = createUnoModel();
1882 return mxUnoModel;
1885 void SdrModel::setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel )
1887 mxUnoModel = xModel;
1890 uno::Reference< uno::XInterface > SdrModel::createUnoModel()
1892 DBG_ERROR( "SdrModel::createUnoModel() - base implementation should not be called!" );
1893 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt;
1894 return xInt;
1897 void SdrModel::setLock( BOOL bLock )
1899 if( mbModelLocked != bLock )
1901 if( sal_False == bLock )
1903 // ReformatAllTextObjects(); #103122# due to a typo in the above if, this code was never
1904 // executed, so I remove it until we discover that we need it here
1905 ImpReformatAllEdgeObjects(); // #103122#
1907 mbModelLocked = bLock;
1911 ////////////////////////////////////////////////////////////////////////////////////////////////////
1913 void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel )
1915 if( pSourceSet && pDestSet && (pSourceSet != pDestSet ) )
1917 if( pNewModel == NULL )
1918 pNewModel = this;
1920 SfxWhichIter aWhichIter(*pSourceSet);
1921 sal_uInt16 nWhich(aWhichIter.FirstWhich());
1922 const SfxPoolItem *pPoolItem;
1924 while(nWhich)
1926 if(SFX_ITEM_SET == pSourceSet->GetItemState(nWhich, FALSE, &pPoolItem))
1928 const SfxPoolItem* pItem = pPoolItem;
1930 switch( nWhich )
1932 case XATTR_FILLBITMAP:
1933 pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pNewModel );
1934 break;
1935 case XATTR_LINEDASH:
1936 pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pNewModel );
1937 break;
1938 case XATTR_LINESTART:
1939 pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pNewModel );
1940 break;
1941 case XATTR_LINEEND:
1942 pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pNewModel );
1943 break;
1944 case XATTR_FILLGRADIENT:
1945 pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pNewModel );
1946 break;
1947 case XATTR_FILLFLOATTRANSPARENCE:
1948 // #85953# allow all kinds of XFillFloatTransparenceItem to be set
1949 pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pNewModel );
1950 break;
1951 case XATTR_FILLHATCH:
1952 pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pNewModel );
1953 break;
1956 // set item
1957 if( pItem )
1959 pDestSet->Put(*pItem);
1961 // delete item if it was a generated one
1962 if( pItem != pPoolItem)
1963 delete (SfxPoolItem*)pItem;
1966 nWhich = aWhichIter.NextWhich();
1971 ////////////////////////////////////////////////////////////////////////////////////////////////////
1973 void SdrModel::SetForbiddenCharsTable( vos::ORef<SvxForbiddenCharactersTable> xForbiddenChars )
1975 if( mpForbiddenCharactersTable )
1976 mpForbiddenCharactersTable->release();
1978 mpForbiddenCharactersTable = xForbiddenChars.getBodyPtr();
1980 if( mpForbiddenCharactersTable )
1981 mpForbiddenCharactersTable->acquire();
1983 ImpSetOutlinerDefaults( pDrawOutliner );
1984 ImpSetOutlinerDefaults( pHitTestOutliner );
1987 vos::ORef<SvxForbiddenCharactersTable> SdrModel::GetForbiddenCharsTable() const
1989 return mpForbiddenCharactersTable;
1992 void SdrModel::SetCharCompressType( UINT16 nType )
1994 if( nType != mnCharCompressType )
1996 mnCharCompressType = nType;
1997 ImpSetOutlinerDefaults( pDrawOutliner );
1998 ImpSetOutlinerDefaults( pHitTestOutliner );
2002 void SdrModel::SetKernAsianPunctuation( sal_Bool bEnabled )
2004 if( mbKernAsianPunctuation != bEnabled )
2006 mbKernAsianPunctuation = bEnabled;
2007 ImpSetOutlinerDefaults( pDrawOutliner );
2008 ImpSetOutlinerDefaults( pHitTestOutliner );
2012 void SdrModel::SetAddExtLeading( sal_Bool bEnabled )
2014 if( mbAddExtLeading != bEnabled )
2016 mbAddExtLeading = bEnabled;
2017 ImpSetOutlinerDefaults( pDrawOutliner );
2018 ImpSetOutlinerDefaults( pHitTestOutliner );
2022 void SdrModel::ReformatAllTextObjects()
2024 ImpReformatAllTextObjects();
2027 FASTBOOL SdrModel::HasTransparentObjects( BOOL bCheckForAlphaChannel ) const
2029 FASTBOOL bRet = FALSE;
2030 USHORT n, nCount;
2032 for( n = 0, nCount = GetMasterPageCount(); ( n < nCount ) && !bRet; n++ )
2033 if( GetMasterPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) )
2034 bRet = TRUE;
2036 if( !bRet )
2038 for( n = 0, nCount = GetPageCount(); ( n < nCount ) && !bRet; n++ )
2039 if( GetPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) )
2040 bRet = TRUE;
2043 return bRet;
2046 SdrOutliner* SdrModel::createOutliner( USHORT nOutlinerMode )
2048 if( NULL == mpOutlinerCache )
2049 mpOutlinerCache = new SdrOutlinerCache(this);
2051 return mpOutlinerCache->createOutliner( nOutlinerMode );
2054 void SdrModel::disposeOutliner( SdrOutliner* pOutliner )
2056 if( mpOutlinerCache )
2058 mpOutlinerCache->disposeOutliner( pOutliner );
2060 else
2062 delete pOutliner;
2066 SvxNumType SdrModel::GetPageNumType() const
2068 return SVX_ARABIC;
2071 const SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) const
2073 DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)");
2074 return (SdrPage*)(maPages.GetObject(nPgNum));
2077 SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum)
2079 DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)");
2080 return (SdrPage*)(maPages.GetObject(nPgNum));
2083 sal_uInt16 SdrModel::GetPageCount() const
2085 return sal_uInt16(maPages.Count());
2088 void SdrModel::PageListChanged()
2092 const SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) const
2094 DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)");
2095 return (SdrPage*)(maMaPag.GetObject(nPgNum));
2098 SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum)
2100 DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)");
2101 return (SdrPage*)(maMaPag.GetObject(nPgNum));
2104 sal_uInt16 SdrModel::GetMasterPageCount() const
2106 return sal_uInt16(maMaPag.Count());
2109 void SdrModel::MasterPageListChanged()
2113 void SdrModel::SetSdrUndoManager( SfxUndoManager* pUndoManager )
2115 mpImpl->mpUndoManager = pUndoManager;
2118 SdrUndoFactory& SdrModel::GetSdrUndoFactory() const
2120 if( !mpImpl->mpUndoFactory )
2121 mpImpl->mpUndoFactory = new SdrUndoFactory;
2122 return *mpImpl->mpUndoFactory;
2125 void SdrModel::SetSdrUndoFactory( SdrUndoFactory* pUndoFactory )
2127 if( pUndoFactory && (pUndoFactory != mpImpl->mpUndoFactory) )
2129 delete mpImpl->mpUndoFactory;
2130 mpImpl->mpUndoFactory = pUndoFactory;
2134 /** cl: added this for OJ to complete his reporting engine, does not work
2135 correctly so only enable it for his model */
2136 bool SdrModel::IsAllowShapePropertyChangeListener() const
2138 return mpImpl && mpImpl->mbAllowShapePropertyChangeListener;
2141 void SdrModel::SetAllowShapePropertyChangeListener( bool bAllow )
2143 if( mpImpl )
2145 mpImpl->mbAllowShapePropertyChangeListener = bAllow;
2149 const ::com::sun::star::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelImplementationId()
2151 static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
2152 if( !pSeq )
2154 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
2155 if( !pSeq )
2157 static Sequence< sal_Int8 > aSeq( 16 );
2158 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
2159 pSeq = &aSeq;
2162 return *pSeq;
2165 ////////////////////////////////////////////////////////////////////////////////////////////////////
2167 TYPEINIT1(SdrHint,SfxHint);
2169 SdrHint::SdrHint()
2170 : mpPage(0L),
2171 mpObj(0L),
2172 mpObjList(0L),
2173 meHint(HINT_UNKNOWN)
2177 SdrHint::SdrHint(SdrHintKind eNewHint)
2178 : mpPage(0L),
2179 mpObj(0L),
2180 mpObjList(0L),
2181 meHint(eNewHint)
2185 SdrHint::SdrHint(const SdrObject& rNewObj)
2186 : mpPage(rNewObj.GetPage()),
2187 mpObj(&rNewObj),
2188 mpObjList(rNewObj.GetObjList()),
2189 meHint(HINT_OBJCHG)
2191 maRectangle = rNewObj.GetLastBoundRect();
2194 SdrHint::SdrHint(const SdrObject& rNewObj, const Rectangle& rRect)
2195 : mpPage(rNewObj.GetPage()),
2196 mpObj(&rNewObj),
2197 mpObjList(rNewObj.GetObjList()),
2198 meHint(HINT_OBJCHG)
2200 maRectangle = rRect;
2203 void SdrHint::SetPage(const SdrPage* pNewPage)
2205 mpPage = pNewPage;
2208 void SdrHint::SetObjList(const SdrObjList* pNewOL)
2210 mpObjList = pNewOL;
2213 void SdrHint::SetObject(const SdrObject* pNewObj)
2215 mpObj = pNewObj;
2218 void SdrHint::SetKind(SdrHintKind eNewKind)
2220 meHint = eNewKind;
2223 void SdrHint::SetRect(const Rectangle& rNewRect)
2225 maRectangle = rNewRect;
2228 const SdrPage* SdrHint::GetPage() const
2230 return mpPage;
2233 const SdrObjList* SdrHint::GetObjList() const
2235 return mpObjList;
2238 const SdrObject* SdrHint::GetObject() const
2240 return mpObj;
2243 SdrHintKind SdrHint::GetKind() const
2245 return meHint;
2248 const Rectangle& SdrHint::GetRect() const
2250 return maRectangle;
2253 // eof