xref: /AOO41X/main/svx/source/svdraw/svdmodel.cxx (revision f6e50924346d0b8c0b07c91832a97665dd718b0c)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svx/svdmodel.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <rtl/uuid.h>
30cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
31cdf0e10cSrcweir #include <osl/endian.h>
32cdf0e10cSrcweir #include <rtl/logfile.hxx>
33cdf0e10cSrcweir #include <math.h>
34cdf0e10cSrcweir #include <tools/urlobj.hxx>
35cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <tools/string.hxx>
38cdf0e10cSrcweir #include <svl/whiter.hxx>
39cdf0e10cSrcweir #include <svx/xit.hxx>
40cdf0e10cSrcweir #include <svx/xbtmpit.hxx>
41cdf0e10cSrcweir #include <svx/xlndsit.hxx>
42cdf0e10cSrcweir #include <svx/xlnedit.hxx>
43cdf0e10cSrcweir #include <svx/xflgrit.hxx>
44cdf0e10cSrcweir #include <svx/xflftrit.hxx>
45cdf0e10cSrcweir #include <svx/xflhtit.hxx>
46cdf0e10cSrcweir #include <svx/xlnstit.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include "svx/svditext.hxx"
49cdf0e10cSrcweir #include <editeng/editeng.hxx>   // Fuer EditEngine::CreatePool()
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <svx/xtable.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include "svx/svditer.hxx"
54cdf0e10cSrcweir #include <svx/svdtrans.hxx>
55cdf0e10cSrcweir #include <svx/svdpage.hxx>
56cdf0e10cSrcweir #include <svx/svdlayer.hxx>
57cdf0e10cSrcweir #include <svx/svdundo.hxx>
58cdf0e10cSrcweir #include <svx/svdpool.hxx>
59cdf0e10cSrcweir #include <svx/svdobj.hxx>
60cdf0e10cSrcweir #include <svx/svdotext.hxx>  // fuer ReformatAllTextObjects und CalcFieldValue
61cdf0e10cSrcweir #include <svx/svdetc.hxx>
62cdf0e10cSrcweir #include <svx/svdoutl.hxx>
63cdf0e10cSrcweir #include <svx/svdoole2.hxx>
64cdf0e10cSrcweir #include "svx/svdglob.hxx"  // Stringcache
65cdf0e10cSrcweir #include "svx/svdstr.hrc"   // Objektname
66cdf0e10cSrcweir #include "svdoutlinercache.hxx"
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #include "svx/xflclit.hxx"
69cdf0e10cSrcweir #include "svx/xflhtit.hxx"
70cdf0e10cSrcweir #include "svx/xlnclit.hxx"
71cdf0e10cSrcweir 
72cdf0e10cSrcweir #include <svl/asiancfg.hxx>
73cdf0e10cSrcweir #include "editeng/fontitem.hxx"
74cdf0e10cSrcweir #include <editeng/colritem.hxx>
75cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
76cdf0e10cSrcweir #include <svl/style.hxx>
77cdf0e10cSrcweir #include <tools/bigint.hxx>
78cdf0e10cSrcweir #include <editeng/numitem.hxx>
79cdf0e10cSrcweir #include <editeng/bulitem.hxx>
80cdf0e10cSrcweir #include <editeng/outlobj.hxx>
81cdf0e10cSrcweir #include "editeng/forbiddencharacterstable.hxx"
82cdf0e10cSrcweir #include <svl/zforlist.hxx>
83cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
84cdf0e10cSrcweir 
85cdf0e10cSrcweir // #90477#
86cdf0e10cSrcweir #include <tools/tenccvt.hxx>
87cdf0e10cSrcweir #include <unotools/syslocale.hxx>
88cdf0e10cSrcweir 
89cdf0e10cSrcweir // #95114#
90cdf0e10cSrcweir #include <vcl/svapp.hxx>
91cdf0e10cSrcweir #include <svx/sdr/properties/properties.hxx>
92cdf0e10cSrcweir #include <editeng/eeitem.hxx>
93cdf0e10cSrcweir #include <svl/itemset.hxx>
94cdf0e10cSrcweir 
95cdf0e10cSrcweir using namespace ::com::sun::star;
96cdf0e10cSrcweir using namespace ::com::sun::star::uno;
97cdf0e10cSrcweir using namespace ::com::sun::star::lang;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
100cdf0e10cSrcweir 
101cdf0e10cSrcweir struct SdrModelImpl
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	SfxUndoManager*	mpUndoManager;
104cdf0e10cSrcweir 	SdrUndoFactory* mpUndoFactory;
105cdf0e10cSrcweir 	bool mbAllowShapePropertyChangeListener;
106cdf0e10cSrcweir };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
109cdf0e10cSrcweir 
110cdf0e10cSrcweir DBG_NAME(SdrModel)
111cdf0e10cSrcweir TYPEINIT1(SdrModel,SfxBroadcaster);
112cdf0e10cSrcweir void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbeddedHelper,
113cdf0e10cSrcweir 	bool bUseExtColorTable, bool bLoadRefCounts)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	mpImpl = new SdrModelImpl;
116cdf0e10cSrcweir 	mpImpl->mpUndoManager=0;
117cdf0e10cSrcweir 	mpImpl->mpUndoFactory=0;
118cdf0e10cSrcweir 	mpImpl->mbAllowShapePropertyChangeListener=false;
119cdf0e10cSrcweir 	mbInDestruction=false;
120cdf0e10cSrcweir 	aObjUnit=SdrEngineDefaults::GetMapFraction();
121cdf0e10cSrcweir 	eObjUnit=SdrEngineDefaults::GetMapUnit();
122cdf0e10cSrcweir 	eUIUnit=FUNIT_MM;
123cdf0e10cSrcweir 	aUIScale=Fraction(1,1);
124cdf0e10cSrcweir 	nUIUnitKomma=0;
125cdf0e10cSrcweir 	bUIOnlyKomma=sal_False;
126cdf0e10cSrcweir 	pLayerAdmin=NULL;
127cdf0e10cSrcweir 	pItemPool=pPool;
128cdf0e10cSrcweir 	bMyPool=sal_False;
129cdf0e10cSrcweir 	m_pEmbeddedHelper=_pEmbeddedHelper;
130cdf0e10cSrcweir 	pDrawOutliner=NULL;
131cdf0e10cSrcweir 	pHitTestOutliner=NULL;
132cdf0e10cSrcweir 	pRefOutDev=NULL;
133cdf0e10cSrcweir 	nProgressAkt=0;
134cdf0e10cSrcweir 	nProgressMax=0;
135cdf0e10cSrcweir 	nProgressOfs=0;
136cdf0e10cSrcweir 	pDefaultStyleSheet=NULL;
137cdf0e10cSrcweir 	pLinkManager=NULL;
138cdf0e10cSrcweir 	pUndoStack=NULL;
139cdf0e10cSrcweir 	pRedoStack=NULL;
140cdf0e10cSrcweir 	nMaxUndoCount=16;
141cdf0e10cSrcweir 	pAktUndoGroup=NULL;
142cdf0e10cSrcweir 	nUndoLevel=0;
143cdf0e10cSrcweir 	mbUndoEnabled=true;
144cdf0e10cSrcweir 	nProgressPercent=0;
145cdf0e10cSrcweir 	nLoadVersion=0;
146cdf0e10cSrcweir 	bExtColorTable=sal_False;
147cdf0e10cSrcweir 	mbChanged = sal_False;
148cdf0e10cSrcweir 	bInfoChanged=sal_False;
149cdf0e10cSrcweir 	bPagNumsDirty=sal_False;
150cdf0e10cSrcweir 	bMPgNumsDirty=sal_False;
151cdf0e10cSrcweir 	bPageNotValid=sal_False;
152cdf0e10cSrcweir 	bSavePortable=sal_False;
153cdf0e10cSrcweir 	bSaveCompressed=sal_False;
154cdf0e10cSrcweir 	bSaveNative=sal_False;
155cdf0e10cSrcweir 	bSwapGraphics=sal_False;
156cdf0e10cSrcweir 	nSwapGraphicsMode=SDR_SWAPGRAPHICSMODE_DEFAULT;
157cdf0e10cSrcweir 	bSaveOLEPreview=sal_False;
158cdf0e10cSrcweir 	bPasteResize=sal_False;
159cdf0e10cSrcweir 	bNoBitmapCaching=sal_False;
160cdf0e10cSrcweir 	bReadOnly=sal_False;
161cdf0e10cSrcweir 	nStreamCompressMode=COMPRESSMODE_NONE;
162cdf0e10cSrcweir 	nStreamNumberFormat=NUMBERFORMAT_INT_BIGENDIAN;
163cdf0e10cSrcweir 	nDefaultTabulator=0;
164cdf0e10cSrcweir 	pColorTable=NULL;
165cdf0e10cSrcweir 	pDashList=NULL;
166cdf0e10cSrcweir 	pLineEndList=NULL;
167cdf0e10cSrcweir 	pHatchList=NULL;
168cdf0e10cSrcweir 	pGradientList=NULL;
169cdf0e10cSrcweir 	pBitmapList=NULL;
170cdf0e10cSrcweir 	mpNumberFormatter = NULL;
171cdf0e10cSrcweir 	bTransparentTextFrames=sal_False;
172cdf0e10cSrcweir 	bStarDrawPreviewMode = sal_False;
173cdf0e10cSrcweir 	nStarDrawPreviewMasterPageNum = SDRPAGE_NOTFOUND;
174cdf0e10cSrcweir 	pModelStorage = NULL;
175cdf0e10cSrcweir 	mpForbiddenCharactersTable = NULL;
176cdf0e10cSrcweir 	mbModelLocked = sal_False;
177cdf0e10cSrcweir 	mpOutlinerCache = NULL;
178cdf0e10cSrcweir 	mbKernAsianPunctuation = sal_False;
179cdf0e10cSrcweir     mbAddExtLeading = sal_False;
180cdf0e10cSrcweir 	mnHandoutPageCount = 0;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     SvxAsianConfig aAsian;
183cdf0e10cSrcweir 	mnCharCompressType = aAsian.GetCharDistanceCompression();
184cdf0e10cSrcweir 
185cdf0e10cSrcweir #ifdef OSL_LITENDIAN
186cdf0e10cSrcweir 	nStreamNumberFormat=NUMBERFORMAT_INT_LITTLEENDIAN;
187cdf0e10cSrcweir #endif
188cdf0e10cSrcweir 	bExtColorTable=bUseExtColorTable;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	if ( pPool == NULL )
191cdf0e10cSrcweir     {
192cdf0e10cSrcweir 		pItemPool=new SdrItemPool(0L, bLoadRefCounts);
193cdf0e10cSrcweir 		// Der Outliner hat keinen eigenen Pool, deshalb den der EditEngine
194cdf0e10cSrcweir 		SfxItemPool* pOutlPool=EditEngine::CreatePool( bLoadRefCounts );
195cdf0e10cSrcweir 		// OutlinerPool als SecondaryPool des SdrPool
196cdf0e10cSrcweir 		pItemPool->SetSecondaryPool(pOutlPool);
197cdf0e10cSrcweir 		// Merken, dass ich mir die beiden Pools selbst gemacht habe
198cdf0e10cSrcweir 		bMyPool=sal_True;
199cdf0e10cSrcweir 	}
200cdf0e10cSrcweir 	pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
201cdf0e10cSrcweir 
202cdf0e10cSrcweir // SJ: #95129# using static SdrEngineDefaults only if default SvxFontHeight item is not available
203cdf0e10cSrcweir     const SfxPoolItem* pPoolItem = pItemPool->GetPoolDefaultItem( EE_CHAR_FONTHEIGHT );
204cdf0e10cSrcweir     if ( pPoolItem )
205cdf0e10cSrcweir         nDefTextHgt = ((SvxFontHeightItem*)pPoolItem)->GetHeight();
206cdf0e10cSrcweir     else
207cdf0e10cSrcweir         nDefTextHgt = SdrEngineDefaults::GetFontHeight();
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem( SdrTextWordWrapItem( sal_False ) );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	SetTextDefaults();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	pLayerAdmin=new SdrLayerAdmin;
214cdf0e10cSrcweir 	pLayerAdmin->SetModel(this);
215cdf0e10cSrcweir 	ImpSetUIUnit();
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	// den DrawOutliner OnDemand erzeugen geht noch nicht, weil ich den Pool
218cdf0e10cSrcweir 	// sonst nicht kriege (erst ab 302!)
219cdf0e10cSrcweir 	pDrawOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
220cdf0e10cSrcweir 	ImpSetOutlinerDefaults(pDrawOutliner, sal_True);
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	pHitTestOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
223cdf0e10cSrcweir 	ImpSetOutlinerDefaults(pHitTestOutliner, sal_True);
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	ImpCreateTables();
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
229cdf0e10cSrcweir 	maMaPag(1024,32,32),
230cdf0e10cSrcweir 	maPages(1024,32,32)
231cdf0e10cSrcweir {
232cdf0e10cSrcweir #ifdef TIMELOG
233cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
234cdf0e10cSrcweir #endif
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	DBG_CTOR(SdrModel,NULL);
237cdf0e10cSrcweir 	ImpCtor(pPool,pPers,sal_False, (FASTBOOL)bLoadRefCounts);
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
241cdf0e10cSrcweir 	maMaPag(1024,32,32),
242cdf0e10cSrcweir 	maPages(1024,32,32),
243cdf0e10cSrcweir 	aTablePath(rPath)
244cdf0e10cSrcweir {
245cdf0e10cSrcweir #ifdef TIMELOG
246cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
247cdf0e10cSrcweir #endif
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	DBG_CTOR(SdrModel,NULL);
250cdf0e10cSrcweir 	ImpCtor(pPool,pPers,sal_False, (FASTBOOL)bLoadRefCounts);
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, FASTBOOL bUseExtColorTable, sal_Bool bLoadRefCounts):
254cdf0e10cSrcweir 	maMaPag(1024,32,32),
255cdf0e10cSrcweir 	maPages(1024,32,32)
256cdf0e10cSrcweir {
257cdf0e10cSrcweir #ifdef TIMELOG
258cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
259cdf0e10cSrcweir #endif
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	DBG_CTOR(SdrModel,NULL);
262cdf0e10cSrcweir 	ImpCtor(pPool,pPers,bUseExtColorTable, (FASTBOOL)bLoadRefCounts);
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, FASTBOOL bUseExtColorTable, sal_Bool bLoadRefCounts):
266cdf0e10cSrcweir 	maMaPag(1024,32,32),
267cdf0e10cSrcweir 	maPages(1024,32,32),
268cdf0e10cSrcweir 	aTablePath(rPath)
269cdf0e10cSrcweir {
270cdf0e10cSrcweir #ifdef TIMELOG
271cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
272cdf0e10cSrcweir #endif
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 	DBG_CTOR(SdrModel,NULL);
275cdf0e10cSrcweir 	ImpCtor(pPool,pPers,bUseExtColorTable, (FASTBOOL)bLoadRefCounts);
276cdf0e10cSrcweir }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir SdrModel::SdrModel(const SdrModel& /*rSrcModel*/):
279cdf0e10cSrcweir 	SfxBroadcaster(),
280cdf0e10cSrcweir 	tools::WeakBase< SdrModel >(),
281cdf0e10cSrcweir 	maMaPag(1024,32,32),
282cdf0e10cSrcweir 	maPages(1024,32,32)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir #ifdef TIMELOG
285cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
286cdf0e10cSrcweir #endif
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	// noch nicht implementiert
289cdf0e10cSrcweir 	DBG_ERROR("SdrModel::CopyCtor() ist noch nicht implementiert");
290cdf0e10cSrcweir }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir SdrModel::~SdrModel()
293cdf0e10cSrcweir {
294cdf0e10cSrcweir #ifdef TIMELOG
295cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::~SdrModel(...)" );
296cdf0e10cSrcweir #endif
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	DBG_DTOR(SdrModel,NULL);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	mbInDestruction = true;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	Broadcast(SdrHint(HINT_MODELCLEARED));
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	delete mpOutlinerCache;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	ClearUndoBuffer();
307cdf0e10cSrcweir #ifdef DBG_UTIL
308cdf0e10cSrcweir 	if(pAktUndoGroup)
309cdf0e10cSrcweir 	{
310cdf0e10cSrcweir 		ByteString aStr("Im Dtor des SdrModel steht noch ein offenes Undo rum: \"");
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 		aStr += ByteString(pAktUndoGroup->GetComment(), gsl_getSystemTextEncoding());
313cdf0e10cSrcweir 		aStr += '\"';
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 		DBG_ERROR(aStr.GetBuffer());
316cdf0e10cSrcweir 	}
317cdf0e10cSrcweir #endif
318cdf0e10cSrcweir 	if (pAktUndoGroup!=NULL)
319cdf0e10cSrcweir 		delete pAktUndoGroup;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	// #116168#
322cdf0e10cSrcweir 	ClearModel(sal_True);
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	delete pLayerAdmin;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	// Den DrawOutliner erst nach dem ItemPool loeschen, da
327cdf0e10cSrcweir 	// der ItemPool Items des DrawOutliners referenziert !!! (<- das war mal)
328cdf0e10cSrcweir 	// Wg. Problem bei Malte Reihenfolge wieder umgestellt.
329cdf0e10cSrcweir 	// Loeschen des Outliners vor dem loeschen des ItemPools
330cdf0e10cSrcweir 	delete pHitTestOutliner;
331cdf0e10cSrcweir 	delete pDrawOutliner;
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	// delete StyleSheetPool, derived classes should not do this since
334cdf0e10cSrcweir 	// the DrawingEngine may need it in its destrctor (SB)
335cdf0e10cSrcweir 	if( mxStyleSheetPool.is() )
336cdf0e10cSrcweir 	{
337cdf0e10cSrcweir 		Reference< XComponent > xComponent( dynamic_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY );
338cdf0e10cSrcweir 		if( xComponent.is() ) try
339cdf0e10cSrcweir 		{
340cdf0e10cSrcweir 			xComponent->dispose();
341cdf0e10cSrcweir 		}
342cdf0e10cSrcweir 		catch( RuntimeException& )
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 		}
345cdf0e10cSrcweir 		mxStyleSheetPool.clear();
346cdf0e10cSrcweir 	}
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	if (bMyPool)
349cdf0e10cSrcweir 	{
350cdf0e10cSrcweir 		// Pools loeschen, falls es meine sind
351cdf0e10cSrcweir 		SfxItemPool* pOutlPool=pItemPool->GetSecondaryPool();
352cdf0e10cSrcweir         SfxItemPool::Free(pItemPool);
353cdf0e10cSrcweir 		// Der OutlinerPool muss nach dem ItemPool plattgemacht werden, da der
354cdf0e10cSrcweir 		// ItemPool SetItems enthaelt die ihrerseits Items des OutlinerPools
355cdf0e10cSrcweir 		// referenzieren (Joe)
356cdf0e10cSrcweir         SfxItemPool::Free(pOutlPool);
357cdf0e10cSrcweir 	}
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	if( mpForbiddenCharactersTable )
360cdf0e10cSrcweir 		mpForbiddenCharactersTable->release();
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	// Tabellen, Listen und Paletten loeschen
363cdf0e10cSrcweir 	if (!bExtColorTable)
364cdf0e10cSrcweir 		delete pColorTable;
365cdf0e10cSrcweir 	delete pDashList;
366cdf0e10cSrcweir 	delete pLineEndList;
367cdf0e10cSrcweir 	delete pHatchList;
368cdf0e10cSrcweir 	delete pGradientList;
369cdf0e10cSrcweir 	delete pBitmapList;
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	if(mpNumberFormatter)
372cdf0e10cSrcweir 		delete mpNumberFormatter;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 	delete mpImpl->mpUndoFactory;
375cdf0e10cSrcweir 	delete mpImpl;
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
378cdf0e10cSrcweir bool SdrModel::IsInDestruction() const
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	return mbInDestruction;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir const SvNumberFormatter& SdrModel::GetNumberFormatter() const
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 	if(!mpNumberFormatter)
386cdf0e10cSrcweir 	{
387cdf0e10cSrcweir 		// use cast here since from outside view this IS a const method
388cdf0e10cSrcweir 		((SdrModel*)this)->mpNumberFormatter = new SvNumberFormatter(
389cdf0e10cSrcweir 			::comphelper::getProcessServiceFactory(), LANGUAGE_SYSTEM);
390cdf0e10cSrcweir 	}
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	return *mpNumberFormatter;
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir // noch nicht implementiert:
396cdf0e10cSrcweir void SdrModel::operator=(const SdrModel& /*rSrcModel*/)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir 	DBG_ERROR("SdrModel::operator=() ist noch nicht implementiert");
399cdf0e10cSrcweir }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir FASTBOOL SdrModel::operator==(const SdrModel& /*rCmpModel*/) const
402cdf0e10cSrcweir {
403cdf0e10cSrcweir 	DBG_ERROR("SdrModel::operator==() ist noch nicht implementiert");
404cdf0e10cSrcweir 	return sal_False;
405cdf0e10cSrcweir }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir void SdrModel::SetSwapGraphics( FASTBOOL bSwap )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir 	bSwapGraphics = bSwap;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir FASTBOOL SdrModel::IsReadOnly() const
413cdf0e10cSrcweir {
414cdf0e10cSrcweir 	return bReadOnly;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir void SdrModel::SetReadOnly(FASTBOOL bYes)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir 	bReadOnly=bYes;
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
423cdf0e10cSrcweir 
424cdf0e10cSrcweir void SdrModel::SetMaxUndoActionCount(sal_uIntPtr nAnz)
425cdf0e10cSrcweir {
426cdf0e10cSrcweir 	if (nAnz<1) nAnz=1;
427cdf0e10cSrcweir 	nMaxUndoCount=nAnz;
428cdf0e10cSrcweir 	if (pUndoStack!=NULL) {
429cdf0e10cSrcweir 		while (pUndoStack->Count()>nMaxUndoCount) {
430cdf0e10cSrcweir 			delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count());
431cdf0e10cSrcweir 		}
432cdf0e10cSrcweir 	}
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir void SdrModel::ClearUndoBuffer()
436cdf0e10cSrcweir {
437cdf0e10cSrcweir 	if (pUndoStack!=NULL) {
438cdf0e10cSrcweir 		while (pUndoStack->Count()!=0) {
439cdf0e10cSrcweir 			delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()-1);
440cdf0e10cSrcweir 		}
441cdf0e10cSrcweir 		delete pUndoStack;
442cdf0e10cSrcweir 		pUndoStack=NULL;
443cdf0e10cSrcweir 	}
444cdf0e10cSrcweir 	if (pRedoStack!=NULL) {
445cdf0e10cSrcweir 		while (pRedoStack->Count()!=0) {
446cdf0e10cSrcweir 			delete (SfxUndoAction*) pRedoStack->Remove(pRedoStack->Count()-1);
447cdf0e10cSrcweir 		}
448cdf0e10cSrcweir 		delete pRedoStack;
449cdf0e10cSrcweir 		pRedoStack=NULL;
450cdf0e10cSrcweir 	}
451cdf0e10cSrcweir }
452cdf0e10cSrcweir 
453cdf0e10cSrcweir FASTBOOL SdrModel::Undo()
454cdf0e10cSrcweir {
455cdf0e10cSrcweir 	FASTBOOL bRet=sal_False;
456cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
457cdf0e10cSrcweir 	{
458cdf0e10cSrcweir 		DBG_ERROR("svx::SdrModel::Undo(), method not supported with application undo manager!");
459cdf0e10cSrcweir 	}
460cdf0e10cSrcweir 	else
461cdf0e10cSrcweir 	{
462cdf0e10cSrcweir 		SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
463cdf0e10cSrcweir 		if(pDo!=NULL)
464cdf0e10cSrcweir 		{
465cdf0e10cSrcweir 			const bool bWasUndoEnabled = mbUndoEnabled;
466cdf0e10cSrcweir 			mbUndoEnabled = false;
467cdf0e10cSrcweir 			pDo->Undo();
468cdf0e10cSrcweir 			if(pRedoStack==NULL)
469cdf0e10cSrcweir 				pRedoStack=new Container(1024,16,16);
470cdf0e10cSrcweir 			pRedoStack->Insert(pUndoStack->Remove((sal_uIntPtr)0),(sal_uIntPtr)0);
471cdf0e10cSrcweir 			mbUndoEnabled = bWasUndoEnabled;
472cdf0e10cSrcweir 		}
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir 	return bRet;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
477cdf0e10cSrcweir FASTBOOL SdrModel::Redo()
478cdf0e10cSrcweir {
479cdf0e10cSrcweir 	FASTBOOL bRet=sal_False;
480cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
481cdf0e10cSrcweir 	{
482cdf0e10cSrcweir 		DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!");
483cdf0e10cSrcweir 	}
484cdf0e10cSrcweir 	else
485cdf0e10cSrcweir 	{
486cdf0e10cSrcweir 		SfxUndoAction* pDo=(SfxUndoAction*)GetRedoAction(0);
487cdf0e10cSrcweir 		if(pDo!=NULL)
488cdf0e10cSrcweir 		{
489cdf0e10cSrcweir 			const bool bWasUndoEnabled = mbUndoEnabled;
490cdf0e10cSrcweir 			mbUndoEnabled = false;
491cdf0e10cSrcweir 			pDo->Redo();
492cdf0e10cSrcweir 			if(pUndoStack==NULL)
493cdf0e10cSrcweir 				pUndoStack=new Container(1024,16,16);
494cdf0e10cSrcweir 			pUndoStack->Insert(pRedoStack->Remove((sal_uIntPtr)0),(sal_uIntPtr)0);
495cdf0e10cSrcweir 			mbUndoEnabled = bWasUndoEnabled;
496cdf0e10cSrcweir 		}
497cdf0e10cSrcweir 	}
498cdf0e10cSrcweir 	return bRet;
499cdf0e10cSrcweir }
500cdf0e10cSrcweir 
501cdf0e10cSrcweir FASTBOOL SdrModel::Repeat(SfxRepeatTarget& rView)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir 	FASTBOOL bRet=sal_False;
504cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
505cdf0e10cSrcweir 	{
506cdf0e10cSrcweir 		DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!");
507cdf0e10cSrcweir 	}
508cdf0e10cSrcweir 	else
509cdf0e10cSrcweir 	{
510cdf0e10cSrcweir 		SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
511cdf0e10cSrcweir 		if(pDo!=NULL)
512cdf0e10cSrcweir 		{
513cdf0e10cSrcweir 			if(pDo->CanRepeat(rView))
514cdf0e10cSrcweir 			{
515cdf0e10cSrcweir 				pDo->Repeat(rView);
516cdf0e10cSrcweir 				bRet=sal_True;
517cdf0e10cSrcweir 			}
518cdf0e10cSrcweir 		}
519cdf0e10cSrcweir 	}
520cdf0e10cSrcweir 	return bRet;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir void SdrModel::ImpPostUndoAction(SdrUndoAction* pUndo)
524cdf0e10cSrcweir {
525cdf0e10cSrcweir 	DBG_ASSERT( mpImpl->mpUndoManager == 0, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" );
526cdf0e10cSrcweir 	if( IsUndoEnabled() )
527cdf0e10cSrcweir 	{
528cdf0e10cSrcweir 		if (aUndoLink.IsSet())
529cdf0e10cSrcweir 		{
530cdf0e10cSrcweir 			aUndoLink.Call(pUndo);
531cdf0e10cSrcweir 		}
532cdf0e10cSrcweir 		else
533cdf0e10cSrcweir 		{
534cdf0e10cSrcweir 			if (pUndoStack==NULL)
535cdf0e10cSrcweir 				pUndoStack=new Container(1024,16,16);
536cdf0e10cSrcweir 			pUndoStack->Insert(pUndo,(sal_uIntPtr)0);
537cdf0e10cSrcweir 			while (pUndoStack->Count()>nMaxUndoCount)
538cdf0e10cSrcweir 			{
539cdf0e10cSrcweir 				delete (SfxUndoAction*)pUndoStack->Remove(pUndoStack->Count()-1);
540cdf0e10cSrcweir 			}
541cdf0e10cSrcweir 			if (pRedoStack!=NULL)
542cdf0e10cSrcweir 				pRedoStack->Clear();
543cdf0e10cSrcweir 		}
544cdf0e10cSrcweir 	}
545cdf0e10cSrcweir 	else
546cdf0e10cSrcweir 	{
547cdf0e10cSrcweir 		delete pUndo;
548cdf0e10cSrcweir 	}
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir void SdrModel::BegUndo()
552cdf0e10cSrcweir {
553cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
554cdf0e10cSrcweir 	{
555cdf0e10cSrcweir 		const String aEmpty;
556cdf0e10cSrcweir 		mpImpl->mpUndoManager->EnterListAction(aEmpty,aEmpty);
557cdf0e10cSrcweir 		nUndoLevel++;
558cdf0e10cSrcweir 	}
559cdf0e10cSrcweir 	else if( IsUndoEnabled() )
560cdf0e10cSrcweir 	{
561cdf0e10cSrcweir 		if(pAktUndoGroup==NULL)
562cdf0e10cSrcweir 		{
563cdf0e10cSrcweir 			pAktUndoGroup = new SdrUndoGroup(*this);
564cdf0e10cSrcweir 			nUndoLevel=1;
565cdf0e10cSrcweir 		}
566cdf0e10cSrcweir 		else
567cdf0e10cSrcweir 		{
568cdf0e10cSrcweir 			nUndoLevel++;
569cdf0e10cSrcweir 		}
570cdf0e10cSrcweir 	}
571cdf0e10cSrcweir }
572cdf0e10cSrcweir 
573cdf0e10cSrcweir void SdrModel::BegUndo(const XubString& rComment)
574cdf0e10cSrcweir {
575cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		const String aEmpty;
578cdf0e10cSrcweir 		mpImpl->mpUndoManager->EnterListAction( rComment, aEmpty );
579cdf0e10cSrcweir 		nUndoLevel++;
580cdf0e10cSrcweir 	}
581cdf0e10cSrcweir 	else if( IsUndoEnabled() )
582cdf0e10cSrcweir 	{
583cdf0e10cSrcweir 		BegUndo();
584cdf0e10cSrcweir 		if (nUndoLevel==1)
585cdf0e10cSrcweir 		{
586cdf0e10cSrcweir 			pAktUndoGroup->SetComment(rComment);
587cdf0e10cSrcweir 		}
588cdf0e10cSrcweir 	}
589cdf0e10cSrcweir }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir void SdrModel::BegUndo(const XubString& rComment, const XubString& rObjDescr, SdrRepeatFunc eFunc)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
594cdf0e10cSrcweir 	{
595cdf0e10cSrcweir 		String aComment(rComment);
596cdf0e10cSrcweir 		if( aComment.Len() && rObjDescr.Len() )
597cdf0e10cSrcweir 		{
598cdf0e10cSrcweir 			String aSearchString(RTL_CONSTASCII_USTRINGPARAM("%1"));
599cdf0e10cSrcweir 			aComment.SearchAndReplace(aSearchString, rObjDescr);
600cdf0e10cSrcweir 		}
601cdf0e10cSrcweir 		const String aEmpty;
602cdf0e10cSrcweir 		mpImpl->mpUndoManager->EnterListAction( aComment,aEmpty );
603cdf0e10cSrcweir 		nUndoLevel++;
604cdf0e10cSrcweir 	}
605cdf0e10cSrcweir 	else if( IsUndoEnabled() )
606cdf0e10cSrcweir 	{
607cdf0e10cSrcweir 		BegUndo();
608cdf0e10cSrcweir 		if (nUndoLevel==1)
609cdf0e10cSrcweir 		{
610cdf0e10cSrcweir 			pAktUndoGroup->SetComment(rComment);
611cdf0e10cSrcweir 			pAktUndoGroup->SetObjDescription(rObjDescr);
612cdf0e10cSrcweir 			pAktUndoGroup->SetRepeatFunction(eFunc);
613cdf0e10cSrcweir 		}
614cdf0e10cSrcweir 	}
615cdf0e10cSrcweir }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir void SdrModel::BegUndo(SdrUndoGroup* pUndoGrp)
618cdf0e10cSrcweir {
619cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
620cdf0e10cSrcweir 	{
621cdf0e10cSrcweir 		DBG_ERROR("svx::SdrModel::BegUndo(), method not supported with application undo manager!" );
622cdf0e10cSrcweir 		nUndoLevel++;
623cdf0e10cSrcweir 	}
624cdf0e10cSrcweir 	else if( IsUndoEnabled() )
625cdf0e10cSrcweir 	{
626cdf0e10cSrcweir 		if (pAktUndoGroup==NULL)
627cdf0e10cSrcweir 		{
628cdf0e10cSrcweir 			pAktUndoGroup=pUndoGrp;
629cdf0e10cSrcweir 			nUndoLevel=1;
630cdf0e10cSrcweir 		}
631cdf0e10cSrcweir 		else
632cdf0e10cSrcweir 		{
633cdf0e10cSrcweir 			delete pUndoGrp;
634cdf0e10cSrcweir 			nUndoLevel++;
635cdf0e10cSrcweir 		}
636cdf0e10cSrcweir 	}
637cdf0e10cSrcweir 	else
638cdf0e10cSrcweir 	{
639cdf0e10cSrcweir 		delete pUndoGrp;
640cdf0e10cSrcweir 	}
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir void SdrModel::EndUndo()
644cdf0e10cSrcweir {
645cdf0e10cSrcweir 	DBG_ASSERT(nUndoLevel!=0,"SdrModel::EndUndo(): UndoLevel is already 0!");
646cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
647cdf0e10cSrcweir 	{
648cdf0e10cSrcweir 		if( nUndoLevel )
649cdf0e10cSrcweir 		{
650cdf0e10cSrcweir 			nUndoLevel--;
651cdf0e10cSrcweir 			mpImpl->mpUndoManager->LeaveListAction();
652cdf0e10cSrcweir 		}
653cdf0e10cSrcweir 	}
654cdf0e10cSrcweir 	else
655cdf0e10cSrcweir 	{
656cdf0e10cSrcweir 		if(pAktUndoGroup!=NULL && IsUndoEnabled())
657cdf0e10cSrcweir 		{
658cdf0e10cSrcweir 			nUndoLevel--;
659cdf0e10cSrcweir 			if(nUndoLevel==0)
660cdf0e10cSrcweir 			{
661cdf0e10cSrcweir 				if(pAktUndoGroup->GetActionCount()!=0)
662cdf0e10cSrcweir 				{
663cdf0e10cSrcweir 					SdrUndoAction* pUndo=pAktUndoGroup;
664cdf0e10cSrcweir 					pAktUndoGroup=NULL;
665cdf0e10cSrcweir 					ImpPostUndoAction(pUndo);
666cdf0e10cSrcweir 				}
667cdf0e10cSrcweir 				else
668cdf0e10cSrcweir 				{
669cdf0e10cSrcweir 					// was empty
670cdf0e10cSrcweir 					delete pAktUndoGroup;
671cdf0e10cSrcweir 					pAktUndoGroup=NULL;
672cdf0e10cSrcweir 				}
673cdf0e10cSrcweir 			}
674cdf0e10cSrcweir 		}
675cdf0e10cSrcweir 	}
676cdf0e10cSrcweir }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir void SdrModel::SetUndoComment(const XubString& rComment)
679cdf0e10cSrcweir {
680cdf0e10cSrcweir 	DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is on level 0!");
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
683cdf0e10cSrcweir 	{
684cdf0e10cSrcweir 		DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
685cdf0e10cSrcweir 	}
686cdf0e10cSrcweir 	else if( IsUndoEnabled() )
687cdf0e10cSrcweir 	{
688cdf0e10cSrcweir 		if(nUndoLevel==1)
689cdf0e10cSrcweir 		{
690cdf0e10cSrcweir 			pAktUndoGroup->SetComment(rComment);
691cdf0e10cSrcweir 		}
692cdf0e10cSrcweir 	}
693cdf0e10cSrcweir }
694cdf0e10cSrcweir 
695cdf0e10cSrcweir void SdrModel::SetUndoComment(const XubString& rComment, const XubString& rObjDescr)
696cdf0e10cSrcweir {
697cdf0e10cSrcweir 	DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is 0!");
698cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
699cdf0e10cSrcweir 	{
700cdf0e10cSrcweir 		DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
701cdf0e10cSrcweir 	}
702cdf0e10cSrcweir 	else
703cdf0e10cSrcweir 	{
704cdf0e10cSrcweir 		if (nUndoLevel==1)
705cdf0e10cSrcweir 		{
706cdf0e10cSrcweir 			pAktUndoGroup->SetComment(rComment);
707cdf0e10cSrcweir 			pAktUndoGroup->SetObjDescription(rObjDescr);
708cdf0e10cSrcweir 		}
709cdf0e10cSrcweir 	}
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir void SdrModel::AddUndo(SdrUndoAction* pUndo)
713cdf0e10cSrcweir {
714cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir 		mpImpl->mpUndoManager->AddUndoAction( pUndo );
717cdf0e10cSrcweir 	}
718cdf0e10cSrcweir 	else if( !IsUndoEnabled() )
719cdf0e10cSrcweir 	{
720cdf0e10cSrcweir 		delete pUndo;
721cdf0e10cSrcweir 	}
722cdf0e10cSrcweir 	else
723cdf0e10cSrcweir 	{
724cdf0e10cSrcweir 		if (pAktUndoGroup!=NULL)
725cdf0e10cSrcweir 		{
726cdf0e10cSrcweir 			pAktUndoGroup->AddAction(pUndo);
727cdf0e10cSrcweir 		}
728cdf0e10cSrcweir 		else
729cdf0e10cSrcweir 		{
730cdf0e10cSrcweir 			ImpPostUndoAction(pUndo);
731cdf0e10cSrcweir 		}
732cdf0e10cSrcweir 	}
733cdf0e10cSrcweir }
734cdf0e10cSrcweir 
735cdf0e10cSrcweir void SdrModel::EnableUndo( bool bEnable )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
738cdf0e10cSrcweir 	{
739cdf0e10cSrcweir 		mpImpl->mpUndoManager->EnableUndo( bEnable );
740cdf0e10cSrcweir 	}
741cdf0e10cSrcweir 	else
742cdf0e10cSrcweir 	{
743cdf0e10cSrcweir 		mbUndoEnabled = bEnable;
744cdf0e10cSrcweir 	}
745cdf0e10cSrcweir }
746cdf0e10cSrcweir 
747cdf0e10cSrcweir bool SdrModel::IsUndoEnabled() const
748cdf0e10cSrcweir {
749cdf0e10cSrcweir 	if( mpImpl->mpUndoManager )
750cdf0e10cSrcweir 	{
751cdf0e10cSrcweir 		return mpImpl->mpUndoManager->IsUndoEnabled();
752cdf0e10cSrcweir 	}
753cdf0e10cSrcweir 	else
754cdf0e10cSrcweir 	{
755cdf0e10cSrcweir 		return mbUndoEnabled;
756cdf0e10cSrcweir 	}
757cdf0e10cSrcweir }
758cdf0e10cSrcweir 
759cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
760cdf0e10cSrcweir 
761cdf0e10cSrcweir void SdrModel::ImpCreateTables()
762cdf0e10cSrcweir {
763cdf0e10cSrcweir 	// der Writer hat seinen eigenen ColorTable
764cdf0e10cSrcweir 	if (!bExtColorTable) pColorTable=new XColorTable(aTablePath,(XOutdevItemPool*)pItemPool);
765cdf0e10cSrcweir 	pDashList    =new XDashList    (aTablePath,(XOutdevItemPool*)pItemPool);
766cdf0e10cSrcweir 	pLineEndList =new XLineEndList (aTablePath,(XOutdevItemPool*)pItemPool);
767cdf0e10cSrcweir 	pHatchList   =new XHatchList   (aTablePath,(XOutdevItemPool*)pItemPool);
768cdf0e10cSrcweir 	pGradientList=new XGradientList(aTablePath,(XOutdevItemPool*)pItemPool);
769cdf0e10cSrcweir 	pBitmapList  =new XBitmapList  (aTablePath,(XOutdevItemPool*)pItemPool);
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
772cdf0e10cSrcweir // #116168#
773cdf0e10cSrcweir void SdrModel::ClearModel(sal_Bool bCalledFromDestructor)
774cdf0e10cSrcweir {
775cdf0e10cSrcweir 	if(bCalledFromDestructor)
776cdf0e10cSrcweir 	{
777cdf0e10cSrcweir 		mbInDestruction = true;
778cdf0e10cSrcweir 	}
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 	sal_Int32 i;
781cdf0e10cSrcweir 	// delete all drawing pages
782cdf0e10cSrcweir 	sal_Int32 nAnz=GetPageCount();
783cdf0e10cSrcweir 	for (i=nAnz-1; i>=0; i--)
784cdf0e10cSrcweir 	{
785cdf0e10cSrcweir 		DeletePage( (sal_uInt16)i );
786cdf0e10cSrcweir 	}
787cdf0e10cSrcweir 	maPages.Clear();
788cdf0e10cSrcweir 	// #109538#
789cdf0e10cSrcweir 	PageListChanged();
790cdf0e10cSrcweir 
791cdf0e10cSrcweir 	// delete all Masterpages
792cdf0e10cSrcweir 	nAnz=GetMasterPageCount();
793cdf0e10cSrcweir 	for(i=nAnz-1; i>=0; i--)
794cdf0e10cSrcweir 	{
795cdf0e10cSrcweir 		DeleteMasterPage( (sal_uInt16)i );
796cdf0e10cSrcweir 	}
797cdf0e10cSrcweir 	maMaPag.Clear();
798cdf0e10cSrcweir 	// #109538#
799cdf0e10cSrcweir 	MasterPageListChanged();
800cdf0e10cSrcweir 
801cdf0e10cSrcweir 	pLayerAdmin->ClearLayer();
802cdf0e10cSrcweir }
803cdf0e10cSrcweir 
804cdf0e10cSrcweir SdrModel* SdrModel::AllocModel() const
805cdf0e10cSrcweir {
806cdf0e10cSrcweir 	SdrModel* pModel=new SdrModel;
807cdf0e10cSrcweir 	pModel->SetScaleUnit(eObjUnit,aObjUnit);
808cdf0e10cSrcweir 	return pModel;
809cdf0e10cSrcweir }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir SdrPage* SdrModel::AllocPage(FASTBOOL bMasterPage)
812cdf0e10cSrcweir {
813cdf0e10cSrcweir 	return new SdrPage(*this,bMasterPage);
814cdf0e10cSrcweir }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir void SdrModel::SetTextDefaults() const
817cdf0e10cSrcweir {
818cdf0e10cSrcweir 	SetTextDefaults( pItemPool, nDefTextHgt );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir 
821cdf0e10cSrcweir void ImpGetDefaultFontsLanguage( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex)
822cdf0e10cSrcweir {
823cdf0e10cSrcweir 	const sal_uInt16 nItemCnt = 3;
824cdf0e10cSrcweir 	static struct {
825cdf0e10cSrcweir 		sal_uInt16 nFntType, nLanguage;
826cdf0e10cSrcweir 	}  aOutTypeArr[ nItemCnt ] = {
827cdf0e10cSrcweir 		{  DEFAULTFONT_LATIN_TEXT, LANGUAGE_ENGLISH_US },
828cdf0e10cSrcweir 		{  DEFAULTFONT_CJK_TEXT, LANGUAGE_ENGLISH_US },
829cdf0e10cSrcweir 		{  DEFAULTFONT_CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA }
830cdf0e10cSrcweir 	};
831cdf0e10cSrcweir 	SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex };
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 	for( sal_uInt16 n = 0; n < nItemCnt; ++n )
834cdf0e10cSrcweir 	{
835cdf0e10cSrcweir 		Font aFnt( OutputDevice::GetDefaultFont(
836cdf0e10cSrcweir 			aOutTypeArr[ n ].nFntType, aOutTypeArr[ n ].nLanguage,
837cdf0e10cSrcweir 			DEFAULTFONT_FLAGS_ONLYONE, 0 ));
838cdf0e10cSrcweir 		SvxFontItem* pI = aItemArr[ n ];
839cdf0e10cSrcweir         pI->SetFamily( aFnt.GetFamily());
840cdf0e10cSrcweir         pI->SetFamilyName( aFnt.GetName());
841cdf0e10cSrcweir         pI->SetStyleName( String() );
842cdf0e10cSrcweir         pI->SetPitch( aFnt.GetPitch());
843cdf0e10cSrcweir         pI->SetCharSet( aFnt.GetCharSet() );
844cdf0e10cSrcweir 	}
845cdf0e10cSrcweir }
846cdf0e10cSrcweir 
847cdf0e10cSrcweir void SdrModel::SetTextDefaults( SfxItemPool* pItemPool, sal_uIntPtr nDefTextHgt )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir 	// #95114# set application-language specific dynamic pool language defaults
850cdf0e10cSrcweir     SvxFontItem aSvxFontItem( EE_CHAR_FONTINFO) ;
851cdf0e10cSrcweir 	SvxFontItem aSvxFontItemCJK(EE_CHAR_FONTINFO_CJK);
852cdf0e10cSrcweir 	SvxFontItem aSvxFontItemCTL(EE_CHAR_FONTINFO_CTL);
853cdf0e10cSrcweir 	sal_uInt16 nLanguage(Application::GetSettings().GetLanguage());
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 	// get DEFAULTFONT_LATIN_TEXT and set at pool as dynamic default
856cdf0e10cSrcweir 	Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
857cdf0e10cSrcweir     aSvxFontItem.SetFamily(aFont.GetFamily());
858cdf0e10cSrcweir     aSvxFontItem.SetFamilyName(aFont.GetName());
859cdf0e10cSrcweir     aSvxFontItem.SetStyleName(String());
860cdf0e10cSrcweir     aSvxFontItem.SetPitch( aFont.GetPitch());
861cdf0e10cSrcweir     aSvxFontItem.SetCharSet( aFont.GetCharSet() );
862cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem(aSvxFontItem);
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 	// get DEFAULTFONT_CJK_TEXT and set at pool as dynamic default
865cdf0e10cSrcweir 	Font aFontCJK(OutputDevice::GetDefaultFont(DEFAULTFONT_CJK_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
866cdf0e10cSrcweir     aSvxFontItemCJK.SetFamily( aFontCJK.GetFamily());
867cdf0e10cSrcweir     aSvxFontItemCJK.SetFamilyName(aFontCJK.GetName());
868cdf0e10cSrcweir     aSvxFontItemCJK.SetStyleName(String());
869cdf0e10cSrcweir     aSvxFontItemCJK.SetPitch( aFontCJK.GetPitch());
870cdf0e10cSrcweir     aSvxFontItemCJK.SetCharSet( aFontCJK.GetCharSet());
871cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem(aSvxFontItemCJK);
872cdf0e10cSrcweir 
873cdf0e10cSrcweir 	// get DEFAULTFONT_CTL_TEXT and set at pool as dynamic default
874cdf0e10cSrcweir 	Font aFontCTL(OutputDevice::GetDefaultFont(DEFAULTFONT_CTL_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
875cdf0e10cSrcweir     aSvxFontItemCTL.SetFamily(aFontCTL.GetFamily());
876cdf0e10cSrcweir     aSvxFontItemCTL.SetFamilyName(aFontCTL.GetName());
877cdf0e10cSrcweir     aSvxFontItemCTL.SetStyleName(String());
878cdf0e10cSrcweir     aSvxFontItemCTL.SetPitch( aFontCTL.GetPitch() );
879cdf0e10cSrcweir     aSvxFontItemCTL.SetCharSet( aFontCTL.GetCharSet());
880cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem(aSvxFontItemCTL);
881cdf0e10cSrcweir 
882cdf0e10cSrcweir 	// set dynamic FontHeight defaults
883cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT ) );
884cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
885cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 	// set FontColor defaults
888cdf0e10cSrcweir     pItemPool->SetPoolDefaultItem( SvxColorItem(SdrEngineDefaults::GetFontColor(), EE_CHAR_COLOR) );
889cdf0e10cSrcweir }
890cdf0e10cSrcweir 
891cdf0e10cSrcweir SdrOutliner& SdrModel::GetDrawOutliner(const SdrTextObj* pObj) const
892cdf0e10cSrcweir {
893cdf0e10cSrcweir 	pDrawOutliner->SetTextObj(pObj);
894cdf0e10cSrcweir 	return *pDrawOutliner;
895cdf0e10cSrcweir }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir boost::shared_ptr< SdrOutliner > SdrModel::CreateDrawOutliner(const SdrTextObj* pObj)
898cdf0e10cSrcweir {
899cdf0e10cSrcweir 	boost::shared_ptr< SdrOutliner > xDrawOutliner( SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this ) );
900cdf0e10cSrcweir 	ImpSetOutlinerDefaults(xDrawOutliner.get(), sal_True);
901cdf0e10cSrcweir 	xDrawOutliner->SetTextObj(pObj);
902cdf0e10cSrcweir 	return xDrawOutliner;
903cdf0e10cSrcweir }
904cdf0e10cSrcweir 
905cdf0e10cSrcweir const SdrTextObj* SdrModel::GetFormattingTextObj() const
906cdf0e10cSrcweir {
907cdf0e10cSrcweir 	if (pDrawOutliner!=NULL) {
908cdf0e10cSrcweir 		return pDrawOutliner->GetTextObj();
909cdf0e10cSrcweir 	}
910cdf0e10cSrcweir 	return NULL;
911cdf0e10cSrcweir }
912cdf0e10cSrcweir 
913cdf0e10cSrcweir void SdrModel::ImpSetOutlinerDefaults( SdrOutliner* pOutliner, sal_Bool bInit )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir 	/**************************************************************************
916cdf0e10cSrcweir 	* Initialisierung der Outliner fuer Textausgabe und HitTest
917cdf0e10cSrcweir 	**************************************************************************/
918cdf0e10cSrcweir 	if( bInit )
919cdf0e10cSrcweir 	{
920cdf0e10cSrcweir 		pOutliner->EraseVirtualDevice();
921cdf0e10cSrcweir 		pOutliner->SetUpdateMode(sal_False);
922cdf0e10cSrcweir 		pOutliner->SetEditTextObjectPool(pItemPool);
923cdf0e10cSrcweir 		pOutliner->SetDefTab(nDefaultTabulator);
924cdf0e10cSrcweir 	}
925cdf0e10cSrcweir 
926cdf0e10cSrcweir 	pOutliner->SetRefDevice(GetRefDevice());
927cdf0e10cSrcweir 	pOutliner->SetForbiddenCharsTable(GetForbiddenCharsTable());
928cdf0e10cSrcweir 	pOutliner->SetAsianCompressionMode( mnCharCompressType );
929cdf0e10cSrcweir 	pOutliner->SetKernAsianPunctuation( IsKernAsianPunctuation() );
930cdf0e10cSrcweir     pOutliner->SetAddExtLeading( IsAddExtLeading() );
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 	if ( !GetRefDevice() )
933cdf0e10cSrcweir 	{
934cdf0e10cSrcweir 		MapMode aMapMode(eObjUnit, Point(0,0), aObjUnit, aObjUnit);
935cdf0e10cSrcweir 		pOutliner->SetRefMapMode(aMapMode);
936cdf0e10cSrcweir 	}
937cdf0e10cSrcweir }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir void SdrModel::SetRefDevice(OutputDevice* pDev)
940cdf0e10cSrcweir {
941cdf0e10cSrcweir 	pRefOutDev=pDev;
942cdf0e10cSrcweir 	ImpSetOutlinerDefaults( pDrawOutliner );
943cdf0e10cSrcweir 	ImpSetOutlinerDefaults( pHitTestOutliner );
944cdf0e10cSrcweir 	RefDeviceChanged();
945cdf0e10cSrcweir }
946cdf0e10cSrcweir 
947cdf0e10cSrcweir void SdrModel::ImpReformatAllTextObjects()
948cdf0e10cSrcweir {
949cdf0e10cSrcweir 	if( isLocked() )
950cdf0e10cSrcweir 		return;
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 	sal_uInt16 nAnz=GetMasterPageCount();
953cdf0e10cSrcweir 	sal_uInt16 nNum;
954cdf0e10cSrcweir 	for (nNum=0; nNum<nAnz; nNum++) {
955cdf0e10cSrcweir 		GetMasterPage(nNum)->ReformatAllTextObjects();
956cdf0e10cSrcweir 	}
957cdf0e10cSrcweir 	nAnz=GetPageCount();
958cdf0e10cSrcweir 	for (nNum=0; nNum<nAnz; nNum++) {
959cdf0e10cSrcweir 		GetPage(nNum)->ReformatAllTextObjects();
960cdf0e10cSrcweir 	}
961cdf0e10cSrcweir }
962cdf0e10cSrcweir 
963cdf0e10cSrcweir /** #103122#
964cdf0e10cSrcweir 	steps over all available pages and sends notify messages to
965cdf0e10cSrcweir 	all edge objects that are connected to other objects so that
966cdf0e10cSrcweir 	they may reposition itselfs
967cdf0e10cSrcweir */
968cdf0e10cSrcweir void SdrModel::ImpReformatAllEdgeObjects()
969cdf0e10cSrcweir {
970cdf0e10cSrcweir 	if( isLocked() )
971cdf0e10cSrcweir 		return;
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	sal_uInt16 nAnz=GetMasterPageCount();
974cdf0e10cSrcweir 	sal_uInt16 nNum;
975cdf0e10cSrcweir 	for (nNum=0; nNum<nAnz; nNum++)
976cdf0e10cSrcweir 	{
977cdf0e10cSrcweir 		GetMasterPage(nNum)->ReformatAllEdgeObjects();
978cdf0e10cSrcweir 	}
979cdf0e10cSrcweir 	nAnz=GetPageCount();
980cdf0e10cSrcweir 	for (nNum=0; nNum<nAnz; nNum++)
981cdf0e10cSrcweir 	{
982cdf0e10cSrcweir 		GetPage(nNum)->ReformatAllEdgeObjects();
983cdf0e10cSrcweir 	}
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
986cdf0e10cSrcweir SvStream* SdrModel::GetDocumentStream(SdrDocumentStreamInfo& /*rStreamInfo*/) const
987cdf0e10cSrcweir {
988cdf0e10cSrcweir 	return NULL;
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir // Die Vorlagenattribute der Zeichenobjekte in harte Attribute verwandeln.
992cdf0e10cSrcweir void SdrModel::BurnInStyleSheetAttributes()
993cdf0e10cSrcweir {
994cdf0e10cSrcweir 	sal_uInt16 nAnz=GetMasterPageCount();
995cdf0e10cSrcweir 	sal_uInt16 nNum;
996cdf0e10cSrcweir 	for (nNum=0; nNum<nAnz; nNum++) {
997cdf0e10cSrcweir 		GetMasterPage(nNum)->BurnInStyleSheetAttributes();
998cdf0e10cSrcweir 	}
999cdf0e10cSrcweir 	nAnz=GetPageCount();
1000cdf0e10cSrcweir 	for (nNum=0; nNum<nAnz; nNum++) {
1001cdf0e10cSrcweir 		GetPage(nNum)->BurnInStyleSheetAttributes();
1002cdf0e10cSrcweir 	}
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir void SdrModel::RefDeviceChanged()
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir 	Broadcast(SdrHint(HINT_REFDEVICECHG));
1008cdf0e10cSrcweir 	ImpReformatAllTextObjects();
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir void SdrModel::SetDefaultFontHeight(sal_uIntPtr nVal)
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir 	if (nVal!=nDefTextHgt) {
1014cdf0e10cSrcweir 		nDefTextHgt=nVal;
1015cdf0e10cSrcweir 		Broadcast(SdrHint(HINT_DEFFONTHGTCHG));
1016cdf0e10cSrcweir 		ImpReformatAllTextObjects();
1017cdf0e10cSrcweir 	}
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir void SdrModel::SetDefaultTabulator(sal_uInt16 nVal)
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir 	if (nDefaultTabulator!=nVal) {
1023cdf0e10cSrcweir 		nDefaultTabulator=nVal;
1024cdf0e10cSrcweir 		Outliner& rOutliner=GetDrawOutliner();
1025cdf0e10cSrcweir 		rOutliner.SetDefTab(nVal);
1026cdf0e10cSrcweir 		Broadcast(SdrHint(HINT_DEFAULTTABCHG));
1027cdf0e10cSrcweir 		ImpReformatAllTextObjects();
1028cdf0e10cSrcweir 	}
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir void SdrModel::ImpSetUIUnit()
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir 	if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator())
1034cdf0e10cSrcweir     {
1035cdf0e10cSrcweir         aUIScale = Fraction(1,1);
1036cdf0e10cSrcweir     }
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir     // set start values
1039cdf0e10cSrcweir 	nUIUnitKomma = 0;
1040cdf0e10cSrcweir 	sal_Int64 nMul(1);
1041cdf0e10cSrcweir 	sal_Int64 nDiv(1);
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 	// normalize on meters resp. inch
1044cdf0e10cSrcweir 	switch (eObjUnit)
1045cdf0e10cSrcweir     {
1046cdf0e10cSrcweir 		case MAP_100TH_MM   : nUIUnitKomma+=5; break;
1047cdf0e10cSrcweir 		case MAP_10TH_MM    : nUIUnitKomma+=4; break;
1048cdf0e10cSrcweir 		case MAP_MM         : nUIUnitKomma+=3; break;
1049cdf0e10cSrcweir 		case MAP_CM         : nUIUnitKomma+=2; break;
1050cdf0e10cSrcweir 		case MAP_1000TH_INCH: nUIUnitKomma+=3; break;
1051cdf0e10cSrcweir 		case MAP_100TH_INCH : nUIUnitKomma+=2; break;
1052cdf0e10cSrcweir 		case MAP_10TH_INCH  : nUIUnitKomma+=1; break;
1053cdf0e10cSrcweir 		case MAP_INCH       : nUIUnitKomma+=0; break;
1054cdf0e10cSrcweir 		case MAP_POINT      : nDiv=72;     break;          // 1Pt   = 1/72"
1055cdf0e10cSrcweir 		case MAP_TWIP       : nDiv=144; nUIUnitKomma++; break; // 1Twip = 1/1440"
1056cdf0e10cSrcweir 		case MAP_PIXEL      : break;
1057cdf0e10cSrcweir 		case MAP_SYSFONT    : break;
1058cdf0e10cSrcweir 		case MAP_APPFONT    : break;
1059cdf0e10cSrcweir 		case MAP_RELATIVE   : break;
1060cdf0e10cSrcweir 		default: break;
1061cdf0e10cSrcweir 	} // switch
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir 	// 1 mile    =  8 furlong = 63.360" = 1.609.344,0mm
1064cdf0e10cSrcweir 	// 1 furlong = 10 chains  =  7.920" =   201.168,0mm
1065cdf0e10cSrcweir 	// 1 chain   =  4 poles   =    792" =    20.116,8mm
1066cdf0e10cSrcweir 	// 1 pole    =  5 1/2 yd  =    198" =     5.029,2mm
1067cdf0e10cSrcweir 	// 1 yd      =  3 ft      =     36" =       914,4mm
1068cdf0e10cSrcweir 	// 1 ft      = 12 "       =      1" =       304,8mm
1069cdf0e10cSrcweir 	switch (eUIUnit)
1070cdf0e10cSrcweir     {
1071cdf0e10cSrcweir 		case FUNIT_NONE   : break;
1072cdf0e10cSrcweir 		// Metrisch
1073cdf0e10cSrcweir 		case FUNIT_100TH_MM: nUIUnitKomma-=5; break;
1074cdf0e10cSrcweir 		case FUNIT_MM     : nUIUnitKomma-=3; break;
1075cdf0e10cSrcweir 		case FUNIT_CM     : nUIUnitKomma-=2; break;
1076cdf0e10cSrcweir 		case FUNIT_M      : nUIUnitKomma+=0; break;
1077cdf0e10cSrcweir 		case FUNIT_KM     : nUIUnitKomma+=3; break;
1078cdf0e10cSrcweir 		// Inch
1079cdf0e10cSrcweir 		case FUNIT_TWIP   : nMul=144; nUIUnitKomma--;  break;  // 1Twip = 1/1440"
1080cdf0e10cSrcweir 		case FUNIT_POINT  : nMul=72;     break;            // 1Pt   = 1/72"
1081cdf0e10cSrcweir 		case FUNIT_PICA   : nMul=6;      break;            // 1Pica = 1/6"  ?
1082cdf0e10cSrcweir 		case FUNIT_INCH   : break;                         // 1"    = 1"
1083cdf0e10cSrcweir 		case FUNIT_FOOT   : nDiv*=12;    break;            // 1Ft   = 12"
1084cdf0e10cSrcweir 		case FUNIT_MILE   : nDiv*=6336; nUIUnitKomma++; break; // 1mile = 63360"
1085cdf0e10cSrcweir 		// sonstiges
1086cdf0e10cSrcweir 		case FUNIT_CUSTOM : break;
1087cdf0e10cSrcweir 		case FUNIT_PERCENT: nUIUnitKomma+=2; break;
1088cdf0e10cSrcweir 	} // switch
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir     // check if mapping is from metric to inch and adapt
1091cdf0e10cSrcweir 	const bool bMapInch(IsInch(eObjUnit));
1092cdf0e10cSrcweir 	const bool bUIMetr(IsMetric(eUIUnit));
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir     if (bMapInch && bUIMetr)
1095cdf0e10cSrcweir     {
1096cdf0e10cSrcweir 		nUIUnitKomma += 4;
1097cdf0e10cSrcweir 		nMul *= 254;
1098cdf0e10cSrcweir 	}
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir     // check if mapping is from inch to metric and adapt
1101cdf0e10cSrcweir 	const bool bMapMetr(IsMetric(eObjUnit));
1102cdf0e10cSrcweir 	const bool bUIInch(IsInch(eUIUnit));
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir     if (bMapMetr && bUIInch)
1105cdf0e10cSrcweir     {
1106cdf0e10cSrcweir 		nUIUnitKomma -= 4;
1107cdf0e10cSrcweir 		nDiv *= 254;
1108cdf0e10cSrcweir 	}
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir 	// use temporary fraction for reduction (fallback to 32bit here),
1111cdf0e10cSrcweir     // may need to be changed in the future, too
1112cdf0e10cSrcweir     if(1 != nMul || 1 != nDiv)
1113cdf0e10cSrcweir     {
1114cdf0e10cSrcweir         const Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv));
1115cdf0e10cSrcweir         nMul = aTemp.GetNumerator();
1116cdf0e10cSrcweir         nDiv = aTemp.GetDenominator();
1117cdf0e10cSrcweir     }
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir     // #i89872# take Unit of Measurement into account
1120cdf0e10cSrcweir     if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator())
1121cdf0e10cSrcweir     {
1122cdf0e10cSrcweir         // divide by UIScale
1123cdf0e10cSrcweir 	    nMul *= aUIScale.GetDenominator();
1124cdf0e10cSrcweir 	    nDiv *= aUIScale.GetNumerator();
1125cdf0e10cSrcweir     }
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir     // shorten trailing zeroes for dividend
1128cdf0e10cSrcweir     while(0 == (nMul % 10))
1129cdf0e10cSrcweir     {
1130cdf0e10cSrcweir 	    nUIUnitKomma--;
1131cdf0e10cSrcweir 	    nMul /= 10;
1132cdf0e10cSrcweir     }
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir     // shorten trailing zeroes for divisor
1135cdf0e10cSrcweir     while(0 == (nDiv % 10))
1136cdf0e10cSrcweir     {
1137cdf0e10cSrcweir 	    nUIUnitKomma++;
1138cdf0e10cSrcweir 	    nDiv /= 10;
1139cdf0e10cSrcweir     }
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir     // end preparations, set member values
1142cdf0e10cSrcweir     aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv));
1143cdf0e10cSrcweir 	bUIOnlyKomma = (nMul == nDiv);
1144cdf0e10cSrcweir 	TakeUnitStr(eUIUnit, aUIUnitStr);
1145cdf0e10cSrcweir }
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac)
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir 	if (eObjUnit!=eMap || aObjUnit!=rFrac) {
1150cdf0e10cSrcweir 		eObjUnit=eMap;
1151cdf0e10cSrcweir 		aObjUnit=rFrac;
1152cdf0e10cSrcweir 		pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
1153cdf0e10cSrcweir 		ImpSetUIUnit();
1154cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pDrawOutliner );
1155cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pHitTestOutliner );
1156cdf0e10cSrcweir 		ImpReformatAllTextObjects(); // #40424#
1157cdf0e10cSrcweir 	}
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir void SdrModel::SetScaleUnit(MapUnit eMap)
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir 	if (eObjUnit!=eMap) {
1163cdf0e10cSrcweir 		eObjUnit=eMap;
1164cdf0e10cSrcweir 		pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
1165cdf0e10cSrcweir 		ImpSetUIUnit();
1166cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pDrawOutliner );
1167cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pHitTestOutliner );
1168cdf0e10cSrcweir 		ImpReformatAllTextObjects(); // #40424#
1169cdf0e10cSrcweir 	}
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir void SdrModel::SetScaleFraction(const Fraction& rFrac)
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir 	if (aObjUnit!=rFrac) {
1175cdf0e10cSrcweir 		aObjUnit=rFrac;
1176cdf0e10cSrcweir 		ImpSetUIUnit();
1177cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pDrawOutliner );
1178cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pHitTestOutliner );
1179cdf0e10cSrcweir 		ImpReformatAllTextObjects(); // #40424#
1180cdf0e10cSrcweir 	}
1181cdf0e10cSrcweir }
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir void SdrModel::SetUIUnit(FieldUnit eUnit)
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir 	if (eUIUnit!=eUnit) {
1186cdf0e10cSrcweir 		eUIUnit=eUnit;
1187cdf0e10cSrcweir 		ImpSetUIUnit();
1188cdf0e10cSrcweir 		ImpReformatAllTextObjects(); // #40424#
1189cdf0e10cSrcweir 	}
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir void SdrModel::SetUIScale(const Fraction& rScale)
1193cdf0e10cSrcweir {
1194cdf0e10cSrcweir 	if (aUIScale!=rScale) {
1195cdf0e10cSrcweir 		aUIScale=rScale;
1196cdf0e10cSrcweir 		ImpSetUIUnit();
1197cdf0e10cSrcweir 		ImpReformatAllTextObjects(); // #40424#
1198cdf0e10cSrcweir 	}
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale)
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir 	if (eUIUnit!=eUnit || aUIScale!=rScale) {
1204cdf0e10cSrcweir 		eUIUnit=eUnit;
1205cdf0e10cSrcweir 		aUIScale=rScale;
1206cdf0e10cSrcweir 		ImpSetUIUnit();
1207cdf0e10cSrcweir 		ImpReformatAllTextObjects(); // #40424#
1208cdf0e10cSrcweir 	}
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir void SdrModel::TakeUnitStr(FieldUnit eUnit, XubString& rStr)
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir 	switch(eUnit)
1214cdf0e10cSrcweir 	{
1215cdf0e10cSrcweir 		default:
1216cdf0e10cSrcweir 		case FUNIT_NONE   :
1217cdf0e10cSrcweir 		case FUNIT_CUSTOM :
1218cdf0e10cSrcweir 		{
1219cdf0e10cSrcweir 			rStr = String();
1220cdf0e10cSrcweir 			break;
1221cdf0e10cSrcweir 		}
1222cdf0e10cSrcweir 		case FUNIT_100TH_MM:
1223cdf0e10cSrcweir 		{
1224cdf0e10cSrcweir 			sal_Char aText[] = "/100mm";
1225cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1226cdf0e10cSrcweir 			break;
1227cdf0e10cSrcweir 		}
1228cdf0e10cSrcweir 		case FUNIT_MM     :
1229cdf0e10cSrcweir 		{
1230cdf0e10cSrcweir 			sal_Char aText[] = "mm";
1231cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1232cdf0e10cSrcweir 			break;
1233cdf0e10cSrcweir 		}
1234cdf0e10cSrcweir 		case FUNIT_CM     :
1235cdf0e10cSrcweir 		{
1236cdf0e10cSrcweir 			sal_Char aText[] = "cm";
1237cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1238cdf0e10cSrcweir 			break;
1239cdf0e10cSrcweir 		}
1240cdf0e10cSrcweir 		case FUNIT_M      :
1241cdf0e10cSrcweir 		{
1242cdf0e10cSrcweir 			rStr = String();
1243cdf0e10cSrcweir 			rStr += sal_Unicode('m');
1244cdf0e10cSrcweir 			break;
1245cdf0e10cSrcweir 		}
1246cdf0e10cSrcweir 		case FUNIT_KM     :
1247cdf0e10cSrcweir 		{
1248cdf0e10cSrcweir 			sal_Char aText[] = "km";
1249cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1250cdf0e10cSrcweir 			break;
1251cdf0e10cSrcweir 		}
1252cdf0e10cSrcweir 		case FUNIT_TWIP   :
1253cdf0e10cSrcweir 		{
1254cdf0e10cSrcweir 			sal_Char aText[] = "twip";
1255cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1256cdf0e10cSrcweir 			break;
1257cdf0e10cSrcweir 		}
1258cdf0e10cSrcweir 		case FUNIT_POINT  :
1259cdf0e10cSrcweir 		{
1260cdf0e10cSrcweir 			sal_Char aText[] = "pt";
1261cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1262cdf0e10cSrcweir 			break;
1263cdf0e10cSrcweir 		}
1264cdf0e10cSrcweir 		case FUNIT_PICA   :
1265cdf0e10cSrcweir 		{
1266cdf0e10cSrcweir 			sal_Char aText[] = "pica";
1267cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1268cdf0e10cSrcweir 			break;
1269cdf0e10cSrcweir 		}
1270cdf0e10cSrcweir 		case FUNIT_INCH   :
1271cdf0e10cSrcweir 		{
1272cdf0e10cSrcweir 			rStr = String();
1273cdf0e10cSrcweir 			rStr += sal_Unicode('"');
1274cdf0e10cSrcweir 			break;
1275cdf0e10cSrcweir 		}
1276cdf0e10cSrcweir 		case FUNIT_FOOT   :
1277cdf0e10cSrcweir 		{
1278cdf0e10cSrcweir 			sal_Char aText[] = "ft";
1279cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1280cdf0e10cSrcweir 			break;
1281cdf0e10cSrcweir 		}
1282cdf0e10cSrcweir 		case FUNIT_MILE   :
1283cdf0e10cSrcweir 		{
1284cdf0e10cSrcweir 			sal_Char aText[] = "mile(s)";
1285cdf0e10cSrcweir 			rStr = UniString(aText, sizeof(aText-1));
1286cdf0e10cSrcweir 			break;
1287cdf0e10cSrcweir 		}
1288cdf0e10cSrcweir 		case FUNIT_PERCENT:
1289cdf0e10cSrcweir 		{
1290cdf0e10cSrcweir 			rStr = String();
1291cdf0e10cSrcweir 			rStr += sal_Unicode('%');
1292cdf0e10cSrcweir 			break;
1293cdf0e10cSrcweir 		}
1294cdf0e10cSrcweir 	}
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir void SdrModel::TakeMetricStr(long nVal, XubString& rStr, FASTBOOL bNoUnitChars, sal_Int32 nNumDigits) const
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir 	// #i22167#
1300cdf0e10cSrcweir 	// change to double precision usage to not loose decimal places after comma
1301cdf0e10cSrcweir 	const bool bNegative(nVal < 0L);
1302cdf0e10cSrcweir     SvtSysLocale aSysLoc;
1303cdf0e10cSrcweir     const LocaleDataWrapper& rLoc(aSysLoc.GetLocaleData());
1304cdf0e10cSrcweir 	double fLocalValue(double(nVal) * double(aUIUnitFact));
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir 	if(bNegative)
1307cdf0e10cSrcweir 	{
1308cdf0e10cSrcweir 		fLocalValue = -fLocalValue;
1309cdf0e10cSrcweir 	}
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir 	if( -1 == nNumDigits )
1312cdf0e10cSrcweir 	{
1313cdf0e10cSrcweir 		nNumDigits = rLoc.getNumDigits();
1314cdf0e10cSrcweir 	}
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir 	sal_Int32 nKomma(nUIUnitKomma);
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir 	if(nKomma > nNumDigits)
1319cdf0e10cSrcweir 	{
1320cdf0e10cSrcweir 		const sal_Int32 nDiff(nKomma - nNumDigits);
1321cdf0e10cSrcweir 		const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir 		fLocalValue /= fFactor;
1324cdf0e10cSrcweir 		nKomma = nNumDigits;
1325cdf0e10cSrcweir 	}
1326cdf0e10cSrcweir 	else if(nKomma < nNumDigits)
1327cdf0e10cSrcweir 	{
1328cdf0e10cSrcweir 		const sal_Int32 nDiff(nNumDigits - nKomma);
1329cdf0e10cSrcweir 		const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir 		fLocalValue *= fFactor;
1332cdf0e10cSrcweir 		nKomma = nNumDigits;
1333cdf0e10cSrcweir 	}
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir 	rStr = UniString::CreateFromInt32(static_cast<sal_Int32>(fLocalValue + 0.5));
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir 	if(nKomma < 0)
1338cdf0e10cSrcweir 	{
1339cdf0e10cSrcweir 		// Negatives Komma bedeutet: Nullen dran
1340cdf0e10cSrcweir 		sal_Int32 nAnz(-nKomma);
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir 		for(sal_Int32 i=0; i<nAnz; i++)
1343cdf0e10cSrcweir 			rStr += sal_Unicode('0');
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir 		nKomma = 0;
1346cdf0e10cSrcweir 	}
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir 	// #83257# the second condition needs to be <= since inside this loop
1349cdf0e10cSrcweir 	// also the leading zero is inserted.
1350cdf0e10cSrcweir 	if(nKomma > 0 && rStr.Len() <= nKomma)
1351cdf0e10cSrcweir 	{
1352cdf0e10cSrcweir 		// Fuer Komma evtl. vorne Nullen dran
1353cdf0e10cSrcweir 		sal_Int32 nAnz(nKomma - rStr.Len());
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir         if(nAnz >= 0 && rLoc.isNumLeadingZero())
1356cdf0e10cSrcweir 			nAnz++;
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir 		for(sal_Int32 i=0; i<nAnz; i++)
1359cdf0e10cSrcweir 			rStr.Insert(sal_Unicode('0'), 0);
1360cdf0e10cSrcweir 	}
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir     sal_Unicode cDec( rLoc.getNumDecimalSep().GetChar(0) );
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir 	// KommaChar einfuegen
1365cdf0e10cSrcweir 	sal_Int32 nVorKomma(rStr.Len() - nKomma);
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 	if(nKomma > 0)
1368cdf0e10cSrcweir         rStr.Insert(cDec, (xub_StrLen) nVorKomma);
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir     if(!rLoc.isNumTrailingZeros())
1371cdf0e10cSrcweir 	{
1372cdf0e10cSrcweir 		while(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == sal_Unicode('0'))
1373cdf0e10cSrcweir 			rStr.Erase(rStr.Len() - 1);
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 		if(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == cDec)
1376cdf0e10cSrcweir 			rStr.Erase(rStr.Len() - 1);
1377cdf0e10cSrcweir 	}
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir 	// ggf. Trennpunkte bei jedem Tausender einfuegen
1380cdf0e10cSrcweir     if( nVorKomma > 3 )
1381cdf0e10cSrcweir 	{
1382cdf0e10cSrcweir         String aThoSep( rLoc.getNumThousandSep() );
1383cdf0e10cSrcweir         if ( aThoSep.Len() > 0 )
1384cdf0e10cSrcweir         {
1385cdf0e10cSrcweir             sal_Unicode cTho( aThoSep.GetChar(0) );
1386cdf0e10cSrcweir             sal_Int32 i(nVorKomma - 3);
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir             while(i > 0) // #78311#
1389cdf0e10cSrcweir             {
1390cdf0e10cSrcweir                 rStr.Insert(cTho, (xub_StrLen)i);
1391cdf0e10cSrcweir                 i -= 3;
1392cdf0e10cSrcweir             }
1393cdf0e10cSrcweir         }
1394cdf0e10cSrcweir 	}
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir 	if(!rStr.Len())
1397cdf0e10cSrcweir 	{
1398cdf0e10cSrcweir 		rStr = String();
1399cdf0e10cSrcweir 		rStr += sal_Unicode('0');
1400cdf0e10cSrcweir 	}
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir 	if(bNegative)
1403cdf0e10cSrcweir 	{
1404cdf0e10cSrcweir 		rStr.Insert(sal_Unicode('-'), 0);
1405cdf0e10cSrcweir 	}
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 	if(!bNoUnitChars)
1408cdf0e10cSrcweir 		rStr += aUIUnitStr;
1409cdf0e10cSrcweir }
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir void SdrModel::TakeWinkStr(long nWink, XubString& rStr, FASTBOOL bNoDegChar) const
1412cdf0e10cSrcweir {
1413cdf0e10cSrcweir 	sal_Bool bNeg(nWink < 0);
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir 	if(bNeg)
1416cdf0e10cSrcweir 		nWink = -nWink;
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir 	rStr = UniString::CreateFromInt32(nWink);
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir     SvtSysLocale aSysLoc;
1421cdf0e10cSrcweir     const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
1422cdf0e10cSrcweir 	xub_StrLen nAnz(2);
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir     if(rLoc.isNumLeadingZero())
1425cdf0e10cSrcweir 		nAnz++;
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir 	while(rStr.Len() < nAnz)
1428cdf0e10cSrcweir 		rStr.Insert(sal_Unicode('0'), 0);
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir     rStr.Insert(rLoc.getNumDecimalSep().GetChar(0), rStr.Len() - 2);
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir 	if(bNeg)
1433cdf0e10cSrcweir 		rStr.Insert(sal_Unicode('-'), 0);
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir 	if(!bNoDegChar)
1436cdf0e10cSrcweir 		rStr += DEGREE_CHAR;
1437cdf0e10cSrcweir }
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir void SdrModel::TakePercentStr(const Fraction& rVal, XubString& rStr, FASTBOOL bNoPercentChar) const
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir 	sal_Int32 nMul(rVal.GetNumerator());
1442cdf0e10cSrcweir 	sal_Int32 nDiv(rVal.GetDenominator());
1443cdf0e10cSrcweir 	sal_Bool bNeg(nMul < 0);
1444cdf0e10cSrcweir 
1445cdf0e10cSrcweir 	if(nDiv < 0)
1446cdf0e10cSrcweir 		bNeg = !bNeg;
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir 	if(nMul < 0)
1449cdf0e10cSrcweir 		nMul = -nMul;
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir 	if(nDiv < 0)
1452cdf0e10cSrcweir 		nDiv = -nDiv;
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 	nMul *= 100;
1455cdf0e10cSrcweir 	nMul += nDiv/2;
1456cdf0e10cSrcweir 	nMul /= nDiv;
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir 	rStr = UniString::CreateFromInt32(nMul);
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir 	if(bNeg)
1461cdf0e10cSrcweir 		rStr.Insert(sal_Unicode('-'), 0);
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir 	if(!bNoPercentChar)
1464cdf0e10cSrcweir 		rStr += sal_Unicode('%');
1465cdf0e10cSrcweir }
1466cdf0e10cSrcweir 
1467cdf0e10cSrcweir void SdrModel::SetChanged(sal_Bool bFlg)
1468cdf0e10cSrcweir {
1469cdf0e10cSrcweir 	mbChanged = bFlg;
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir void SdrModel::RecalcPageNums(FASTBOOL bMaster)
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir 	Container& rPL=*(bMaster ? &maMaPag : &maPages);
1475cdf0e10cSrcweir 	sal_uInt16 nAnz=sal_uInt16(rPL.Count());
1476cdf0e10cSrcweir 	sal_uInt16 i;
1477cdf0e10cSrcweir 	for (i=0; i<nAnz; i++) {
1478cdf0e10cSrcweir 		SdrPage* pPg=(SdrPage*)(rPL.GetObject(i));
1479cdf0e10cSrcweir 		pPg->SetPageNum(i);
1480cdf0e10cSrcweir 	}
1481cdf0e10cSrcweir 	if (bMaster) bMPgNumsDirty=sal_False;
1482cdf0e10cSrcweir 	else bPagNumsDirty=sal_False;
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir void SdrModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
1486cdf0e10cSrcweir {
1487cdf0e10cSrcweir 	sal_uInt16 nAnz=GetPageCount();
1488cdf0e10cSrcweir 	if (nPos>nAnz) nPos=nAnz;
1489cdf0e10cSrcweir 	maPages.Insert(pPage,nPos);
1490cdf0e10cSrcweir 	// #109538#
1491cdf0e10cSrcweir 	PageListChanged();
1492cdf0e10cSrcweir 	pPage->SetInserted(sal_True);
1493cdf0e10cSrcweir 	pPage->SetPageNum(nPos);
1494cdf0e10cSrcweir 	pPage->SetModel(this);
1495cdf0e10cSrcweir 	if (nPos<nAnz) bPagNumsDirty=sal_True;
1496cdf0e10cSrcweir 	SetChanged();
1497cdf0e10cSrcweir 	SdrHint aHint(HINT_PAGEORDERCHG);
1498cdf0e10cSrcweir 	aHint.SetPage(pPage);
1499cdf0e10cSrcweir 	Broadcast(aHint);
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir void SdrModel::DeletePage(sal_uInt16 nPgNum)
1503cdf0e10cSrcweir {
1504cdf0e10cSrcweir 	SdrPage* pPg=RemovePage(nPgNum);
1505cdf0e10cSrcweir 	delete pPg;
1506cdf0e10cSrcweir }
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir SdrPage* SdrModel::RemovePage(sal_uInt16 nPgNum)
1509cdf0e10cSrcweir {
1510cdf0e10cSrcweir 	SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum);
1511cdf0e10cSrcweir 	// #109538#
1512cdf0e10cSrcweir 	PageListChanged();
1513cdf0e10cSrcweir 	if (pPg!=NULL) {
1514cdf0e10cSrcweir 		pPg->SetInserted(sal_False);
1515cdf0e10cSrcweir 	}
1516cdf0e10cSrcweir 	bPagNumsDirty=sal_True;
1517cdf0e10cSrcweir 	SetChanged();
1518cdf0e10cSrcweir 	SdrHint aHint(HINT_PAGEORDERCHG);
1519cdf0e10cSrcweir 	aHint.SetPage(pPg);
1520cdf0e10cSrcweir 	Broadcast(aHint);
1521cdf0e10cSrcweir 	return pPg;
1522cdf0e10cSrcweir }
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir void SdrModel::MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir 	SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum);
1527cdf0e10cSrcweir 	// #109538#
1528cdf0e10cSrcweir 	PageListChanged();
1529cdf0e10cSrcweir 	if (pPg!=NULL) {
1530cdf0e10cSrcweir 		pPg->SetInserted(sal_False);
1531cdf0e10cSrcweir 		InsertPage(pPg,nNewPos);
1532cdf0e10cSrcweir 	}
1533cdf0e10cSrcweir }
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir 	sal_uInt16 nAnz=GetMasterPageCount();
1538cdf0e10cSrcweir 	if (nPos>nAnz) nPos=nAnz;
1539cdf0e10cSrcweir 	maMaPag.Insert(pPage,nPos);
1540cdf0e10cSrcweir 	// #109538#
1541cdf0e10cSrcweir 	MasterPageListChanged();
1542cdf0e10cSrcweir 	pPage->SetInserted(sal_True);
1543cdf0e10cSrcweir 	pPage->SetPageNum(nPos);
1544cdf0e10cSrcweir 	pPage->SetModel(this);
1545cdf0e10cSrcweir 	if (nPos<nAnz) {
1546cdf0e10cSrcweir 		bMPgNumsDirty=sal_True;
1547cdf0e10cSrcweir 	}
1548cdf0e10cSrcweir 	SetChanged();
1549cdf0e10cSrcweir 	SdrHint aHint(HINT_PAGEORDERCHG);
1550cdf0e10cSrcweir 	aHint.SetPage(pPage);
1551cdf0e10cSrcweir 	Broadcast(aHint);
1552cdf0e10cSrcweir }
1553cdf0e10cSrcweir 
1554cdf0e10cSrcweir void SdrModel::DeleteMasterPage(sal_uInt16 nPgNum)
1555cdf0e10cSrcweir {
1556cdf0e10cSrcweir 	SdrPage* pPg=RemoveMasterPage(nPgNum);
1557cdf0e10cSrcweir 	if (pPg!=NULL) delete pPg;
1558cdf0e10cSrcweir }
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir SdrPage* SdrModel::RemoveMasterPage(sal_uInt16 nPgNum)
1561cdf0e10cSrcweir {
1562cdf0e10cSrcweir 	SdrPage* pRetPg=(SdrPage*)maMaPag.Remove(nPgNum);
1563cdf0e10cSrcweir 	// #109538#
1564cdf0e10cSrcweir 	MasterPageListChanged();
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir 	if(pRetPg)
1567cdf0e10cSrcweir 	{
1568cdf0e10cSrcweir 		// Nun die Verweise der normalen Zeichenseiten auf die entfernte MasterPage loeschen
1569cdf0e10cSrcweir 		sal_uInt16 nPageAnz(GetPageCount());
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir 		for(sal_uInt16 np(0); np < nPageAnz; np++)
1572cdf0e10cSrcweir 		{
1573cdf0e10cSrcweir 			GetPage(np)->TRG_ImpMasterPageRemoved(*pRetPg);
1574cdf0e10cSrcweir 		}
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir 		pRetPg->SetInserted(sal_False);
1577cdf0e10cSrcweir 	}
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir 	bMPgNumsDirty=sal_True;
1580cdf0e10cSrcweir 	SetChanged();
1581cdf0e10cSrcweir 	SdrHint aHint(HINT_PAGEORDERCHG);
1582cdf0e10cSrcweir 	aHint.SetPage(pRetPg);
1583cdf0e10cSrcweir 	Broadcast(aHint);
1584cdf0e10cSrcweir 	return pRetPg;
1585cdf0e10cSrcweir }
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir void SdrModel::MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
1588cdf0e10cSrcweir {
1589cdf0e10cSrcweir 	SdrPage* pPg=(SdrPage*)maMaPag.Remove(nPgNum);
1590cdf0e10cSrcweir 	// #109538#
1591cdf0e10cSrcweir 	MasterPageListChanged();
1592cdf0e10cSrcweir 	if (pPg!=NULL) {
1593cdf0e10cSrcweir 		pPg->SetInserted(sal_False);
1594cdf0e10cSrcweir 		maMaPag.Insert(pPg,nNewPos);
1595cdf0e10cSrcweir 		// #109538#
1596cdf0e10cSrcweir 		MasterPageListChanged();
1597cdf0e10cSrcweir 	}
1598cdf0e10cSrcweir 	bMPgNumsDirty=sal_True;
1599cdf0e10cSrcweir 	SetChanged();
1600cdf0e10cSrcweir 	SdrHint aHint(HINT_PAGEORDERCHG);
1601cdf0e10cSrcweir 	aHint.SetPage(pPg);
1602cdf0e10cSrcweir 	Broadcast(aHint);
1603cdf0e10cSrcweir }
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir FASTBOOL SdrModel::CheckConsistence() const
1608cdf0e10cSrcweir {
1609cdf0e10cSrcweir 	FASTBOOL bRet=sal_True;
1610cdf0e10cSrcweir #ifdef DBG_UTIL
1611cdf0e10cSrcweir 	DBG_CHKTHIS(SdrModel,NULL);
1612cdf0e10cSrcweir #endif
1613cdf0e10cSrcweir 	return bRet;
1614cdf0e10cSrcweir }
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir // #48289#
1619cdf0e10cSrcweir void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
1620cdf0e10cSrcweir 						 sal_uInt16 nDestPos,
1621cdf0e10cSrcweir 						 FASTBOOL bUndo, FASTBOOL bMoveNoCopy)
1622cdf0e10cSrcweir {
1623cdf0e10cSrcweir 	if( bUndo && !IsUndoEnabled() )
1624cdf0e10cSrcweir 		bUndo = false;
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir 	if( bUndo )
1627cdf0e10cSrcweir 		BegUndo(ImpGetResStr(STR_UndoMergeModel));
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir 	sal_uInt16 nPageAnz=GetPageCount();
1630cdf0e10cSrcweir 	sal_uInt16 nMaxPage=nPageAnz;
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir 	if (nMaxPage!=0)
1633cdf0e10cSrcweir 		nMaxPage--;
1634cdf0e10cSrcweir 	if (nFirstPageNum>nMaxPage)
1635cdf0e10cSrcweir 		nFirstPageNum=nMaxPage;
1636cdf0e10cSrcweir 	if (nLastPageNum>nMaxPage)
1637cdf0e10cSrcweir 		nLastPageNum =nMaxPage;
1638cdf0e10cSrcweir 	FASTBOOL bReverse=nLastPageNum<nFirstPageNum;
1639cdf0e10cSrcweir 	if (nDestPos>nPageAnz)
1640cdf0e10cSrcweir 		nDestPos=nPageAnz;
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 	// Zunaechst die Zeiger der betroffenen Seiten in einem Array sichern
1643cdf0e10cSrcweir 	sal_uInt16 nPageNum=nFirstPageNum;
1644cdf0e10cSrcweir 	sal_uInt16 nCopyAnz=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1;
1645cdf0e10cSrcweir 	SdrPage** pPagePtrs=new SdrPage*[nCopyAnz];
1646cdf0e10cSrcweir 	sal_uInt16 nCopyNum;
1647cdf0e10cSrcweir 	for(nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
1648cdf0e10cSrcweir 	{
1649cdf0e10cSrcweir 		pPagePtrs[nCopyNum]=GetPage(nPageNum);
1650cdf0e10cSrcweir 		if (bReverse)
1651cdf0e10cSrcweir 			nPageNum--;
1652cdf0e10cSrcweir 		else
1653cdf0e10cSrcweir 			nPageNum++;
1654cdf0e10cSrcweir 	}
1655cdf0e10cSrcweir 
1656cdf0e10cSrcweir 	// Jetzt die Seiten kopieren
1657cdf0e10cSrcweir 	sal_uInt16 nDestNum=nDestPos;
1658cdf0e10cSrcweir 	for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
1659cdf0e10cSrcweir 	{
1660cdf0e10cSrcweir 		SdrPage* pPg=pPagePtrs[nCopyNum];
1661cdf0e10cSrcweir 		sal_uInt16 nPageNum2=pPg->GetPageNum();
1662cdf0e10cSrcweir 		if (!bMoveNoCopy)
1663cdf0e10cSrcweir 		{
1664cdf0e10cSrcweir 			const SdrPage* pPg1=GetPage(nPageNum2);
1665cdf0e10cSrcweir 			pPg=pPg1->Clone();
1666cdf0e10cSrcweir 			InsertPage(pPg,nDestNum);
1667cdf0e10cSrcweir 			if (bUndo)
1668cdf0e10cSrcweir 				AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg));
1669cdf0e10cSrcweir 			nDestNum++;
1670cdf0e10cSrcweir 		}
1671cdf0e10cSrcweir 		else
1672cdf0e10cSrcweir 		{
1673cdf0e10cSrcweir 			// Move ist nicht getestet!
1674cdf0e10cSrcweir 			if (nDestNum>nPageNum2)
1675cdf0e10cSrcweir 				nDestNum--;
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir 			if(bUndo)
1678cdf0e10cSrcweir 				AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum));
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir 			pPg=RemovePage(nPageNum2);
1681cdf0e10cSrcweir 			InsertPage(pPg,nDestNum);
1682cdf0e10cSrcweir 			nDestNum++;
1683cdf0e10cSrcweir 		}
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir 		if(bReverse)
1686cdf0e10cSrcweir 			nPageNum2--;
1687cdf0e10cSrcweir 		else
1688cdf0e10cSrcweir 			nPageNum2++;
1689cdf0e10cSrcweir 	}
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir 	delete[] pPagePtrs;
1692cdf0e10cSrcweir 	if(bUndo)
1693cdf0e10cSrcweir 		EndUndo();
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir void SdrModel::Merge(SdrModel& rSourceModel,
1697cdf0e10cSrcweir 					 sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
1698cdf0e10cSrcweir 					 sal_uInt16 nDestPos,
1699cdf0e10cSrcweir 					 FASTBOOL bMergeMasterPages, FASTBOOL bAllMasterPages,
1700cdf0e10cSrcweir 					 FASTBOOL bUndo, FASTBOOL bTreadSourceAsConst)
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir 	if (&rSourceModel==this)
1703cdf0e10cSrcweir 	{ // #48289#
1704cdf0e10cSrcweir 		CopyPages(nFirstPageNum,nLastPageNum,nDestPos,bUndo,!bTreadSourceAsConst);
1705cdf0e10cSrcweir 		return;
1706cdf0e10cSrcweir 	}
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir 	if( bUndo && !IsUndoEnabled() )
1709cdf0e10cSrcweir 		bUndo = false;
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir 	if (bUndo)
1712cdf0e10cSrcweir 		BegUndo(ImpGetResStr(STR_UndoMergeModel));
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir 	sal_uInt16 nSrcPageAnz=rSourceModel.GetPageCount();
1715cdf0e10cSrcweir 	sal_uInt16 nSrcMasterPageAnz=rSourceModel.GetMasterPageCount();
1716cdf0e10cSrcweir 	sal_uInt16 nDstMasterPageAnz=GetMasterPageCount();
1717cdf0e10cSrcweir 	FASTBOOL bInsPages=(nFirstPageNum<nSrcPageAnz || nLastPageNum<nSrcPageAnz);
1718cdf0e10cSrcweir 	sal_uInt16 nMaxSrcPage=nSrcPageAnz; if (nMaxSrcPage!=0) nMaxSrcPage--;
1719cdf0e10cSrcweir 	if (nFirstPageNum>nMaxSrcPage) nFirstPageNum=nMaxSrcPage;
1720cdf0e10cSrcweir 	if (nLastPageNum>nMaxSrcPage)  nLastPageNum =nMaxSrcPage;
1721cdf0e10cSrcweir 	FASTBOOL bReverse=nLastPageNum<nFirstPageNum;
1722cdf0e10cSrcweir 
1723cdf0e10cSrcweir 	sal_uInt16*   pMasterMap=NULL;
1724cdf0e10cSrcweir 	int* pMasterNeed=NULL;
1725cdf0e10cSrcweir 	sal_uInt16    nMasterNeed=0;
1726cdf0e10cSrcweir 	if (bMergeMasterPages && nSrcMasterPageAnz!=0) {
1727cdf0e10cSrcweir 		// Feststellen, welche MasterPages aus rSrcModel benoetigt werden
1728cdf0e10cSrcweir 		pMasterMap=new sal_uInt16[nSrcMasterPageAnz];
1729cdf0e10cSrcweir 		pMasterNeed=new int[nSrcMasterPageAnz];
1730cdf0e10cSrcweir 		memset(pMasterMap,0xFF,nSrcMasterPageAnz*sizeof(sal_uInt16));
1731cdf0e10cSrcweir 		if (bAllMasterPages) {
1732cdf0e10cSrcweir 			memset(pMasterNeed,sal_True,nSrcMasterPageAnz*sizeof(FASTBOOL));
1733cdf0e10cSrcweir 		} else {
1734cdf0e10cSrcweir 			memset(pMasterNeed,sal_False,nSrcMasterPageAnz*sizeof(FASTBOOL));
1735cdf0e10cSrcweir 			sal_uInt16 nAnf= bReverse ? nLastPageNum : nFirstPageNum;
1736cdf0e10cSrcweir 			sal_uInt16 nEnd= bReverse ? nFirstPageNum : nLastPageNum;
1737cdf0e10cSrcweir 			for (sal_uInt16 i=nAnf; i<=nEnd; i++) {
1738cdf0e10cSrcweir 				const SdrPage* pPg=rSourceModel.GetPage(i);
1739cdf0e10cSrcweir 				if(pPg->TRG_HasMasterPage())
1740cdf0e10cSrcweir 				{
1741cdf0e10cSrcweir 					SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
1742cdf0e10cSrcweir 					sal_uInt16 nMPgNum(rMasterPage.GetPageNum());
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir 					if(nMPgNum < nSrcMasterPageAnz)
1745cdf0e10cSrcweir 					{
1746cdf0e10cSrcweir 						pMasterNeed[nMPgNum] = sal_True;
1747cdf0e10cSrcweir 					}
1748cdf0e10cSrcweir 				}
1749cdf0e10cSrcweir 			}
1750cdf0e10cSrcweir 		}
1751cdf0e10cSrcweir 		// Nun das Mapping der MasterPages bestimmen
1752cdf0e10cSrcweir 		sal_uInt16 nAktMaPagNum=nDstMasterPageAnz;
1753cdf0e10cSrcweir 		for (sal_uInt16 i=0; i<nSrcMasterPageAnz; i++) {
1754cdf0e10cSrcweir 			if (pMasterNeed[i]) {
1755cdf0e10cSrcweir 				pMasterMap[i]=nAktMaPagNum;
1756cdf0e10cSrcweir 				nAktMaPagNum++;
1757cdf0e10cSrcweir 				nMasterNeed++;
1758cdf0e10cSrcweir 			}
1759cdf0e10cSrcweir 		}
1760cdf0e10cSrcweir 	}
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir 	// rueberholen der Masterpages
1763cdf0e10cSrcweir 	if (pMasterMap!=NULL && pMasterNeed!=NULL && nMasterNeed!=0) {
1764cdf0e10cSrcweir 		for (sal_uInt16 i=nSrcMasterPageAnz; i>0;) {
1765cdf0e10cSrcweir 			i--;
1766cdf0e10cSrcweir 			if (pMasterNeed[i]) {
1767cdf0e10cSrcweir 				SdrPage* pPg=NULL;
1768cdf0e10cSrcweir 				if (bTreadSourceAsConst) {
1769cdf0e10cSrcweir 					const SdrPage* pPg1=rSourceModel.GetMasterPage(i);
1770cdf0e10cSrcweir 					pPg=pPg1->Clone();
1771cdf0e10cSrcweir 				} else {
1772cdf0e10cSrcweir 					pPg=rSourceModel.RemoveMasterPage(i);
1773cdf0e10cSrcweir 				}
1774cdf0e10cSrcweir 				if (pPg!=NULL) {
1775cdf0e10cSrcweir 					// und alle ans einstige Ende des DstModel reinschieben.
1776cdf0e10cSrcweir 					// nicht InsertMasterPage() verwenden da die Sache
1777cdf0e10cSrcweir 					// inkonsistent ist bis alle drin sind
1778cdf0e10cSrcweir 					maMaPag.Insert(pPg,nDstMasterPageAnz);
1779cdf0e10cSrcweir 					// #109538#
1780cdf0e10cSrcweir 					MasterPageListChanged();
1781cdf0e10cSrcweir 					pPg->SetInserted(sal_True);
1782cdf0e10cSrcweir 					pPg->SetModel(this);
1783cdf0e10cSrcweir 					bMPgNumsDirty=sal_True;
1784cdf0e10cSrcweir 					if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
1785cdf0e10cSrcweir 				} else {
1786cdf0e10cSrcweir 					DBG_ERROR("SdrModel::Merge(): MasterPage im SourceModel nicht gefunden");
1787cdf0e10cSrcweir 				}
1788cdf0e10cSrcweir 			}
1789cdf0e10cSrcweir 		}
1790cdf0e10cSrcweir 	}
1791cdf0e10cSrcweir 
1792cdf0e10cSrcweir 	// rueberholen der Zeichenseiten
1793cdf0e10cSrcweir 	if (bInsPages) {
1794cdf0e10cSrcweir 		sal_uInt16 nSourcePos=nFirstPageNum;
1795cdf0e10cSrcweir 		sal_uInt16 nMergeCount=sal_uInt16(Abs((long)((long)nFirstPageNum-nLastPageNum))+1);
1796cdf0e10cSrcweir 		if (nDestPos>GetPageCount()) nDestPos=GetPageCount();
1797cdf0e10cSrcweir 		while (nMergeCount>0) {
1798cdf0e10cSrcweir 			SdrPage* pPg=NULL;
1799cdf0e10cSrcweir 			if (bTreadSourceAsConst) {
1800cdf0e10cSrcweir 				const SdrPage* pPg1=rSourceModel.GetPage(nSourcePos);
1801cdf0e10cSrcweir 				pPg=pPg1->Clone();
1802cdf0e10cSrcweir 			} else {
1803cdf0e10cSrcweir 				pPg=rSourceModel.RemovePage(nSourcePos);
1804cdf0e10cSrcweir 			}
1805cdf0e10cSrcweir 			if (pPg!=NULL) {
1806cdf0e10cSrcweir 				InsertPage(pPg,nDestPos);
1807cdf0e10cSrcweir 				if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
1808cdf0e10cSrcweir 				// und nun zu den MasterPageDescriptoren
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir 				if(pPg->TRG_HasMasterPage())
1811cdf0e10cSrcweir 				{
1812cdf0e10cSrcweir 					SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
1813cdf0e10cSrcweir 					sal_uInt16 nMaPgNum(rMasterPage.GetPageNum());
1814cdf0e10cSrcweir 
1815cdf0e10cSrcweir 					if (bMergeMasterPages)
1816cdf0e10cSrcweir 					{
1817cdf0e10cSrcweir 						sal_uInt16 nNeuNum(0xFFFF);
1818cdf0e10cSrcweir 
1819cdf0e10cSrcweir 						if(pMasterMap)
1820cdf0e10cSrcweir 						{
1821cdf0e10cSrcweir 							nNeuNum = pMasterMap[nMaPgNum];
1822cdf0e10cSrcweir 						}
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir 						if(nNeuNum != 0xFFFF)
1825cdf0e10cSrcweir 						{
1826cdf0e10cSrcweir 							if(bUndo)
1827cdf0e10cSrcweir 							{
1828cdf0e10cSrcweir 								AddUndo(GetSdrUndoFactory().CreateUndoPageChangeMasterPage(*pPg));
1829cdf0e10cSrcweir 							}
1830cdf0e10cSrcweir 
1831cdf0e10cSrcweir 							pPg->TRG_SetMasterPage(*GetMasterPage(nNeuNum));
1832cdf0e10cSrcweir 						}
1833cdf0e10cSrcweir 						DBG_ASSERT(nNeuNum!=0xFFFF,"SdrModel::Merge(): Irgendwas ist krumm beim Mappen der MasterPages");
1834cdf0e10cSrcweir 					} else {
1835cdf0e10cSrcweir 						if (nMaPgNum>=nDstMasterPageAnz) {
1836cdf0e10cSrcweir 							// Aha, die ist ausserbalb des urspruenglichen Bereichs der Masterpages des DstModel
1837cdf0e10cSrcweir 							pPg->TRG_ClearMasterPage();
1838cdf0e10cSrcweir 						}
1839cdf0e10cSrcweir 					}
1840cdf0e10cSrcweir 				}
1841cdf0e10cSrcweir 
1842cdf0e10cSrcweir 			} else {
1843cdf0e10cSrcweir 				DBG_ERROR("SdrModel::Merge(): Zeichenseite im SourceModel nicht gefunden");
1844cdf0e10cSrcweir 			}
1845cdf0e10cSrcweir 			nDestPos++;
1846cdf0e10cSrcweir 			if (bReverse) nSourcePos--;
1847cdf0e10cSrcweir 			else if (bTreadSourceAsConst) nSourcePos++;
1848cdf0e10cSrcweir 			nMergeCount--;
1849cdf0e10cSrcweir 		}
1850cdf0e10cSrcweir 	}
1851cdf0e10cSrcweir 
1852cdf0e10cSrcweir 	delete [] pMasterMap;
1853cdf0e10cSrcweir 	delete [] pMasterNeed;
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir 	bMPgNumsDirty=sal_True;
1856cdf0e10cSrcweir 	bPagNumsDirty=sal_True;
1857cdf0e10cSrcweir 
1858cdf0e10cSrcweir 	SetChanged();
1859cdf0e10cSrcweir 	// Fehlt: Mergen und Mapping der Layer
1860cdf0e10cSrcweir 	// an den Objekten sowie an den MasterPageDescriptoren
1861cdf0e10cSrcweir 	if (bUndo) EndUndo();
1862cdf0e10cSrcweir }
1863cdf0e10cSrcweir 
1864cdf0e10cSrcweir void SdrModel::SetStarDrawPreviewMode(sal_Bool bPreview)
1865cdf0e10cSrcweir {
1866cdf0e10cSrcweir 	if (!bPreview && bStarDrawPreviewMode && GetPageCount())
1867cdf0e10cSrcweir 	{
1868cdf0e10cSrcweir 		// Das Zuruecksetzen ist nicht erlaubt, da das Model ev. nicht vollstaendig geladen wurde
1869cdf0e10cSrcweir 		DBG_ASSERT(sal_False,"SdrModel::SetStarDrawPreviewMode(): Zuruecksetzen nicht erlaubt, da Model ev. nicht vollstaendig");
1870cdf0e10cSrcweir 	}
1871cdf0e10cSrcweir 	else
1872cdf0e10cSrcweir 	{
1873cdf0e10cSrcweir 		bStarDrawPreviewMode = bPreview;
1874cdf0e10cSrcweir 	}
1875cdf0e10cSrcweir }
1876cdf0e10cSrcweir 
1877cdf0e10cSrcweir uno::Reference< uno::XInterface > SdrModel::getUnoModel()
1878cdf0e10cSrcweir {
1879cdf0e10cSrcweir 	if( !mxUnoModel.is() )
1880cdf0e10cSrcweir 		mxUnoModel = createUnoModel();
1881cdf0e10cSrcweir 
1882cdf0e10cSrcweir 	return mxUnoModel;
1883cdf0e10cSrcweir }
1884cdf0e10cSrcweir 
1885cdf0e10cSrcweir void SdrModel::setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel )
1886cdf0e10cSrcweir {
1887cdf0e10cSrcweir     mxUnoModel = xModel;
1888cdf0e10cSrcweir }
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir uno::Reference< uno::XInterface > SdrModel::createUnoModel()
1891cdf0e10cSrcweir {
1892cdf0e10cSrcweir 	DBG_ERROR( "SdrModel::createUnoModel() - base implementation should not be called!" );
1893cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt;
1894cdf0e10cSrcweir 	return xInt;
1895cdf0e10cSrcweir }
1896cdf0e10cSrcweir 
1897cdf0e10cSrcweir void SdrModel::setLock( sal_Bool bLock )
1898cdf0e10cSrcweir {
1899cdf0e10cSrcweir 	if( mbModelLocked != bLock )
1900cdf0e10cSrcweir 	{
1901cdf0e10cSrcweir 		if( sal_False == bLock )
1902cdf0e10cSrcweir 		{
1903cdf0e10cSrcweir 			// ReformatAllTextObjects(); #103122# due to a typo in the above if, this code was never
1904cdf0e10cSrcweir 			//							 executed, so I remove it until we discover that we need it here
1905cdf0e10cSrcweir 			ImpReformatAllEdgeObjects();	// #103122#
1906cdf0e10cSrcweir 		}
1907cdf0e10cSrcweir 		mbModelLocked = bLock;
1908cdf0e10cSrcweir 	}
1909cdf0e10cSrcweir }
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1912cdf0e10cSrcweir 
1913cdf0e10cSrcweir void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel )
1914cdf0e10cSrcweir {
1915cdf0e10cSrcweir 	if( pSourceSet && pDestSet && (pSourceSet != pDestSet ) )
1916cdf0e10cSrcweir 	{
1917cdf0e10cSrcweir 		if( pNewModel == NULL )
1918cdf0e10cSrcweir 			pNewModel = this;
1919cdf0e10cSrcweir 
1920cdf0e10cSrcweir 		SfxWhichIter aWhichIter(*pSourceSet);
1921cdf0e10cSrcweir 		sal_uInt16 nWhich(aWhichIter.FirstWhich());
1922cdf0e10cSrcweir 		const SfxPoolItem *pPoolItem;
1923cdf0e10cSrcweir 
1924cdf0e10cSrcweir 		while(nWhich)
1925cdf0e10cSrcweir 		{
1926cdf0e10cSrcweir 			if(SFX_ITEM_SET == pSourceSet->GetItemState(nWhich, sal_False, &pPoolItem))
1927cdf0e10cSrcweir 			{
1928cdf0e10cSrcweir 				const SfxPoolItem* pItem = pPoolItem;
1929cdf0e10cSrcweir 
1930cdf0e10cSrcweir 				switch( nWhich )
1931cdf0e10cSrcweir 				{
1932cdf0e10cSrcweir 				case XATTR_FILLBITMAP:
1933cdf0e10cSrcweir 					pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pNewModel );
1934cdf0e10cSrcweir 					break;
1935cdf0e10cSrcweir 				case XATTR_LINEDASH:
1936cdf0e10cSrcweir 					pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pNewModel );
1937cdf0e10cSrcweir 					break;
1938cdf0e10cSrcweir 				case XATTR_LINESTART:
1939cdf0e10cSrcweir 					pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pNewModel );
1940cdf0e10cSrcweir 					break;
1941cdf0e10cSrcweir 				case XATTR_LINEEND:
1942cdf0e10cSrcweir 					pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pNewModel );
1943cdf0e10cSrcweir 					break;
1944cdf0e10cSrcweir 				case XATTR_FILLGRADIENT:
1945cdf0e10cSrcweir 					pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pNewModel );
1946cdf0e10cSrcweir 					break;
1947cdf0e10cSrcweir 				case XATTR_FILLFLOATTRANSPARENCE:
1948cdf0e10cSrcweir 					// #85953# allow all kinds of XFillFloatTransparenceItem to be set
1949cdf0e10cSrcweir 					pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pNewModel );
1950cdf0e10cSrcweir 					break;
1951cdf0e10cSrcweir 				case XATTR_FILLHATCH:
1952cdf0e10cSrcweir 					pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pNewModel );
1953cdf0e10cSrcweir 					break;
1954cdf0e10cSrcweir 				}
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir 				// set item
1957cdf0e10cSrcweir 				if( pItem )
1958cdf0e10cSrcweir 				{
1959cdf0e10cSrcweir 					pDestSet->Put(*pItem);
1960cdf0e10cSrcweir 
1961cdf0e10cSrcweir 					// delete item if it was a generated one
1962cdf0e10cSrcweir 					if( pItem != pPoolItem)
1963cdf0e10cSrcweir 						delete (SfxPoolItem*)pItem;
1964cdf0e10cSrcweir 				}
1965cdf0e10cSrcweir 			}
1966cdf0e10cSrcweir 			nWhich = aWhichIter.NextWhich();
1967cdf0e10cSrcweir 		}
1968cdf0e10cSrcweir 	}
1969cdf0e10cSrcweir }
1970cdf0e10cSrcweir 
1971cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1972cdf0e10cSrcweir 
1973cdf0e10cSrcweir void SdrModel::SetForbiddenCharsTable( vos::ORef<SvxForbiddenCharactersTable> xForbiddenChars )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir 	if( mpForbiddenCharactersTable )
1976cdf0e10cSrcweir 		mpForbiddenCharactersTable->release();
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir 	mpForbiddenCharactersTable = xForbiddenChars.getBodyPtr();
1979cdf0e10cSrcweir 
1980cdf0e10cSrcweir 	if( mpForbiddenCharactersTable )
1981cdf0e10cSrcweir 		mpForbiddenCharactersTable->acquire();
1982cdf0e10cSrcweir 
1983cdf0e10cSrcweir 	ImpSetOutlinerDefaults( pDrawOutliner );
1984cdf0e10cSrcweir 	ImpSetOutlinerDefaults( pHitTestOutliner );
1985cdf0e10cSrcweir }
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir vos::ORef<SvxForbiddenCharactersTable> SdrModel::GetForbiddenCharsTable() const
1988cdf0e10cSrcweir {
1989cdf0e10cSrcweir 	return mpForbiddenCharactersTable;
1990cdf0e10cSrcweir }
1991cdf0e10cSrcweir 
1992cdf0e10cSrcweir void SdrModel::SetCharCompressType( sal_uInt16 nType )
1993cdf0e10cSrcweir {
1994cdf0e10cSrcweir 	if( nType != mnCharCompressType )
1995cdf0e10cSrcweir 	{
1996cdf0e10cSrcweir 		mnCharCompressType = nType;
1997cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pDrawOutliner );
1998cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pHitTestOutliner );
1999cdf0e10cSrcweir 	}
2000cdf0e10cSrcweir }
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir void SdrModel::SetKernAsianPunctuation( sal_Bool bEnabled )
2003cdf0e10cSrcweir {
2004cdf0e10cSrcweir 	if( mbKernAsianPunctuation != bEnabled )
2005cdf0e10cSrcweir 	{
2006cdf0e10cSrcweir 		mbKernAsianPunctuation = bEnabled;
2007cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pDrawOutliner );
2008cdf0e10cSrcweir 		ImpSetOutlinerDefaults( pHitTestOutliner );
2009cdf0e10cSrcweir 	}
2010cdf0e10cSrcweir }
2011cdf0e10cSrcweir 
2012cdf0e10cSrcweir void SdrModel::SetAddExtLeading( sal_Bool bEnabled )
2013cdf0e10cSrcweir {
2014cdf0e10cSrcweir     if( mbAddExtLeading != bEnabled )
2015cdf0e10cSrcweir     {
2016cdf0e10cSrcweir         mbAddExtLeading = bEnabled;
2017cdf0e10cSrcweir         ImpSetOutlinerDefaults( pDrawOutliner );
2018cdf0e10cSrcweir         ImpSetOutlinerDefaults( pHitTestOutliner );
2019cdf0e10cSrcweir     }
2020cdf0e10cSrcweir }
2021cdf0e10cSrcweir 
2022cdf0e10cSrcweir void SdrModel::ReformatAllTextObjects()
2023cdf0e10cSrcweir {
2024cdf0e10cSrcweir 	ImpReformatAllTextObjects();
2025cdf0e10cSrcweir }
2026cdf0e10cSrcweir 
2027cdf0e10cSrcweir FASTBOOL SdrModel::HasTransparentObjects( sal_Bool bCheckForAlphaChannel ) const
2028cdf0e10cSrcweir {
2029cdf0e10cSrcweir 	FASTBOOL	bRet = sal_False;
2030cdf0e10cSrcweir 	sal_uInt16		n, nCount;
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir 	for( n = 0, nCount = GetMasterPageCount(); ( n < nCount ) && !bRet; n++ )
2033cdf0e10cSrcweir 		if( GetMasterPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) )
2034cdf0e10cSrcweir 			bRet = sal_True;
2035cdf0e10cSrcweir 
2036cdf0e10cSrcweir 	if( !bRet )
2037cdf0e10cSrcweir 	{
2038cdf0e10cSrcweir 		for( n = 0, nCount = GetPageCount(); ( n < nCount ) && !bRet; n++ )
2039cdf0e10cSrcweir 			if( GetPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) )
2040cdf0e10cSrcweir 				bRet = sal_True;
2041cdf0e10cSrcweir 	}
2042cdf0e10cSrcweir 
2043cdf0e10cSrcweir 	return bRet;
2044cdf0e10cSrcweir }
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir SdrOutliner* SdrModel::createOutliner( sal_uInt16 nOutlinerMode )
2047cdf0e10cSrcweir {
2048cdf0e10cSrcweir 	if( NULL == mpOutlinerCache )
2049cdf0e10cSrcweir 		mpOutlinerCache = new SdrOutlinerCache(this);
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir 	return mpOutlinerCache->createOutliner( nOutlinerMode );
2052cdf0e10cSrcweir }
2053cdf0e10cSrcweir 
2054cdf0e10cSrcweir void SdrModel::disposeOutliner( SdrOutliner* pOutliner )
2055cdf0e10cSrcweir {
2056cdf0e10cSrcweir 	if( mpOutlinerCache )
2057cdf0e10cSrcweir 	{
2058cdf0e10cSrcweir 		mpOutlinerCache->disposeOutliner( pOutliner );
2059cdf0e10cSrcweir 	}
2060cdf0e10cSrcweir 	else
2061cdf0e10cSrcweir 	{
2062cdf0e10cSrcweir 		delete pOutliner;
2063cdf0e10cSrcweir 	}
2064cdf0e10cSrcweir }
2065cdf0e10cSrcweir 
2066cdf0e10cSrcweir SvxNumType SdrModel::GetPageNumType() const
2067cdf0e10cSrcweir {
2068cdf0e10cSrcweir 	return SVX_ARABIC;
2069cdf0e10cSrcweir }
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir const SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) const
2072cdf0e10cSrcweir {
2073cdf0e10cSrcweir 	DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)");
2074cdf0e10cSrcweir 	return (SdrPage*)(maPages.GetObject(nPgNum));
2075cdf0e10cSrcweir }
2076cdf0e10cSrcweir 
2077cdf0e10cSrcweir SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum)
2078cdf0e10cSrcweir {
2079cdf0e10cSrcweir 	DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)");
2080cdf0e10cSrcweir 	return (SdrPage*)(maPages.GetObject(nPgNum));
2081cdf0e10cSrcweir }
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir sal_uInt16 SdrModel::GetPageCount() const
2084cdf0e10cSrcweir {
2085cdf0e10cSrcweir 	return sal_uInt16(maPages.Count());
2086cdf0e10cSrcweir }
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir void SdrModel::PageListChanged()
2089cdf0e10cSrcweir {
2090cdf0e10cSrcweir }
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir const SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) const
2093cdf0e10cSrcweir {
2094cdf0e10cSrcweir 	DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)");
2095cdf0e10cSrcweir 	return (SdrPage*)(maMaPag.GetObject(nPgNum));
2096cdf0e10cSrcweir }
2097cdf0e10cSrcweir 
2098cdf0e10cSrcweir SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum)
2099cdf0e10cSrcweir {
2100cdf0e10cSrcweir 	DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)");
2101cdf0e10cSrcweir 	return (SdrPage*)(maMaPag.GetObject(nPgNum));
2102cdf0e10cSrcweir }
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir sal_uInt16 SdrModel::GetMasterPageCount() const
2105cdf0e10cSrcweir {
2106cdf0e10cSrcweir 	return sal_uInt16(maMaPag.Count());
2107cdf0e10cSrcweir }
2108cdf0e10cSrcweir 
2109cdf0e10cSrcweir void SdrModel::MasterPageListChanged()
2110cdf0e10cSrcweir {
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir 
2113cdf0e10cSrcweir void SdrModel::SetSdrUndoManager( SfxUndoManager* pUndoManager )
2114cdf0e10cSrcweir {
2115cdf0e10cSrcweir 	mpImpl->mpUndoManager = pUndoManager;
2116cdf0e10cSrcweir }
2117cdf0e10cSrcweir 
2118cdf0e10cSrcweir SfxUndoManager* SdrModel::GetSdrUndoManager() const
2119cdf0e10cSrcweir {
2120cdf0e10cSrcweir     return mpImpl->mpUndoManager;
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir 
2123cdf0e10cSrcweir SdrUndoFactory& SdrModel::GetSdrUndoFactory() const
2124cdf0e10cSrcweir {
2125cdf0e10cSrcweir 	if( !mpImpl->mpUndoFactory )
2126cdf0e10cSrcweir 		mpImpl->mpUndoFactory = new SdrUndoFactory;
2127cdf0e10cSrcweir 	return *mpImpl->mpUndoFactory;
2128cdf0e10cSrcweir }
2129cdf0e10cSrcweir 
2130cdf0e10cSrcweir void SdrModel::SetSdrUndoFactory( SdrUndoFactory* pUndoFactory )
2131cdf0e10cSrcweir {
2132cdf0e10cSrcweir 	if( pUndoFactory && (pUndoFactory != mpImpl->mpUndoFactory) )
2133cdf0e10cSrcweir 	{
2134cdf0e10cSrcweir 		delete mpImpl->mpUndoFactory;
2135cdf0e10cSrcweir 		mpImpl->mpUndoFactory = pUndoFactory;
2136cdf0e10cSrcweir 	}
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir /** cl: added this for OJ to complete his reporting engine, does not work
2140cdf0e10cSrcweir 	correctly so only enable it for his model */
2141cdf0e10cSrcweir bool SdrModel::IsAllowShapePropertyChangeListener() const
2142cdf0e10cSrcweir {
2143cdf0e10cSrcweir 	return mpImpl && mpImpl->mbAllowShapePropertyChangeListener;
2144cdf0e10cSrcweir }
2145cdf0e10cSrcweir 
2146cdf0e10cSrcweir void SdrModel::SetAllowShapePropertyChangeListener( bool bAllow )
2147cdf0e10cSrcweir {
2148cdf0e10cSrcweir 	if( mpImpl )
2149cdf0e10cSrcweir 	{
2150cdf0e10cSrcweir 		mpImpl->mbAllowShapePropertyChangeListener = bAllow;
2151cdf0e10cSrcweir 	}
2152cdf0e10cSrcweir }
2153cdf0e10cSrcweir 
2154cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelImplementationId()
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir 	static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
2157cdf0e10cSrcweir 	if( !pSeq )
2158cdf0e10cSrcweir 	{
2159cdf0e10cSrcweir 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
2160cdf0e10cSrcweir 		if( !pSeq )
2161cdf0e10cSrcweir 		{
2162cdf0e10cSrcweir 			static Sequence< sal_Int8 > aSeq( 16 );
2163cdf0e10cSrcweir 			rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
2164cdf0e10cSrcweir 			pSeq = &aSeq;
2165cdf0e10cSrcweir 		}
2166cdf0e10cSrcweir 	}
2167cdf0e10cSrcweir 	return *pSeq;
2168cdf0e10cSrcweir }
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir void SdrModel::SetDrawingLayerPoolDefaults()
2171cdf0e10cSrcweir {
2172cdf0e10cSrcweir 	const String aNullStr;
2173cdf0e10cSrcweir 	const Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE);
2174cdf0e10cSrcweir 	const Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING);
2175cdf0e10cSrcweir 	const XHatch aNullHatch(aNullLineCol);
2176cdf0e10cSrcweir 
2177cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem( XFillColorItem(aNullStr,aNullFillCol) );
2178cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem( XFillHatchItem(pItemPool,aNullHatch) );
2179cdf0e10cSrcweir 	pItemPool->SetPoolDefaultItem( XLineColorItem(aNullStr,aNullLineCol) );
2180cdf0e10cSrcweir }
2181cdf0e10cSrcweir 
2182cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2183cdf0e10cSrcweir 
2184cdf0e10cSrcweir TYPEINIT1(SdrHint,SfxHint);
2185cdf0e10cSrcweir 
2186cdf0e10cSrcweir SdrHint::SdrHint()
2187cdf0e10cSrcweir :	mpPage(0L),
2188cdf0e10cSrcweir 	mpObj(0L),
2189cdf0e10cSrcweir 	mpObjList(0L),
2190cdf0e10cSrcweir 	meHint(HINT_UNKNOWN)
2191cdf0e10cSrcweir {
2192cdf0e10cSrcweir }
2193cdf0e10cSrcweir 
2194cdf0e10cSrcweir SdrHint::SdrHint(SdrHintKind eNewHint)
2195cdf0e10cSrcweir :	mpPage(0L),
2196cdf0e10cSrcweir 	mpObj(0L),
2197cdf0e10cSrcweir 	mpObjList(0L),
2198cdf0e10cSrcweir 	meHint(eNewHint)
2199cdf0e10cSrcweir {
2200cdf0e10cSrcweir }
2201cdf0e10cSrcweir 
2202cdf0e10cSrcweir SdrHint::SdrHint(const SdrObject& rNewObj)
2203cdf0e10cSrcweir :	mpPage(rNewObj.GetPage()),
2204cdf0e10cSrcweir 	mpObj(&rNewObj),
2205cdf0e10cSrcweir 	mpObjList(rNewObj.GetObjList()),
2206cdf0e10cSrcweir 	meHint(HINT_OBJCHG)
2207cdf0e10cSrcweir {
2208cdf0e10cSrcweir 	maRectangle = rNewObj.GetLastBoundRect();
2209cdf0e10cSrcweir }
2210cdf0e10cSrcweir 
2211cdf0e10cSrcweir SdrHint::SdrHint(const SdrObject& rNewObj, const Rectangle& rRect)
2212cdf0e10cSrcweir :	mpPage(rNewObj.GetPage()),
2213cdf0e10cSrcweir 	mpObj(&rNewObj),
2214cdf0e10cSrcweir 	mpObjList(rNewObj.GetObjList()),
2215cdf0e10cSrcweir 	meHint(HINT_OBJCHG)
2216cdf0e10cSrcweir {
2217cdf0e10cSrcweir 	maRectangle = rRect;
2218cdf0e10cSrcweir }
2219cdf0e10cSrcweir 
2220cdf0e10cSrcweir void SdrHint::SetPage(const SdrPage* pNewPage)
2221cdf0e10cSrcweir {
2222cdf0e10cSrcweir 	mpPage = pNewPage;
2223cdf0e10cSrcweir }
2224cdf0e10cSrcweir 
2225cdf0e10cSrcweir void SdrHint::SetObjList(const SdrObjList* pNewOL)
2226cdf0e10cSrcweir {
2227cdf0e10cSrcweir 	mpObjList = pNewOL;
2228cdf0e10cSrcweir }
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir void SdrHint::SetObject(const SdrObject* pNewObj)
2231cdf0e10cSrcweir {
2232cdf0e10cSrcweir 	mpObj = pNewObj;
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir 
2235cdf0e10cSrcweir void SdrHint::SetKind(SdrHintKind eNewKind)
2236cdf0e10cSrcweir {
2237cdf0e10cSrcweir 	meHint = eNewKind;
2238cdf0e10cSrcweir }
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir void SdrHint::SetRect(const Rectangle& rNewRect)
2241cdf0e10cSrcweir {
2242cdf0e10cSrcweir 	maRectangle = rNewRect;
2243cdf0e10cSrcweir }
2244cdf0e10cSrcweir 
2245cdf0e10cSrcweir const SdrPage* SdrHint::GetPage() const
2246cdf0e10cSrcweir {
2247cdf0e10cSrcweir 	return mpPage;
2248cdf0e10cSrcweir }
2249cdf0e10cSrcweir 
2250cdf0e10cSrcweir const SdrObjList* SdrHint::GetObjList() const
2251cdf0e10cSrcweir {
2252cdf0e10cSrcweir 	return mpObjList;
2253cdf0e10cSrcweir }
2254cdf0e10cSrcweir 
2255cdf0e10cSrcweir const SdrObject* SdrHint::GetObject() const
2256cdf0e10cSrcweir {
2257cdf0e10cSrcweir 	return mpObj;
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir 
2260cdf0e10cSrcweir SdrHintKind SdrHint::GetKind() const
2261cdf0e10cSrcweir {
2262cdf0e10cSrcweir 	return meHint;
2263cdf0e10cSrcweir }
2264cdf0e10cSrcweir 
2265cdf0e10cSrcweir const Rectangle& SdrHint::GetRect() const
2266cdf0e10cSrcweir {
2267cdf0e10cSrcweir 	return maRectangle;
2268cdf0e10cSrcweir }
2269cdf0e10cSrcweir 
2270cdf0e10cSrcweir // eof
2271