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