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