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 mbAutomaticXPropertyListCreation; 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 die Grafiken 492 // von Grafikobjekten: 493 // - beim Laden eines Dokuments nicht sofort mitgeladen, 494 // sondern erst wenn sie gebraucht (z.B. angezeigt) werden. 495 // - ggf. wieder aus dem Speicher geworfen, falls Sie gerade 496 // nicht benoetigt werden. 497 // Damit das funktioniert, muss die virtuelle Methode 498 // GetDocumentStream() ueberladen werden. 499 // Default=FALSE. Flag ist nicht persistent. 500 FASTBOOL IsSwapGraphics() const { return bSwapGraphics; } 501 void SetSwapGraphics(FASTBOOL bJa=sal_True); 502 void SetSwapGraphicsMode(sal_uIntPtr nMode) { nSwapGraphicsMode = nMode; } 503 sal_uIntPtr GetSwapGraphicsMode() const { return nSwapGraphicsMode; } 504 505 FASTBOOL IsSaveOLEPreview() const { return bSaveOLEPreview; } 506 void SetSaveOLEPreview( FASTBOOL bSet) { bSaveOLEPreview = bSet; } 507 508 // Damit die Bildschirmausgabe von Bitmaps (insbesondere bei gedrehten) 509 // etwas schneller wird, werden sie gecachet. Diesen Cache kann man mit 510 // diesem Flag ein-/ausschalten. Beim naechsten Paint wird an den Objekten 511 // dann ggf. ein Image gemerkt bzw. freigegeben. Wandert ein Bitmapobjekt 512 // in's Undo, so wird der Cache fuer dieses Objekt sofort ausgeschaltet 513 // (Speicher sparen). 514 // Default=Cache eingeschaltet. Flag ist nicht persistent. 515 FASTBOOL IsBitmapCaching() const { return !bNoBitmapCaching; } 516 void SetBitmapCaching(FASTBOOL bJa=sal_True) { bNoBitmapCaching=!bJa; } 517 518 // Defaultmaessig (sal_False) kann man Textrahmen ohne Fuellung durch 519 // Mausklick selektieren. Nach Aktivierung dieses Flags trifft man sie 520 // nur noch in dem Bereich, wo sich auch tatsaechlich Text befindet. 521 FASTBOOL IsPickThroughTransparentTextFrames() const { return bTransparentTextFrames; } 522 void SetPickThroughTransparentTextFrames(FASTBOOL bOn) { bTransparentTextFrames=bOn; } 523 524 // Darf denn das Model ueberhaupt veraendert werden? 525 // Wird nur von den Possibility-Methoden der View ausgewerdet. 526 // Direkte Manipulationen am Model, ... berueksichtigen dieses Flag nicht. 527 // Sollte ueberladen werden und entsprechend des ReadOnly-Status des Files 528 // sal_True oder sal_False liefern (Methode wird oeffters gerufen, also ein Flag 529 // verwenden!). 530 virtual FASTBOOL IsReadOnly() const; 531 virtual void SetReadOnly(FASTBOOL bYes); 532 533 // Vermischen zweier SdrModel. Zu beachten sei, dass rSourceModel nicht 534 // const ist. Die Pages werden beim einfuegen nicht kopiert, sondern gemoved. 535 // rSourceModel ist anschliessend u.U. weitgehend leer. 536 // nFirstPageNum,nLastPageNum: Die aus rSourceModel zu uebernehmenden Seiten 537 // nDestPos..................: Einfuegeposition 538 // bMergeMasterPages.........: sal_True =benoetigte MasterPages werden aus 539 // rSourceModel ebenfalls uebernommen 540 // sal_False=Die MasterPageDescriptoren der Seiten 541 // aus rSourceModel werden auf die 542 // vorhandenen MasterPages gemappt. 543 // bUndo.....................: Fuer das Merging wird eine UndoAction generiert. 544 // Undo ist nur fuer das ZielModel, nicht fuer 545 // rSourceModel. 546 // bTreadSourceAsConst.......: sal_True=Das SourceModel wird nicht veraendert,. 547 // d.h die Seiten werden kopiert. 548 virtual void Merge(SdrModel& rSourceModel, 549 sal_uInt16 nFirstPageNum=0, sal_uInt16 nLastPageNum=0xFFFF, 550 sal_uInt16 nDestPos=0xFFFF, 551 FASTBOOL bMergeMasterPages=sal_False, FASTBOOL bAllMasterPages=sal_False, 552 FASTBOOL bUndo=sal_True, FASTBOOL bTreadSourceAsConst=sal_False); 553 554 // Ist wie Merge(SourceModel=DestModel,nFirst,nLast,nDest,sal_False,sal_False,bUndo,!bMoveNoCopy); 555 void CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum, 556 sal_uInt16 nDestPos, 557 FASTBOOL bUndo=sal_True, FASTBOOL bMoveNoCopy=sal_False); 558 559 // Mit BegUndo() / EndUndo() ist es moeglich beliebig viele UndoActions 560 // beliebig tief zu klammern. Als Kommentar der 561 // UndoAction wird der des ersten BegUndo(String) aller Klammerungen 562 // verwendet. Der NotifyUndoActionHdl wird in diesem Fall erst beim letzten 563 // EndUndo() gerufen. Bei einer leeren Klammerung wird keine UndoAction 564 // generiert. 565 // Alle direkten Aktionen am SdrModel erzeugen keine UndoActions, die 566 // Aktionen an der SdrView dagegen generieren solche. 567 void BegUndo(); // Undo-Klammerung auf 568 void BegUndo(const String& rComment); // Undo-Klammerung auf 569 void BegUndo(const String& rComment, const String& rObjDescr, SdrRepeatFunc eFunc=SDRREPFUNC_OBJ_NONE); // Undo-Klammerung auf 570 void BegUndo(SdrUndoGroup* pUndoGrp); // Undo-Klammerung auf 571 void EndUndo(); // Undo-Klammerung zu 572 void AddUndo(SdrUndoAction* pUndo); 573 sal_uInt16 GetUndoBracketLevel() const { return nUndoLevel; } 574 const SdrUndoGroup* GetAktUndoGroup() const { return pAktUndoGroup; } 575 // nur nach dem 1. BegUndo oder vor dem letzten EndUndo: 576 void SetUndoComment(const String& rComment); 577 void SetUndoComment(const String& rComment, const String& rObjDescr); 578 579 // Das Undo-Managment findet nur statt, wenn kein NotifyUndoAction-Handler 580 // gesetzt ist. 581 // Default ist 16. Minimaler MaxUndoActionCount ist 1! 582 void SetMaxUndoActionCount(sal_uIntPtr nAnz); 583 sal_uIntPtr GetMaxUndoActionCount() const { return nMaxUndoCount; } 584 void ClearUndoBuffer(); 585 // UndoAction(0) ist die aktuelle (also die zuletzt eingegangene) 586 sal_uIntPtr GetUndoActionCount() const { return pUndoStack!=NULL ? pUndoStack->Count() : 0; } 587 const SfxUndoAction* GetUndoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pUndoStack!=NULL ? pUndoStack->GetObject(nNum) : NULL); } 588 // RedoAction(0) ist die aktuelle (also die des letzten Undo) 589 sal_uIntPtr GetRedoActionCount() const { return pRedoStack!=NULL ? pRedoStack->Count() : 0; } 590 const SfxUndoAction* GetRedoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pRedoStack!=NULL ? pRedoStack->GetObject(nNum) : NULL); } 591 592 FASTBOOL Undo(); 593 FASTBOOL Redo(); 594 FASTBOOL Repeat(SfxRepeatTarget&); 595 596 // Hier kann die Applikation einen Handler setzen, der die auflaufenden 597 // UndoActions einsammelt. Der Handler hat folgendes Aussehen: 598 // void __EXPORT NotifyUndoActionHdl(SfxUndoAction* pUndoAction); 599 // Beim Aufruf des Handlers findet eine Eigentumsuebereignung statt; die 600 // UndoAction gehoert somit dem Handler, nicht mehr dem SdrModel. 601 void SetNotifyUndoActionHdl(const Link& rLink) { aUndoLink=rLink; } 602 const Link& GetNotifyUndoActionHdl() const { return aUndoLink; } 603 604 /** application can set it's own undo manager, BegUndo, EndUndo and AddUndoAction 605 calls are routet to this interface if given */ 606 void SetSdrUndoManager( SfxUndoManager* pUndoManager ); 607 SfxUndoManager* GetSdrUndoManager() const; 608 609 /** applications can set their own undo factory to overide creation of 610 undo actions. The SdrModel will become owner of the given SdrUndoFactory 611 and delete it upon its destruction. */ 612 void SetSdrUndoFactory( SdrUndoFactory* pUndoFactory ); 613 614 /** returns the models undo factory. This must be used to create 615 undo actions for this model. */ 616 SdrUndoFactory& GetSdrUndoFactory() const; 617 618 // Hier kann man einen Handler setzen der beim Streamen mehrfach gerufen 619 // wird und ungefaehre Auskunft ueber den Fortschreitungszustand der 620 // Funktion gibt. Der Handler muss folgendes Aussehen haben: 621 // void __EXPORT class::IOProgressHdl(const sal_uInt16& nPercent); 622 // Der erste Aufruf des Handlers erfolgt grundsaetzlich mit 0, der letzte 623 // mit 100. Dazwischen erfolgen maximal 99 Aufrufe mit Werten 1...99. 624 // Man kann also durchaus bei 0 den Progressbar Initiallisieren und bei 625 // 100 wieder schliessen. Zu beachten sei, dass der Handler auch gerufen 626 // wird, wenn die App Draw-Daten im officeweiten Draw-Exchange-Format 627 // bereitstellt, denn dies geschieht durch streamen in einen MemoryStream. 628 void SetIOProgressHdl(const Link& rLink) { aIOProgressLink=rLink; } 629 const Link& GetIOProgressHdl() const { return aIOProgressLink; } 630 631 // Zugriffsmethoden fuer Paletten, Listen und Tabellen 632 void SetColorTableAtSdrModel(XColorListSharedPtr aTable); 633 XColorListSharedPtr GetColorTableFromSdrModel() const; 634 635 void SetDashListAtSdrModel(XDashListSharedPtr aList); 636 XDashListSharedPtr GetDashListFromSdrModel() const; 637 638 void SetLineEndListAtSdrModel(XLineEndListSharedPtr aList); 639 XLineEndListSharedPtr GetLineEndListFromSdrModel() const; 640 641 void SetHatchListAtSdrModel(XHatchListSharedPtr aList); 642 XHatchListSharedPtr GetHatchListFromSdrModel() const; 643 644 void SetGradientListAtSdrModel(XGradientListSharedPtr aList); 645 XGradientListSharedPtr GetGradientListFromSdrModel() const; 646 647 void SetBitmapListAtSdrModel(XBitmapListSharedPtr aList); 648 XBitmapListSharedPtr GetBitmapListFromSdrModel() const; 649 650 // Der StyleSheetPool wird der DrawingEngine nur bekanntgemacht. 651 // Zu loeschen hat ihn schliesslich der, der ihn auch konstruiert hat. 652 SfxStyleSheetBasePool* GetStyleSheetPool() const { return mxStyleSheetPool.get(); } 653 void SetStyleSheetPool(SfxStyleSheetBasePool* pPool) { mxStyleSheetPool=pPool; } 654 655 // Diese Methode fuert einen Konsistenzcheck auf die Struktur des Models 656 // durch. Geprueft wird insbesondere die Verkettung von Verschachtelten 657 // Gruppenobjekten, aber auch Stati wie bInserted sowie Model* und Page* 658 // der Objects, SubLists und Pages. Bei korrekter Struktur liefert die 659 // Methode sal_True, andernfalls FALSE. 660 // Dieser Check steht nur zur Verfuegung, wenn die Engine mit DBG_UTIL 661 // uebersetzt wurde. Andernfalls liefert die Methode immer TRUE. (ni) 662 FASTBOOL CheckConsistence() const; 663 664 void SetStarDrawPreviewMode(sal_Bool bPreview); 665 sal_Bool IsStarDrawPreviewMode() { return bStarDrawPreviewMode; } 666 667 SotStorage* GetModelStorage() const { return pModelStorage; } 668 void SetModelStorage( SotStorage* pStor ) { pModelStorage = pStor; } 669 670 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoModel(); 671 void setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel ); 672 673 // these functions are used by the api to disable repaints during a 674 // set of api calls. 675 sal_Bool isLocked() const { return (sal_Bool)mbModelLocked; } 676 void setLock( sal_Bool bLock ); 677 678 void SetForbiddenCharsTable( vos::ORef<SvxForbiddenCharactersTable> xForbiddenChars ); 679 vos::ORef<SvxForbiddenCharactersTable> GetForbiddenCharsTable() const; 680 681 void SetCharCompressType( sal_uInt16 nType ); 682 sal_uInt16 GetCharCompressType() const { return mnCharCompressType; } 683 684 void SetKernAsianPunctuation( sal_Bool bEnabled ); 685 sal_Bool IsKernAsianPunctuation() const { return (sal_Bool)mbKernAsianPunctuation; } 686 687 void SetAddExtLeading( sal_Bool bEnabled ); 688 sal_Bool IsAddExtLeading() const { return (sal_Bool)mbAddExtLeading; } 689 690 void ReformatAllTextObjects(); 691 692 FASTBOOL HasTransparentObjects( sal_Bool bCheckForAlphaChannel = sal_False ) const; 693 694 SdrOutliner* createOutliner( sal_uInt16 nOutlinerMode ); 695 void disposeOutliner( SdrOutliner* pOutliner ); 696 697 sal_Bool IsWriter() const { return !bMyPool; } 698 699 /** returns the numbering type that is used to format page fields in drawing shapes */ 700 virtual SvxNumType GetPageNumType() const; 701 702 /** copies the items from the source set to the destination set. Both sets must have 703 same ranges but can have different pools. If pNewModel is optional. If it is null, 704 this model is used. */ 705 706 void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel ); 707 708 bool IsInDestruction() const; 709 710 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId(); 711 712 /** enables (true) or disables (false) recording of undo actions 713 If undo actions are added while undo is disabled, they are deleted. 714 Disabling undo does not clear the current undo buffer! */ 715 void EnableUndo( bool bEnable ); 716 717 /** returns true if undo is currently enabled 718 This returns false if undo was disabled using EnableUndo( false ) and 719 also during the runtime of the Undo() and Redo() methods. */ 720 bool IsUndoEnabled() const; 721 722 void SetAutomaticXPropertyListCreation(bool bNew) { mbAutomaticXPropertyListCreation = bNew; } 723 bool IsAutomaticXPropertyListCreation() const { return mbAutomaticXPropertyListCreation; } 724 }; 725 726 typedef tools::WeakReference< SdrModel > SdrModelWeakRef; 727 728 //////////////////////////////////////////////////////////////////////////////////////////////////// 729 730 #endif //_SVDMODEL_HXX 731 732 /* ///////////////////////////////////////////////////////////////////////////////////////////////// 733 +-----------+ 734 | SdrModel | 735 +--+------+-+ 736 | +-----------+ 737 +----+-----+ | 738 | ... | | 739 +----+---+ +----+---+ +-----+--------+ 740 |SdrPage | |SdrPage | |SdrLayerAdmin | 741 +---+----+ +-+--+--++ +---+-------+--+ 742 | | | | | +-------------------+ 743 +----+----+ +-----+-----+ +-------+-------+ 744 | ... | | ... | | ... | 745 +---+---+ +---+---+ +----+----+ +----+----+ +-----+------+ +------+-----+ 746 |SdrObj | |SdrObj | |SdrLayer | |SdrLayer | |SdrLayerSet | |SdrLayerSet | 747 +-------+ +-------+ +---------+ +---------+ +------------+ +------------+ 748 Die Klasse SdrModel ist der Kopf des Datenmodells der StarView Drawing-Engine. 749 750 ///////////////////////////////////////////////////////////////////////////////////////////////// */ 751 752