xref: /aoo42x/main/svx/inc/svx/svdmodel.hxx (revision 35726d9d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDMODEL_HXX
25 #define _SVDMODEL_HXX
26 
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <cppuhelper/weakref.hxx>
29 #include <sot/storage.hxx>
30 #include <tools/link.hxx>
31 #include <tools/contnr.hxx>
32 #include <tools/weakbase.hxx>
33 #include <vcl/mapmod.hxx>
34 #include <svl/brdcst.hxx>
35 #include <tools/string.hxx>
36 #include <tools/datetime.hxx>
37 #include <svl/hint.hxx>
38 #include <svl/style.hxx>
39 #include <svx/pageitem.hxx>
40 #include <vcl/field.hxx>
41 #include <boost/shared_ptr.hpp>
42 #include <svx/svdtypes.hxx> // fuer enum RepeatFuncts
43 #include <vcl/field.hxx>
44 #include "svx/svxdllapi.h"
45 #include <vos/ref.hxx>
46 #include <svx/xtable.hxx>
47 
48 #if defined(UNX) || defined(WNT)
49 #define DEGREE_CHAR ((sal_Unicode)176)   /* 0xB0 = Ansi */
50 #endif
51 
52 #if defined(OS2)
53 #define DEGREE_CHAR ((sal_Unicode)248)   /* 0xF8 = IBM PC (Erw. ASCII) */
54 #endif
55 
56 #ifndef DEGREE_CHAR
57 #error unbekannte Plattrorm
58 #endif
59 
60 class OutputDevice;
61 class SdrOutliner;
62 class SdrLayerAdmin;
63 class SdrObjList;
64 class SdrObject;
65 class SdrPage;
66 class SdrPageView;
67 class SdrTextObj;
68 class SdrUndoAction;
69 class SdrUndoGroup;
70 class AutoTimer;
71 class SfxItemPool;
72 class SfxItemSet;
73 class SfxRepeatTarget;
74 class SfxStyleSheet;
75 class SfxUndoAction;
76 class SfxUndoManager;
77 class SvxForbiddenCharactersTable;
78 class SvNumberFormatter;
79 class SotStorage;
80 class SdrOutlinerCache;
81 class SotStorageRef;
82 class SdrUndoFactory;
83 namespace comphelper { class IEmbeddedHelper; }
84 namespace sfx2 { class LinkManager; }
85 
86 ////////////////////////////////////////////////////////////////////////////////////////////////////
87 
88 #define SDR_SWAPGRAPHICSMODE_NONE		0x00000000
89 #define SDR_SWAPGRAPHICSMODE_TEMP		0x00000001
90 #define SDR_SWAPGRAPHICSMODE_DOC		0x00000002
91 #define SDR_SWAPGRAPHICSMODE_PURGE		0x00000100
92 #define SDR_SWAPGRAPHICSMODE_DEFAULT	(SDR_SWAPGRAPHICSMODE_TEMP|SDR_SWAPGRAPHICSMODE_DOC|SDR_SWAPGRAPHICSMODE_PURGE)
93 
94 ////////////////////////////////////////////////////////////////////////////////////////////////////
95 
96 enum SdrHintKind
97 {
98 				  HINT_UNKNOWN,         // Unbekannt
99 				  HINT_LAYERCHG,        // Layerdefinition geaendert
100 				  HINT_LAYERORDERCHG,   // Layerreihenfolge geaendert (Insert/Remove/ChangePos)
101 				  HINT_PAGEORDERCHG,    // Reihenfolge der Seiten (Zeichenseiten oder Masterpages) geaendert (Insert/Remove/ChangePos)
102 				  HINT_OBJCHG,          // Objekt geaendert
103 				  HINT_OBJINSERTED,     // Neues Zeichenobjekt eingefuegt
104 				  HINT_OBJREMOVED,      // Zeichenobjekt aus Liste entfernt
105 				  HINT_MODELCLEARED,    // gesamtes Model geloescht (keine Pages mehr da). not impl.
106 				  HINT_REFDEVICECHG,    // RefDevice geaendert
107 				  HINT_DEFAULTTABCHG,   // Default Tabulatorweite geaendert
108 				  HINT_DEFFONTHGTCHG,   // Default FontHeight geaendert
109 				  HINT_MODELSAVED,      // Dokument wurde gesichert
110 				  HINT_SWITCHTOPAGE,    // #94278# UNDO/REDO at an object evtl. on another page
111 				  HINT_BEGEDIT,			// Is called after the object has entered text edit mode
112 				  HINT_ENDEDIT			// Is called after the object has left text edit mode
113 };
114 
115 class SVX_DLLPUBLIC SdrHint: public SfxHint
116 {
117 public:
118 	Rectangle								maRectangle;
119 	const SdrPage*							mpPage;
120 	const SdrObject*						mpObj;
121 	const SdrObjList*						mpObjList;
122 	SdrHintKind								meHint;
123 
124 public:
125 	TYPEINFO();
126 
127 	SdrHint();
128 	SdrHint(SdrHintKind eNewHint);
129 	SdrHint(const SdrObject& rNewObj);
130 	SdrHint(const SdrObject& rNewObj, const Rectangle& rRect);
131 
132 	void SetPage(const SdrPage* pNewPage);
133 	void SetObjList(const SdrObjList* pNewOL);
134 	void SetObject(const SdrObject* pNewObj);
135 	void SetKind(SdrHintKind eNewKind);
136 	void SetRect(const Rectangle& rNewRect);
137 
138 	const SdrPage* GetPage() const;
139 	const SdrObjList* GetObjList() const;
140 	const SdrObject* GetObject() const;
141 	SdrHintKind GetKind() const;
142 	const Rectangle& GetRect() const;
143 };
144 
145 ////////////////////////////////////////////////////////////////////////////////////////////////////
146 
147 // Flag um nach dem Laden des Pools Aufzuraeumen (d.h. die RefCounts
148 // neu zu bestimmen und unbenutztes wegzuwerfen). sal_False == aktiv
149 #define LOADREFCOUNTS (sal_False)
150 
151 struct SdrDocumentStreamInfo
152 {
153 	FASTBOOL	    mbDeleteAfterUse;
154 	String		    maUserData;
155     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > mxStorageRef;
156 	sal_Bool		    mbDummy1 : 1;
157 };
158 
159 struct SdrModelImpl;
160 
161 class SVX_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase< SdrModel >
162 {
163 protected:
164 	DateTime       aReadDate;  // Datum des Einstreamens
165 	Container      maMaPag;     // StammSeiten (Masterpages)
166 	Container      maPages;
167 	Link           aUndoLink;  // Link fuer einen NotifyUndo-Handler
168 	Link           aIOProgressLink;
169 	String         aTablePath;
170 	Size           aMaxObjSize; // z.B. fuer Autogrowing Text
171     Fraction       aObjUnit;   // Beschreibung der Koordinateneinheiten fuer ClipBoard, Drag&Drop, ...
172     MapUnit        eObjUnit;   // see above
173     FieldUnit      eUIUnit;      // Masseinheit, Masstab (z.B. 1/1000) fuer die UI (Statuszeile) wird von ImpSetUIUnit() gesetzt
174     Fraction       aUIScale;     // see above
175     String         aUIUnitStr;   // see above
176     Fraction       aUIUnitFact;  // see above
177     int            nUIUnitKomma; // see above
178     FASTBOOL       bUIOnlyKomma; // see above
179 
180 	SdrLayerAdmin*  pLayerAdmin;
181 	SfxItemPool*    pItemPool;
182 	FASTBOOL        bMyPool;        // zum Aufraeumen von pMyPool ab 303a
183 	comphelper::IEmbeddedHelper*
184                     m_pEmbeddedHelper; // helper for embedded objects to get rid of the SfxObjectShell
185 	SdrOutliner*    pDrawOutliner;  // ein Outliner zur Textausgabe
186 	SdrOutliner*    pHitTestOutliner;// ein Outliner fuer den HitTest
187 	sal_uIntPtr           nDefTextHgt;    // Default Texthoehe in logischen Einheiten
188 	OutputDevice*   pRefOutDev;     // ReferenzDevice fuer die EditEngine
189 	sal_uIntPtr           nProgressAkt;   // fuer den
190 	sal_uIntPtr           nProgressMax;   // ProgressBar-
191 	sal_uIntPtr           nProgressOfs;   // -Handler
192 	rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool;
193 	SfxStyleSheet*	pDefaultStyleSheet;
194     SfxStyleSheet* mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; // #119287#
195 	sfx2::LinkManager* pLinkManager;   // LinkManager
196 	Container*      pUndoStack;
197 	Container*      pRedoStack;
198 	SdrUndoGroup*   pAktUndoGroup;  // Fuer mehrstufige
199 	sal_uInt16          nUndoLevel;     // Undo-Klammerung
200 	bool			mbUndoEnabled;	// If false no undo is recorded or we are during the execution of an undo action
201 	sal_uInt16          nProgressPercent; // fuer den ProgressBar-Handler
202 	sal_uInt16          nLoadVersion;   // Versionsnummer der geladenen Datei
203 	sal_Bool        mbChanged;
204 	FASTBOOL        bInfoChanged;
205 	FASTBOOL        bPagNumsDirty;
206 	FASTBOOL        bMPgNumsDirty;
207 	FASTBOOL        bPageNotValid;  // sal_True=Doc ist nur ObjektTraeger. Page ist nicht gueltig.
208 	FASTBOOL        bSavePortable;  // Metafiles portabel speichern
209 	FASTBOOL        bNoBitmapCaching;   // Bitmaps fuer Screenoutput cachen
210 	FASTBOOL        bReadOnly;
211 	FASTBOOL        bTransparentTextFrames;
212 	FASTBOOL        bSaveCompressed;
213 	FASTBOOL        bSwapGraphics;
214 	FASTBOOL        bPasteResize; // Objekte werden gerade resized wegen Paste mit anderem MapMode
215 	FASTBOOL		bSaveOLEPreview;      // save preview metafile of OLE objects
216 	sal_uInt16          nStreamCompressMode;  // Komprimiert schreiben?
217 	sal_uInt16          nStreamNumberFormat;
218 	sal_uInt16          nDefaultTabulator;
219 	sal_uInt32          nMaxUndoCount;
220 	FASTBOOL        bSaveNative;
221 	sal_Bool            bStarDrawPreviewMode;
222 
223 
224 //////////////////////////////////////////////////////////////////////////////
225 // sdr::Comment interface
226 private:
227 	// the next unique comment ID, used for counting added comments. Initialized
228 	// to 0. UI shows one more due to the fact that 0 is a no-no for users.
229 	sal_uInt32											mnUniqueCommentID;
230 
231 public:
232 	// create a new, unique comment ID
233 	sal_uInt32 GetNextUniqueCommentID();
234 
235 	// get the author name
236 	::rtl::OUString GetDocumentAuthorName() const;
237 
238 	// for export
239 	sal_uInt32 GetUniqueCommentID() const { return mnUniqueCommentID; }
240 
241 	// for import
242 	void SetUniqueCommentID(sal_uInt32 nNewID) { if(nNewID != mnUniqueCommentID) { mnUniqueCommentID = nNewID; } }
243 	/** cl: added this for OJ to complete his reporting engine, does not work
244 		correctly so only enable it for his model */
245 	bool IsAllowShapePropertyChangeListener() const;
246 	void SetAllowShapePropertyChangeListener( bool bAllow );
247 
248 	sal_uInt16          nStarDrawPreviewMasterPageNum;
249 	// Reserven fuer kompatible Erweiterungen
250 //-/	SfxItemPool*    pUndoItemPool;
251 	SotStorage*		pModelStorage;
252 	SvxForbiddenCharactersTable* mpForbiddenCharactersTable;
253 	sal_uIntPtr			nSwapGraphicsMode;
254 
255 	SdrOutlinerCache* mpOutlinerCache;
256 	SdrModelImpl*	mpImpl;
257 	sal_uInt16          mnCharCompressType;
258 	sal_uInt16          mnHandoutPageCount;
259 	sal_uInt16          nReserveUInt6;
260 	sal_uInt16          nReserveUInt7;
261 	FASTBOOL        mbModelLocked;
262 	FASTBOOL        mbKernAsianPunctuation;
263     FASTBOOL        mbAddExtLeading;
264 	FASTBOOL        mbInDestruction;
265 
266     // lists for colors, dashes, lineends, hatches, gradients and bitmaps for this model
267     XColorListSharedPtr     maColorTable;
268     XDashListSharedPtr      maDashList;
269     XLineEndListSharedPtr   maLineEndList;
270     XHatchListSharedPtr     maHatchList;
271     XGradientListSharedPtr  maGradientList;
272     XBitmapListSharedPtr    maBitmapList;
273 
274 	// New src638: NumberFormatter for drawing layer and
275 	// method for getting it. It is constructed on demand
276 	// and destroyed when destroying the SdrModel.
277 	SvNumberFormatter* mpNumberFormatter;
278 public:
279 	const SvNumberFormatter& GetNumberFormatter() const;
280 
281 	sal_uInt16 getHandoutPageCount() const { return mnHandoutPageCount; }
282 	void setHandoutPageCount( sal_uInt16 nHandoutPageCount ) { mnHandoutPageCount = nHandoutPageCount; }
283 
284 protected:
285 
286 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel();
287 
288 private:
289 	// Nicht implementiert:
290 	SVX_DLLPRIVATE SdrModel(const SdrModel& rSrcModel);
291 	SVX_DLLPRIVATE void operator=(const SdrModel& rSrcModel);
292 	SVX_DLLPRIVATE FASTBOOL operator==(const SdrModel& rCmpModel) const;
293 //#if 0 // _SOLAR__PRIVATE
294 	SVX_DLLPRIVATE void ImpPostUndoAction(SdrUndoAction* pUndo);
295 	SVX_DLLPRIVATE void ImpSetUIUnit();
296 	SVX_DLLPRIVATE void ImpSetOutlinerDefaults( SdrOutliner* pOutliner, sal_Bool bInit = sal_False );
297 	SVX_DLLPRIVATE void ImpReformatAllTextObjects();
298 	SVX_DLLPRIVATE void ImpReformatAllEdgeObjects();	// #103122#
299 	SVX_DLLPRIVATE void ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bLoadRefCounts = true);
300 
301 //#endif // __PRIVATE
302 
303 	// this is a weak reference to a possible living api wrapper for this model
304 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxUnoModel;
305 
306 public:
307 //#if 0 // _SOLAR__PRIVATE
308 	FASTBOOL IsPasteResize() const        { return bPasteResize; }
309 	void     SetPasteResize(FASTBOOL bOn) { bPasteResize=bOn; }
310 //#endif // __PRIVATE
311 	TYPEINFO();
312 	// Steckt man hier seinen eigenen Pool rein, so wird die Klasse auch
313 	// Aktionen an ihm vornehmen (Put(),Remove()). Bei Zerstoerung von
314 	// SdrModel wird dieser Pool ver delete geloescht!
315 	// Gibt man den Konstruktor stattdessen eine NULL mit, so macht sich
316 	// die Klasse einen eigenen Pool (SdrItemPool), den sie dann auch im
317 	// Destruktor zerstoert.
318 	// Bei Verwendung eines eigenen Pools ist darauf zu achten, dass dieser
319 	// von SdrItemPool abgeleitet ist, falls man von SdrAttrObj abgeleitete
320 	// Zeichenobjekte verwenden moechte. Setzt man degegen nur vom abstrakten
321 	// Basisobjekt SdrObject abgeleitete Objekte ein, so ist man frei in der
322 	// Wahl des Pools.
323 	SdrModel(SfxItemPool* pPool=NULL, ::comphelper::IEmbeddedHelper* pPers=NULL, sal_Bool bLoadRefCounts = LOADREFCOUNTS);
324 	SdrModel(const String& rPath, SfxItemPool* pPool=NULL, ::comphelper::IEmbeddedHelper* pPers=NULL, sal_Bool bLoadRefCounts = LOADREFCOUNTS);
325 	virtual ~SdrModel();
326 	void ClearModel(sal_Bool bCalledFromDestructor);
327 
328 	// Hier kann man erfragen, ob das Model gerade eingrstreamt wird
329 	FASTBOOL IsLoading() const                  { return sal_False /*BFS01 bLoading */; }
330 	// Muss z.B. ueberladen werden, um das Swappen/LoadOnDemand von Grafiken
331 	// zu ermoeglichen. Wird rbDeleteAfterUse auf sal_True gesetzt, so wird
332 	// die SvStream-Instanz vom Aufrufer nach Gebrauch destruiert.
333 	// Wenn diese Methode NULL liefert, wird zum Swappen eine temporaere
334 	// Datei angelegt.
335 	// Geliefert werden muss der Stream, aus dem das Model geladen wurde
336 	// bzw. in den es zuletzt gespeichert wurde.
337 	virtual SvStream* GetDocumentStream( SdrDocumentStreamInfo& rStreamInfo ) const;
338 	// Die Vorlagenattribute der Zeichenobjekte in harte Attribute verwandeln.
339 	void BurnInStyleSheetAttributes();
340 	// Wer sich von SdrPage ableitet muss sich auch von SdrModel ableiten
341 	// und diese beiden VM AllocPage() und AllocModel() ueberladen...
342 	virtual SdrPage*  AllocPage(FASTBOOL bMasterPage);
343 	virtual SdrModel* AllocModel() const;
344 
345 	// Aenderungen an den Layern setzen das Modified-Flag und broadcasten am Model!
346 	const SdrLayerAdmin& GetLayerAdmin() const                  { return *pLayerAdmin; }
347 	SdrLayerAdmin&       GetLayerAdmin()                        { return *pLayerAdmin; }
348 
349 	const SfxItemPool&   GetItemPool() const                    { return *pItemPool; }
350 	SfxItemPool&         GetItemPool()                          { return *pItemPool; }
351 
352 	SdrOutliner&         GetDrawOutliner(const SdrTextObj* pObj=NULL) const;
353 
354 	/** returns a new created and non shared outliner.
355 		The outliner will not get updated when the SdrModel is changed.
356 	*/
357 	boost::shared_ptr< SdrOutliner > CreateDrawOutliner(const SdrTextObj* pObj=NULL);
358 
359 	SdrOutliner&         GetHitTestOutliner() const { return *pHitTestOutliner; }
360 	const SdrTextObj*    GetFormattingTextObj() const;
361 	// Die TextDefaults (Font,Hoehe,Farbe) in ein Set putten
362 	void         		 SetTextDefaults() const;
363 	static void    		 SetTextDefaults( SfxItemPool* pItemPool, sal_uIntPtr nDefTextHgt );
364 
365 	// ReferenzDevice fuer die EditEngine
366 	void                 SetRefDevice(OutputDevice* pDev);
367 	OutputDevice*        GetRefDevice() const                   { return pRefOutDev; }
368 	// Wenn ein neuer MapMode am RefDevice gesetzt wird o.ae.
369 	void                 RefDeviceChanged(); // noch nicht implementiert
370 	// Default-Schrifthoehe in logischen Einheiten
371 	void                 SetDefaultFontHeight(sal_uIntPtr nVal);
372 	sal_uIntPtr                GetDefaultFontHeight() const           { return nDefTextHgt; }
373 	// Default-Tabulatorweite fuer die EditEngine
374 	void                 SetDefaultTabulator(sal_uInt16 nVal);
375 	sal_uInt16               GetDefaultTabulator() const            { return nDefaultTabulator; }
376 
377 	// Der DefaultStyleSheet wird jedem Zeichenobjekt verbraten das in diesem
378 	// Model eingefuegt wird und kein StyleSheet gesetzt hat.
379 	SfxStyleSheet*       GetDefaultStyleSheet() const             { return pDefaultStyleSheet; }
380 	void                 SetDefaultStyleSheet(SfxStyleSheet* pDefSS) { pDefaultStyleSheet = pDefSS; }
381 
382     // #119287# default StyleSheet for SdrGrafObj and SdrOle2Obj
383     SfxStyleSheet* GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj() const { return mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; }
384 	void SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(SfxStyleSheet* pDefSS) { mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj = pDefSS; }
385 
386 	sfx2::LinkManager*      GetLinkManager()                         { return pLinkManager; }
387 	void                 SetLinkManager( sfx2::LinkManager* pLinkMgr ) { pLinkManager = pLinkMgr; }
388 
389     ::comphelper::IEmbeddedHelper*     GetPersist() const               { return m_pEmbeddedHelper; }
390 	void				 ClearPersist()                                 { m_pEmbeddedHelper = 0; }
391 	void				 SetPersist( ::comphelper::IEmbeddedHelper *p ) { m_pEmbeddedHelper = p; }
392 
393 	// Masseinheit fuer die Zeichenkoordinaten.
394 	// Default ist 1 logische Einheit = 1/100mm (Unit=MAP_100TH_MM, Fract=(1,1)).
395 	// Beispiele:
396 	//   MAP_POINT,    Fraction(72,1)    : 1 log Einh = 72 Point   = 1 Inch
397 	//   MAP_POINT,    Fraction(1,20)    : 1 log Einh = 1/20 Point = 1 Twip
398 	//   MAP_TWIP,     Fraction(1,1)     : 1 log Einh = 1 Twip
399 	//   MAP_100TH_MM, Fraction(1,10)    : 1 log Einh = 1/1000mm
400 	//   MAP_MM,       Fraction(1000,1)  : 1 log Einh = 1000mm     = 1m
401 	//   MAP_CM,       Fraction(100,1)   : 1 log Einh = 100cm      = 1m
402 	//   MAP_CM,       Fraction(100,1)   : 1 log Einh = 100cm      = 1m
403 	//   MAP_CM,       Fraction(100000,1): 1 log Einh = 100000cm   = 1km
404 	// (PS: Lichtjahre sind somit also nicht darstellbar).
405 	// Die Skalierungseinheit wird benoetigt, damit die Engine das Clipboard
406 	// mit den richtigen Groessen beliefern kann.
407 	MapUnit          GetScaleUnit() const                       { return eObjUnit; }
408 	void             SetScaleUnit(MapUnit eMap);
409 	const Fraction&  GetScaleFraction() const                   { return aObjUnit; }
410 	void             SetScaleFraction(const Fraction& rFrac);
411 	// Beides gleichzeitig setzen ist etwas performanter
412 	void             SetScaleUnit(MapUnit eMap, const Fraction& rFrac);
413 
414 	// Maximale Groesse z.B. fuer Autogrowing-Texte
415 	const Size&      GetMaxObjSize() const                      { return aMaxObjSize; }
416 	void             SetMaxObjSize(const Size& rSiz)            { aMaxObjSize=rSiz; }
417 
418 	// Damit die View! in der Statuszeile vernuenftige Zahlen anzeigen kann:
419 	// Default ist mm.
420 	void             SetUIUnit(FieldUnit eUnit);
421 	FieldUnit        GetUIUnit() const                          { return eUIUnit; }
422 	// Der Masstab der Zeichnung. Default 1/1.
423 	void             SetUIScale(const Fraction& rScale);
424 	const Fraction&  GetUIScale() const                         { return aUIScale; }
425 	// Beides gleichzeitig setzen ist etwas performanter
426 	void             SetUIUnit(FieldUnit eUnit, const Fraction& rScale);
427 
428 	const Fraction&  GetUIUnitFact() const                      { return aUIUnitFact; }
429 	const String&    GetUIUnitStr() const                       { return aUIUnitStr; }
430 	int              GetUIUnitKomma() const                     { return nUIUnitKomma; }
431 	FASTBOOL         IsUIOnlyKomma() const                      { return bUIOnlyKomma; }
432 
433 	static void		 TakeUnitStr(FieldUnit eUnit, String& rStr);
434 	void             TakeMetricStr(long nVal, String& rStr, FASTBOOL bNoUnitChars=sal_False, sal_Int32 nNumDigits = -1) const;
435 	void             TakeWinkStr(long nWink, String& rStr, FASTBOOL bNoDegChar=sal_False) const;
436 	void             TakePercentStr(const Fraction& rVal, String& rStr, FASTBOOL bNoPercentChar=sal_False) const;
437 
438 	// RecalcPageNums wird idR. nur von der Page gerufen.
439 	FASTBOOL         IsPagNumsDirty() const                     { return bPagNumsDirty; };
440 	FASTBOOL         IsMPgNumsDirty() const                     { return bMPgNumsDirty; };
441 	void             RecalcPageNums(FASTBOOL bMaster);
442 	// Nach dem Insert gehoert die Page dem SdrModel.
443 	virtual void     InsertPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
444 	virtual void     DeletePage(sal_uInt16 nPgNum);
445 	// Remove bedeutet Eigentumsuebereignung an den Aufrufer (Gegenteil von Insert)
446 	virtual SdrPage* RemovePage(sal_uInt16 nPgNum);
447 	virtual void     MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
448 	const SdrPage* GetPage(sal_uInt16 nPgNum) const;
449 	SdrPage* GetPage(sal_uInt16 nPgNum);
450 	sal_uInt16 GetPageCount() const;
451 	// #109538#
452 	virtual void PageListChanged();
453 
454 	// Masterpages
455 	virtual void     InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
456 	virtual void     DeleteMasterPage(sal_uInt16 nPgNum);
457 	// Remove bedeutet Eigentumsuebereignung an den Aufrufer (Gegenteil von Insert)
458 	virtual SdrPage* RemoveMasterPage(sal_uInt16 nPgNum);
459 	virtual void     MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
460 	const SdrPage* GetMasterPage(sal_uInt16 nPgNum) const;
461 	SdrPage* GetMasterPage(sal_uInt16 nPgNum);
462 	sal_uInt16 GetMasterPageCount() const;
463 	// #109538#
464 	virtual void MasterPageListChanged();
465 
466 	// Modified-Flag. Wird automatisch gesetzt, wenn an den Pages oder
467 	// Zeichenobjekten was geaendert wird. Zuruecksetzen muss man es
468 	// jedoch selbst (z.B. bei Save() ...).
469 	sal_Bool IsChanged() const { return mbChanged; }
470 	virtual void SetChanged(sal_Bool bFlg = sal_True);
471 
472 	// PageNotValid bedeutet, dass das Model lediglich Objekte traegt die zwar
473 	// auf einer Page verankert sind, die Page aber nicht gueltig ist. Diese
474 	// Kennzeichnung wird fuers Clipboard/Drag&Drop benoetigt.
475 	FASTBOOL        IsPageNotValid() const                     { return bPageNotValid; }
476 	void            SetPageNotValid(FASTBOOL bJa=sal_True)         { bPageNotValid=bJa; }
477 
478 	// Schaltet man dieses Flag auf sal_True, so werden Grafikobjekte
479 	// portabel gespeichert. Es findet dann beim Speichern ggf.
480 	// eine implizite Wandlung von Metafiles statt.
481 	// Default=FALSE. Flag ist nicht persistent.
482 	FASTBOOL        IsSavePortable() const                     { return bSavePortable; }
483 	void            SetSavePortable(FASTBOOL bJa=sal_True)         { bSavePortable=bJa; }
484 
485 	// Schaltet man dieses Flag auf sal_True, so werden
486 	// Pixelobjekte (stark) komprimiert gespeichert.
487 	// Default=FALSE. Flag ist nicht persistent.
488 	FASTBOOL        IsSaveCompressed() const                   { return bSaveCompressed; }
489 	void            SetSaveCompressed(FASTBOOL bJa=sal_True)       { bSaveCompressed=bJa; }
490 
491 	// Schaltet man dieses Flag auf sal_True, so werden
492 	// Grafikobjekte mit gesetztem Native-Link
493 	// native gespeichert.
494 	// Default=FALSE. Flag ist nicht persistent.
495 	FASTBOOL        IsSaveNative() const                       { return bSaveNative; }
496 	void            SetSaveNative(FASTBOOL bJa=sal_True)           { bSaveNative=bJa; }
497 
498 	// Schaltet man dieses Flag auf sal_True, so werden die Grafiken
499 	// von Grafikobjekten:
500 	// - beim Laden eines Dokuments nicht sofort mitgeladen,
501 	//   sondern erst wenn sie gebraucht (z.B. angezeigt) werden.
502 	// - ggf. wieder aus dem Speicher geworfen, falls Sie gerade
503     //   nicht benoetigt werden.
504 	// Damit das funktioniert, muss die virtuelle Methode
505 	// GetDocumentStream() ueberladen werden.
506 	// Default=FALSE. Flag ist nicht persistent.
507 	FASTBOOL        IsSwapGraphics() const { return bSwapGraphics; }
508 	void            SetSwapGraphics(FASTBOOL bJa=sal_True);
509 	void			SetSwapGraphicsMode(sal_uIntPtr nMode) { nSwapGraphicsMode = nMode; }
510 	sal_uIntPtr			GetSwapGraphicsMode() const { return nSwapGraphicsMode; }
511 
512 	FASTBOOL        IsSaveOLEPreview() const          { return bSaveOLEPreview; }
513 	void            SetSaveOLEPreview( FASTBOOL bSet) { bSaveOLEPreview = bSet; }
514 
515 	// Damit die Bildschirmausgabe von Bitmaps (insbesondere bei gedrehten)
516 	// etwas schneller wird, werden sie gecachet. Diesen Cache kann man mit
517 	// diesem Flag ein-/ausschalten. Beim naechsten Paint wird an den Objekten
518 	// dann ggf. ein Image gemerkt bzw. freigegeben. Wandert ein Bitmapobjekt
519 	// in's Undo, so wird der Cache fuer dieses Objekt sofort ausgeschaltet
520 	// (Speicher sparen).
521 	// Default=Cache eingeschaltet. Flag ist nicht persistent.
522 	FASTBOOL        IsBitmapCaching() const                     { return !bNoBitmapCaching; }
523 	void            SetBitmapCaching(FASTBOOL bJa=sal_True)         { bNoBitmapCaching=!bJa; }
524 
525 	// Defaultmaessig (sal_False) kann man Textrahmen ohne Fuellung durch
526 	// Mausklick selektieren. Nach Aktivierung dieses Flags trifft man sie
527 	// nur noch in dem Bereich, wo sich auch tatsaechlich Text befindet.
528 	FASTBOOL        IsPickThroughTransparentTextFrames() const  { return bTransparentTextFrames; }
529 	void            SetPickThroughTransparentTextFrames(FASTBOOL bOn) { bTransparentTextFrames=bOn; }
530 
531 	// Darf denn das Model ueberhaupt veraendert werden?
532 	// Wird nur von den Possibility-Methoden der View ausgewerdet.
533 	// Direkte Manipulationen am Model, ... berueksichtigen dieses Flag nicht.
534 	// Sollte ueberladen werden und entsprechend des ReadOnly-Status des Files
535 	// sal_True oder sal_False liefern (Methode wird oeffters gerufen, also ein Flag
536 	// verwenden!).
537 	virtual FASTBOOL IsReadOnly() const;
538 	virtual void     SetReadOnly(FASTBOOL bYes);
539 
540 	// Vermischen zweier SdrModel. Zu beachten sei, dass rSourceModel nicht
541 	// const ist. Die Pages werden beim einfuegen nicht kopiert, sondern gemoved.
542 	// rSourceModel ist anschliessend u.U. weitgehend leer.
543 	// nFirstPageNum,nLastPageNum: Die aus rSourceModel zu uebernehmenden Seiten
544 	// nDestPos..................: Einfuegeposition
545 	// bMergeMasterPages.........: sal_True =benoetigte MasterPages werden aus
546 	//                                   rSourceModel ebenfalls uebernommen
547 	//                             sal_False=Die MasterPageDescriptoren der Seiten
548 	//                                   aus rSourceModel werden auf die
549 	//                                   vorhandenen MasterPages gemappt.
550 	// bUndo.....................: Fuer das Merging wird eine UndoAction generiert.
551 	//                             Undo ist nur fuer das ZielModel, nicht fuer
552 	//                             rSourceModel.
553 	// bTreadSourceAsConst.......: sal_True=Das SourceModel wird nicht veraendert,.
554 	//                             d.h die Seiten werden kopiert.
555 	virtual void Merge(SdrModel& rSourceModel,
556 			   sal_uInt16 nFirstPageNum=0, sal_uInt16 nLastPageNum=0xFFFF,
557 			   sal_uInt16 nDestPos=0xFFFF,
558 			   FASTBOOL bMergeMasterPages=sal_False, FASTBOOL bAllMasterPages=sal_False,
559 			   FASTBOOL bUndo=sal_True, FASTBOOL bTreadSourceAsConst=sal_False);
560 
561 	// Ist wie Merge(SourceModel=DestModel,nFirst,nLast,nDest,sal_False,sal_False,bUndo,!bMoveNoCopy);
562 	void CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
563 				   sal_uInt16 nDestPos,
564 				   FASTBOOL bUndo=sal_True, FASTBOOL bMoveNoCopy=sal_False);
565 
566 	// Mit BegUndo() / EndUndo() ist es moeglich beliebig viele UndoActions
567 	// beliebig tief zu klammern. Als Kommentar der
568 	// UndoAction wird der des ersten BegUndo(String) aller Klammerungen
569 	// verwendet. Der NotifyUndoActionHdl wird in diesem Fall erst beim letzten
570 	// EndUndo() gerufen. Bei einer leeren Klammerung wird keine UndoAction
571 	// generiert.
572 	// Alle direkten Aktionen am SdrModel erzeugen keine UndoActions, die
573 	// Aktionen an der SdrView dagegen generieren solche.
574 	void BegUndo();                       // Undo-Klammerung auf
575 	void BegUndo(const String& rComment); // Undo-Klammerung auf
576 	void BegUndo(const String& rComment, const String& rObjDescr, SdrRepeatFunc eFunc=SDRREPFUNC_OBJ_NONE); // Undo-Klammerung auf
577 	void BegUndo(SdrUndoGroup* pUndoGrp); // Undo-Klammerung auf
578 	void EndUndo();                       // Undo-Klammerung zu
579 	void AddUndo(SdrUndoAction* pUndo);
580 	sal_uInt16 GetUndoBracketLevel() const                       { return nUndoLevel; }
581 	const SdrUndoGroup* GetAktUndoGroup() const              { return pAktUndoGroup; }
582 	// nur nach dem 1. BegUndo oder vor dem letzten EndUndo:
583 	void SetUndoComment(const String& rComment);
584 	void SetUndoComment(const String& rComment, const String& rObjDescr);
585 
586 	// Das Undo-Managment findet nur statt, wenn kein NotifyUndoAction-Handler
587 	// gesetzt ist.
588 	// Default ist 16. Minimaler MaxUndoActionCount ist 1!
589 	void  SetMaxUndoActionCount(sal_uIntPtr nAnz);
590 	sal_uIntPtr GetMaxUndoActionCount() const { return nMaxUndoCount; }
591 	void  ClearUndoBuffer();
592 	// UndoAction(0) ist die aktuelle (also die zuletzt eingegangene)
593 	sal_uIntPtr GetUndoActionCount() const                      { return pUndoStack!=NULL ? pUndoStack->Count() : 0; }
594 	const SfxUndoAction* GetUndoAction(sal_uIntPtr nNum) const  { return (SfxUndoAction*)(pUndoStack!=NULL ? pUndoStack->GetObject(nNum) : NULL); }
595 	// RedoAction(0) ist die aktuelle (also die des letzten Undo)
596 	sal_uIntPtr GetRedoActionCount() const                      { return pRedoStack!=NULL ? pRedoStack->Count() : 0; }
597 	const SfxUndoAction* GetRedoAction(sal_uIntPtr nNum) const  { return (SfxUndoAction*)(pRedoStack!=NULL ? pRedoStack->GetObject(nNum) : NULL); }
598 
599 	FASTBOOL Undo();
600 	FASTBOOL Redo();
601 	FASTBOOL Repeat(SfxRepeatTarget&);
602 
603 	// Hier kann die Applikation einen Handler setzen, der die auflaufenden
604 	// UndoActions einsammelt. Der Handler hat folgendes Aussehen:
605 	//   void __EXPORT NotifyUndoActionHdl(SfxUndoAction* pUndoAction);
606 	// Beim Aufruf des Handlers findet eine Eigentumsuebereignung statt; die
607 	// UndoAction gehoert somit dem Handler, nicht mehr dem SdrModel.
608 	void        SetNotifyUndoActionHdl(const Link& rLink)    { aUndoLink=rLink; }
609 	const Link& GetNotifyUndoActionHdl() const               { return aUndoLink; }
610 
611 	/** application can set it's own undo manager, BegUndo, EndUndo and AddUndoAction
612 		calls are routet to this interface if given */
613 	void SetSdrUndoManager( SfxUndoManager*	pUndoManager );
614     SfxUndoManager* GetSdrUndoManager() const;
615 
616 	/** applications can set their own undo factory to overide creation of
617 		undo actions. The SdrModel will become owner of the given SdrUndoFactory
618 		and delete it upon its destruction. */
619 	void SetSdrUndoFactory( SdrUndoFactory* pUndoFactory );
620 
621 	/** returns the models undo factory. This must be used to create
622 		undo actions for this model. */
623 	SdrUndoFactory& GetSdrUndoFactory() const;
624 
625 	// Hier kann man einen Handler setzen der beim Streamen mehrfach gerufen
626 	// wird und ungefaehre Auskunft ueber den Fortschreitungszustand der
627 	// Funktion gibt. Der Handler muss folgendes Aussehen haben:
628 	//   void __EXPORT class::IOProgressHdl(const sal_uInt16& nPercent);
629 	// Der erste Aufruf des Handlers erfolgt grundsaetzlich mit 0, der letzte
630 	// mit 100. Dazwischen erfolgen maximal 99 Aufrufe mit Werten 1...99.
631 	// Man kann also durchaus bei 0 den Progressbar Initiallisieren und bei
632 	// 100 wieder schliessen. Zu beachten sei, dass der Handler auch gerufen
633 	// wird, wenn die App Draw-Daten im officeweiten Draw-Exchange-Format
634 	// bereitstellt, denn dies geschieht durch streamen in einen MemoryStream.
635 	void        SetIOProgressHdl(const Link& rLink)          { aIOProgressLink=rLink; }
636 	const Link& GetIOProgressHdl() const                     { return aIOProgressLink; }
637 
638 	// Zugriffsmethoden fuer Paletten, Listen und Tabellen
639     void SetColorTableAtSdrModel(XColorListSharedPtr aTable);
640     XColorListSharedPtr GetColorTableFromSdrModel() const;
641 
642     void SetDashListAtSdrModel(XDashListSharedPtr aList);
643     XDashListSharedPtr GetDashListFromSdrModel() const;
644 
645     void SetLineEndListAtSdrModel(XLineEndListSharedPtr aList);
646     XLineEndListSharedPtr GetLineEndListFromSdrModel() const;
647 
648     void SetHatchListAtSdrModel(XHatchListSharedPtr aList);
649     XHatchListSharedPtr GetHatchListFromSdrModel() const;
650 
651     void SetGradientListAtSdrModel(XGradientListSharedPtr aList);
652     XGradientListSharedPtr GetGradientListFromSdrModel() const;
653 
654     void SetBitmapListAtSdrModel(XBitmapListSharedPtr aList);
655     XBitmapListSharedPtr GetBitmapListFromSdrModel() const;
656 
657 	// Der StyleSheetPool wird der DrawingEngine nur bekanntgemacht.
658 	// Zu loeschen hat ihn schliesslich der, der ihn auch konstruiert hat.
659 	SfxStyleSheetBasePool* GetStyleSheetPool() const         { return mxStyleSheetPool.get(); }
660 	void SetStyleSheetPool(SfxStyleSheetBasePool* pPool)     { mxStyleSheetPool=pPool; }
661 
662 	// Diese Methode fuert einen Konsistenzcheck auf die Struktur des Models
663 	// durch. Geprueft wird insbesondere die Verkettung von Verschachtelten
664 	// Gruppenobjekten, aber auch Stati wie bInserted sowie Model* und Page*
665 	// der Objects, SubLists und Pages. Bei korrekter Struktur liefert die
666 	// Methode sal_True, andernfalls FALSE.
667 	// Dieser Check steht nur zur Verfuegung, wenn die Engine mit DBG_UTIL
668 	// uebersetzt wurde. Andernfalls liefert die Methode immer TRUE. (ni)
669 	FASTBOOL CheckConsistence() const;
670 
671 	void 	SetStarDrawPreviewMode(sal_Bool bPreview);
672 	sal_Bool 	IsStarDrawPreviewMode() { return bStarDrawPreviewMode; }
673 
674 	SotStorage*	GetModelStorage() const { return pModelStorage; }
675 	void		SetModelStorage( SotStorage* pStor ) { pModelStorage = pStor; }
676 
677 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoModel();
678 	void setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel );
679 
680 	// these functions are used by the api to disable repaints during a
681 	// set of api calls.
682 	sal_Bool isLocked() const { return (sal_Bool)mbModelLocked; }
683 	void setLock( sal_Bool bLock );
684 
685 	void			SetForbiddenCharsTable( vos::ORef<SvxForbiddenCharactersTable> xForbiddenChars );
686 	vos::ORef<SvxForbiddenCharactersTable>	GetForbiddenCharsTable() const;
687 
688 	void SetCharCompressType( sal_uInt16 nType );
689 	sal_uInt16 GetCharCompressType() const { return mnCharCompressType; }
690 
691 	void SetKernAsianPunctuation( sal_Bool bEnabled );
692 	sal_Bool IsKernAsianPunctuation() const { return (sal_Bool)mbKernAsianPunctuation; }
693 
694     void SetAddExtLeading( sal_Bool bEnabled );
695     sal_Bool IsAddExtLeading() const { return (sal_Bool)mbAddExtLeading; }
696 
697 	void ReformatAllTextObjects();
698 
699 	FASTBOOL HasTransparentObjects( sal_Bool bCheckForAlphaChannel = sal_False ) const;
700 
701 	SdrOutliner* createOutliner( sal_uInt16 nOutlinerMode );
702 	void disposeOutliner( SdrOutliner* pOutliner );
703 
704 	sal_Bool IsWriter() const { return !bMyPool; }
705 
706 	/** returns the numbering type that is used to format page fields in drawing shapes */
707 	virtual SvxNumType GetPageNumType() const;
708 
709 	/** copies the items from the source set to the destination set. Both sets must have
710 		same ranges but can have different pools. If pNewModel is optional. If it is null,
711 		this model is used. */
712 
713 	void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel );
714 
715 	bool IsInDestruction() const;
716 
717     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId();
718 
719 	/** enables (true) or disables (false) recording of undo actions
720 		If undo actions are added while undo is disabled, they are deleted.
721 		Disabling undo does not clear the current undo buffer! */
722 	void EnableUndo( bool bEnable );
723 
724 	/** returns true if undo is currently enabled
725 		This returns false if undo was disabled using EnableUndo( false ) and
726 		also during the runtime of the Undo() and Redo() methods. */
727 	bool IsUndoEnabled() const;
728 };
729 
730 typedef tools::WeakReference< SdrModel > SdrModelWeakRef;
731 
732 ////////////////////////////////////////////////////////////////////////////////////////////////////
733 
734 #endif //_SVDMODEL_HXX
735 
736 /* /////////////////////////////////////////////////////////////////////////////////////////////////
737             +-----------+
738 			| SdrModel  |
739             +--+------+-+
740                |      +-----------+
741           +----+-----+            |
742 		  |   ...    |            |
743      +----+---+ +----+---+  +-----+--------+
744 	 |SdrPage | |SdrPage |  |SdrLayerAdmin |
745      +---+----+ +-+--+--++  +---+-------+--+
746          |        |  |  |       |       +-------------------+
747     +----+----+           +-----+-----+             +-------+-------+
748 	|   ...   |           |    ...    |             |      ...      |
749 +---+---+ +---+---+  +----+----+ +----+----+  +-----+------+ +------+-----+
750 |SdrObj | |SdrObj |  |SdrLayer | |SdrLayer |  |SdrLayerSet | |SdrLayerSet |
751 +-------+ +-------+  +---------+ +---------+  +------------+ +------------+
752 Die Klasse SdrModel ist der Kopf des Datenmodells der StarView Drawing-Engine.
753 
754 ///////////////////////////////////////////////////////////////////////////////////////////////// */
755 
756