LibreOffice Module svx (master)  1
svdmodel.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SVX_SVDMODEL_HXX
21 #define INCLUDED_SVX_SVDMODEL_HXX
22 
23 #include <functional>
24 #include <memory>
25 #include <com/sun/star/uno/Sequence.hxx>
27 #include <editeng/outliner.hxx>
28 #include <rtl/ustring.hxx>
29 #include <tools/weakbase.h>
30 #include <svl/SfxBroadcaster.hxx>
31 #include <tools/fldunit.hxx>
32 #include <tools/fract.hxx>
33 #include <svl/hint.hxx>
34 #include <o3tl/enumarray.hxx>
35 
36 #include <svl/style.hxx>
37 #include <svx/xtable.hxx>
38 
39 class OutputDevice;
40 #include <svx/svdtypes.hxx>
41 #include <svx/svxdllapi.h>
42 
43 #include <rtl/ref.hxx>
44 #include <deque>
45 
46 #ifdef DBG_UTIL
47 // SdrObjectLifetimeWatchDog
48 #include <unordered_set>
49 #endif
50 
51 #define DEGREE_CHAR u'\x00B0' /* U+00B0 DEGREE SIGN */
52 
53 class SdrOutliner;
54 class SdrLayerAdmin;
55 class SdrObjList;
56 class SdrObject;
57 class SdrPage;
58 class SdrPageView;
59 class SdrTextObj;
60 class SdrUndoAction;
61 class SdrUndoGroup;
62 class AutoTimer;
63 class SfxItemPool;
64 class SfxItemSet;
65 class SfxRepeatTarget;
66 class SfxStyleSheet;
67 class SfxUndoAction;
68 class SfxUndoManager;
69 class XBitmapList;
70 class XColorList;
71 class XDashList;
72 class XGradientList;
73 class XHatchList;
74 class XLineEndList;
76 class SvNumberFormatter;
77 class SdrOutlinerCache;
78 class SdrUndoFactory;
79 class ImageMap;
80 class TextChain;
81 enum class CharCompressType;
82 namespace comphelper
83 {
84  class IEmbeddedHelper;
85  class LifecycleProxy;
86 }
87 namespace sfx2
88 {
89  class LinkManager;
90 }
91 
92 
93 enum class SdrHintKind
94 {
95  LayerChange, // changed layer definition
96  LayerOrderChange, // order of layer changed (Insert/Remove/ChangePos)
97  PageOrderChange, // order of pages (object pages or master pages) changed (Insert/Remove/ChangePos)
98  ObjectChange, // object changed
99  ObjectInserted, // new object inserted
100  ObjectRemoved, // symbol object removed from list
101  ModelCleared, // deleted the whole model (no pages exist anymore). not impl.
102  RefDeviceChange, // RefDevice changed
103  DefaultTabChange, // Default tabulator width changed
104  SwitchToPage, // #94278# UNDO/REDO at an object evtl. on another page
105  BeginEdit, // Is called after the object has entered text edit mode
106  EndEdit // Is called after the object has left text edit mode
107 };
108 
109 class SVX_DLLPUBLIC SdrHint final : public SfxHint
110 {
111 private:
113  const SdrObject* mpObj;
114  const SdrPage* mpPage;
115 
116 public:
117  explicit SdrHint(SdrHintKind eNewHint);
118  explicit SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj);
119  explicit SdrHint(SdrHintKind eNewHint, const SdrPage* pPage);
120  explicit SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj, const SdrPage* pPage);
121 
122  const SdrPage* GetPage() const { return mpPage;}
123  const SdrObject* GetObject() const { return mpObj;}
124  SdrHintKind GetKind() const { return meHint;}
125 };
126 
128 //
129 // SdrModel
130 // DlgEdModel
131 // FmFormModel
132 // ScDrawLayer
133 // SdDrawDocument
134 // SwDrawModel
135 // OReportModel
136 
137 struct SdrModelImpl;
138 
140 {
141 private:
142 #ifdef DBG_UTIL
143  // SdrObjectLifetimeWatchDog:
144  // Use maAllIncarnatedObjects to keep track of all SdrObjects incarnated using this SdrModel
145  // (what is now possible after the paradigm change that a SdrObject stays at a single SdrModel
146  // for it's whole lifetime).
147  // The two methods are exclusive, debug-only, only-accessible-by SdrObject accesses to else
148  // hidden/non-existing maAllIncarnatedObjects.
149  // SdrObject::SdrObject uses impAddIncarnatedSdrObjectToSdrModel, while SdrObject::~SdrObject
150  // uses impRemoveIncarnatedSdrObjectToSdrModel.
151  // There are two places which may trigger SAL_WARN warnings:
152  // - impRemoveIncarnatedSdrObjectToSdrModel when the to-be-removed SdrObject is not member of SdrModel
153  // - SdrModel::~SdrModel after all SdrObjects *should* be cleaned-up.
154  // SdrModel::~SdrModel will also - for convenience - Free the non-deleted SdrObjects if there
155  // are any.
156  // Using std::unordered_set will use quasi constant access times, so this watchdog will not
157  // be expensive. Nonetheless, only use with debug code. It may be seductive to use this in
158  // product code, too, especially if it will indeed trigger - but its intention is clearly
159  // to find/identify MemoryLeaks caused by SdrObjects
160  friend void impAddIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
161  friend void impRemoveIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
162  std::unordered_set< const SdrObject* > maAllIncarnatedObjects;
163 #endif
164 protected:
165  std::vector<SdrPage*> maMaPag; // master pages
166  std::vector<SdrPage*> maPages;
167  std::function<void(std::unique_ptr<SdrUndoAction>)> m_aUndoLink; // link to a NotifyUndo-Handler
168  Size m_aMaxObjSize; // e.g. for auto-growing text
169  Fraction m_aObjUnit; // description of the coordinate units for ClipBoard, Drag&Drop, ...
170  MapUnit m_eObjUnit; // see above
171  FieldUnit m_eUIUnit; // unit, scale (e.g. 1/1000) for the UI (status bar) is set by ImpSetUIUnit()
172  Fraction m_aUIScale; // see above
173  OUString m_aUIUnitStr; // see above
174  Fraction m_aUIUnitFact; // see above
175  int m_nUIUnitDecimalMark; // see above
176 
177  std::unique_ptr<SdrLayerAdmin> m_pLayerAdmin;
180  m_pEmbeddedHelper; // helper for embedded objects to get rid of the SfxObjectShell
181  std::unique_ptr<SdrOutliner> m_pDrawOutliner; // an Outliner for outputting text
182  std::unique_ptr<SdrOutliner> m_pHitTestOutliner;// an Outliner for the HitTest
183  std::unique_ptr<SdrOutliner> m_pChainingOutliner; // an Outliner for chaining overflowing text
184  sal_Int32 mnDefTextHgt; // Default text height in logical units
185  VclPtr<OutputDevice> m_pRefOutDev; // ReferenceDevice for the EditEngine
190  std::unique_ptr<std::deque<std::unique_ptr<SfxUndoAction>>> m_pUndoStack;
191  std::unique_ptr<std::deque<std::unique_ptr<SfxUndoAction>>> m_pRedoStack;
192  std::unique_ptr<SdrUndoGroup> m_pCurrentUndoGroup; // For multi-level
193  sal_uInt16 m_nUndoLevel; // undo nesting
194  bool m_bMyPool:1; // to clean up pMyPool from 303a
195  bool mbUndoEnabled:1; // If false no undo is recorded or we are during the execution of an undo action
196  bool mbChanged:1;
197  bool m_bPagNumsDirty:1;
198  bool m_bMPgNumsDirty:1;
199  bool m_bTransportContainer:1; // doc is temporary object container, no display (e.g. clipboard)
200  bool m_bReadOnly:1;
201  bool m_bTransparentTextFrames:1;
202  bool m_bSwapGraphics:1;
203  bool m_bPasteResize:1; // Objects are being resized due to Paste with different MapMode
204  bool m_bStarDrawPreviewMode:1;
205  bool mbDisableTextEditUsesCommonUndoManager:1;
207  sal_uInt32 m_nMaxUndoCount;
208 
209  std::unique_ptr<TextChain> m_pTextChain;
210 
211 
212 public:
213  std::shared_ptr<SvxForbiddenCharactersTable> mpForbiddenCharactersTable;
214 
215  std::unique_ptr<SdrOutlinerCache> mpOutlinerCache;
216  //get a vector of all the SdrOutliner belonging to the model
217  std::vector<SdrOutliner*> GetActiveOutliners() const;
218  std::unique_ptr<SdrModelImpl> mpImpl;
220  sal_uInt16 mnHandoutPageCount;
225 
226  // Color, Dash, Line-End, Hatch, Gradient, Bitmap property lists ...
228 
229  sal_uInt16 getHandoutPageCount() const { return mnHandoutPageCount; }
230  void setHandoutPageCount( sal_uInt16 nHandoutPageCount ) { mnHandoutPageCount = nHandoutPageCount; }
231 
232  // Adapt to given Size and Borders scaling all contained data, maybe
233  // including PresObj's in higher derivations
234  virtual void adaptSizeAndBorderForAllPages(
235  const Size& rNewSize,
236  long nLeft = 0,
237  long nRight = 0,
238  long nUpper = 0,
239  long nLower = 0);
240 
241 protected:
242  virtual css::uno::Reference< css::uno::XInterface > createUnoModel();
243 
244 private:
245  SdrModel(const SdrModel& rSrcModel) = delete;
246  void operator=(const SdrModel& rSrcModel) = delete;
247  bool operator==(const SdrModel& rCmpModel) const = delete;
248  SVX_DLLPRIVATE void ImpPostUndoAction(std::unique_ptr<SdrUndoAction> pUndo);
249  SVX_DLLPRIVATE void ImpSetUIUnit();
250  SVX_DLLPRIVATE void ImpSetOutlinerDefaults( SdrOutliner* pOutliner, bool bInit = false );
251  SVX_DLLPRIVATE void ImpReformatAllTextObjects();
252  SVX_DLLPRIVATE void ImpReformatAllEdgeObjects();
253  SVX_DLLPRIVATE void ImpCreateTables(bool bDisablePropertyFiles);
254 
255  SVX_DLLPRIVATE void ImpCtor(
256  SfxItemPool* pPool,
258  bool bDisablePropertyFiles);
259 
260  // this is a weak reference to a possible living api wrapper for this model
261  css::uno::Reference< css::uno::XInterface > mxUnoModel;
262 
263  // used to disable unique name checking during page move
264  bool mbMakePageObjectsNamesUnique = true;
265 
266 public:
267  SVX_DLLPRIVATE virtual bool IsCreatingDataObj() const { return false; }
268  bool IsTransportContainer() const { return m_bTransportContainer; }
269  bool IsPasteResize() const { return m_bPasteResize; }
270  void SetPasteResize(bool bOn) { m_bPasteResize=bOn; }
271  // If a custom Pool is put here, the class will call methods
272  // on it (Put(), Remove()). On disposal of SdrModel the pool
273  // will be deleted with delete.
274  // If you give NULL instead, it will create an own pool (SdrItemPool)
275  // which will also be disposed in the destructor.
276  // If you do use a custom Pool, make sure you inherit from SdrItemPool,
277  // if you want to use symbol objects inherited from SdrAttrObj.
278  // If, however, you use objects inheriting from SdrObject you are free
279  // to chose a pool of your liking.
280  //
281  // tdf#118731 a bDisablePropertyFiles of true will disable ability to load
282  // XPropertyFiles describing defaults. Useful for UI preview widgets
283  explicit SdrModel(
284  SfxItemPool* pPool = nullptr,
285  ::comphelper::IEmbeddedHelper* pPers = nullptr,
286  bool bDisablePropertyFiles = false);
287  virtual ~SdrModel() override;
288  void ClearModel(bool bCalledFromDestructor);
289 
290  // Override this to enable the Swap/LoadOnDemand of graphics.
291  // If rbDeleteAfterUse is set to sal_True the SvStream instance from
292  // the caller will be disposed after use.
293  // If this method returns NULL, a temporary file will be allocated for
294  // swapping.
295  // The stream from which the model was loaded or in which is was saved last
296  // needs to be delivered
297  virtual css::uno::Reference<
298  css::embed::XStorage> GetDocumentStorage() const;
299  css::uno::Reference<
300  css::io::XInputStream >
301  GetDocumentStream(OUString const& rURL,
302  ::comphelper::LifecycleProxy const & rProxy) const;
303  // Change the template attributes of the symbol objects to hard attributes
304  void BurnInStyleSheetAttributes();
305  // If you inherit from SdrPage you also need to inherit from SdrModel
306  // and implement both VM AllocPage() and AllocModel()...
307  virtual SdrPage* AllocPage(bool bMasterPage);
308  virtual SdrModel* AllocModel() const;
309 
310  // Changes on the layers set the modified flag and broadcast on the model!
311  const SdrLayerAdmin& GetLayerAdmin() const { return *m_pLayerAdmin; }
312  SdrLayerAdmin& GetLayerAdmin() { return *m_pLayerAdmin; }
313 
314  const SfxItemPool& GetItemPool() const { return *m_pItemPool; }
315  SfxItemPool& GetItemPool() { return *m_pItemPool; }
316 
317  SdrOutliner& GetDrawOutliner(const SdrTextObj* pObj=nullptr) const;
318 
319  SdrOutliner& GetHitTestOutliner() const { return *m_pHitTestOutliner; }
320  const SdrTextObj* GetFormattingTextObj() const;
321  // put the TextDefaults (Font,Height,Color) in a Set
322  void SetTextDefaults() const;
323  static void SetTextDefaults( SfxItemPool* pItemPool, sal_Int32 nDefTextHgt );
324 
325  SdrOutliner& GetChainingOutliner(const SdrTextObj* pObj) const;
326  TextChain * GetTextChain() const;
327 
328  // ReferenceDevice for the EditEngine
329  void SetRefDevice(OutputDevice* pDev);
330  OutputDevice* GetRefDevice() const { return m_pRefOutDev.get(); }
331  // If a new MapMode is set on the RefDevice (or similar)
332  void RefDeviceChanged(); // not yet implemented
333  // default font height in logical units
334  void SetDefaultFontHeight(sal_Int32 nVal);
335  // default tabulator width for the EditEngine
336  void SetDefaultTabulator(sal_uInt16 nVal);
337  sal_uInt16 GetDefaultTabulator() const { return m_nDefaultTabulator; }
338 
339  // The DefaultStyleSheet will be used in every symbol object which is inserted
340  // in this model and does not have a StyleSheet set.
341  SfxStyleSheet* GetDefaultStyleSheet() const { return m_pDefaultStyleSheet; }
342  void SetDefaultStyleSheet(SfxStyleSheet* pDefSS) { m_pDefaultStyleSheet = pDefSS; }
343 
344  // #i119287# default StyleSheet for SdrGrafObj and SdrOle2Obj
345  SfxStyleSheet* GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj() const { return mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; }
346  void SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(SfxStyleSheet* pDefSS) { mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj = pDefSS; }
347 
348  sfx2::LinkManager* GetLinkManager() { return m_pLinkManager; }
349  void SetLinkManager( sfx2::LinkManager* pLinkMgr ) { m_pLinkManager = pLinkMgr; }
350 
351  ::comphelper::IEmbeddedHelper* GetPersist() const { return m_pEmbeddedHelper; }
352  void SetPersist( ::comphelper::IEmbeddedHelper *p ) { m_pEmbeddedHelper = p; }
353 
354  // Unit for the symbol coordination
355  // Default is 1 logical unit = 1/100mm (Unit=MapUnit::Map100thMM, Fract=(1,1)).
356  // Examples:
357  // MapUnit::MapPoint, Fraction(72,1) : 1 log Einh = 72 Point = 1 Inch
358  // MapUnit::MapPoint, Fraction(1,20) : 1 log Einh = 1/20 Point = 1 Twip
359  // MapUnit::MapTwip, Fraction(1,1) : 1 log Einh = 1 Twip
360  // MapUnit::Map100thMM, Fraction(1,10) : 1 log Einh = 1/1000mm
361  // MapUnit::MapMM, Fraction(1000,1) : 1 log Einh = 1000mm = 1m
362  // MapUnit::MapCM, Fraction(100,1) : 1 log Einh = 100cm = 1m
363  // MapUnit::MapCM, Fraction(100000,1): 1 log Einh = 100000cm = 1km
364  // (FWIW: you cannot represent light years).
365  // The scaling unit is needed for the Engine to serve the Clipboard
366  // with the correct sizes.
367  MapUnit GetScaleUnit() const { return m_eObjUnit; }
368  void SetScaleUnit(MapUnit eMap);
369  const Fraction& GetScaleFraction() const { return m_aObjUnit; }
370  void SetScaleFraction(const Fraction& rFrac);
371  // Setting both simultaneously performs a little better
372  void SetScaleUnit(MapUnit eMap, const Fraction& rFrac);
373 
374  // maximal size e.g. for auto growing texts
375  const Size& GetMaxObjSize() const { return m_aMaxObjSize; }
376  void SetMaxObjSize(const Size& rSiz) { m_aMaxObjSize=rSiz; }
377 
378  // For the View! to display sane numbers in the status bar: Default is mm.
379  void SetUIUnit(FieldUnit eUnit);
380  FieldUnit GetUIUnit() const { return m_eUIUnit; }
381  // The scale of the drawing. Default 1/1.
382  void SetUIScale(const Fraction& rScale);
383  const Fraction& GetUIScale() const { return m_aUIScale; }
384  // Setting both simultaneously performs a little better
385  void SetUIUnit(FieldUnit eUnit, const Fraction& rScale);
386 
387  static OUString GetUnitString(FieldUnit eUnit);
388  OUString GetMetricString(long nVal, bool bNoUnitChars = false, sal_Int32 nNumDigits = -1) const;
389  static OUString GetAngleString(long nAngle);
390  static OUString GetPercentString(const Fraction& rVal);
391 
392  // RecalcPageNums is ordinarily only called by the Page.
393  bool IsPagNumsDirty() const { return m_bPagNumsDirty; };
394  bool IsMPgNumsDirty() const { return m_bMPgNumsDirty; };
395  void RecalcPageNums(bool bMaster);
396  // After the Insert the Page belongs to the SdrModel.
397  virtual void InsertPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
398  virtual void DeletePage(sal_uInt16 nPgNum);
399  // Remove means transferring ownership to the caller (opposite of Insert)
400  virtual SdrPage* RemovePage(sal_uInt16 nPgNum);
401  virtual void MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
402  const SdrPage* GetPage(sal_uInt16 nPgNum) const;
403  SdrPage* GetPage(sal_uInt16 nPgNum);
404  sal_uInt16 GetPageCount() const;
405  virtual void PageListChanged();
406 
407  // Masterpages
408  virtual void InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
409  void DeleteMasterPage(sal_uInt16 nPgNum);
410  // Remove means transferring ownership to the caller (opposite of Insert)
411  virtual SdrPage* RemoveMasterPage(sal_uInt16 nPgNum);
412  void MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
413  const SdrPage* GetMasterPage(sal_uInt16 nPgNum) const;
414  SdrPage* GetMasterPage(sal_uInt16 nPgNum);
415  sal_uInt16 GetMasterPageCount() const;
416  virtual void MasterPageListChanged();
417 
418  // modified flag. Is set automatically when something changes on the Pages
419  // symbol objects. You need to reset it yourself, however, e.g. on Save().
420  bool IsChanged() const { return mbChanged; }
421  virtual void SetChanged(bool bFlg = true);
422 
423  // If set to sal_True, graphics from graphics objects will:
424  // - not be loaded immediately when loading a document,
425  // but only once they are needed (e.g. displayed).
426  // - be pruned from memory if they are not needed.
427  // For that to work, override the virtual method GetDocumentStream().
428  // Default=FALSE. Flag is not persistent.
429  bool IsSwapGraphics() const { return m_bSwapGraphics; }
430  void SetSwapGraphics();
431 
432  // Text frames without filling can be select with a mouse click by default (sal_False).
433  // With this flag set to true you can hit them only in the area in which text is to be
434  // found.
435  bool IsPickThroughTransparentTextFrames() const { return m_bTransparentTextFrames; }
436  void SetPickThroughTransparentTextFrames(bool bOn) { m_bTransparentTextFrames=bOn; }
437 
438  // Can the model be changed at all?
439  // Is only evaluated by the possibility methods of the View.
440  // Direct manipulations on the model, ... do not respect this flag.
441  // Override this and return the appropriate ReadOnly status
442  // of the files, i.e. true or false. (Method is called multiple
443  // times, so use one flag only!)
444  virtual bool IsReadOnly() const;
445  void SetReadOnly(bool bYes);
446 
447  // Mixing two SdrModels. Mind that rSourceModel is not const.
448  // The pages will not be copied but moved, when inserted.
449  // rSourceModel may very well be empty afterwards.
450  // nFirstPageNum,nLastPageNum: The pages to take from rSourceModel
451  // nDestPos..................: position to insert
452  // bMergeMasterPages.........: sal_True = needed MasterPages will be taken
453  // from rSourceModel
454  // sal_False= the MasterPageDescriptors of
455  // the pages of the rSourceModel will be
456  // mapped on the existing MasterPages.
457  // bUndo.....................: An undo action is generated for the merging.
458  // Undo is only for the target model, not for the
459  // rSourceModel.
460  // bTreadSourceAsConst.......: sal_True=the SourceModel will not be changed,
461  // so pages will be copied.
462  virtual void Merge(SdrModel& rSourceModel,
463  sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
464  sal_uInt16 nDestPos,
465  bool bMergeMasterPages, bool bAllMasterPages,
466  bool bUndo = true, bool bTreadSourceAsConst = false);
467 
468  // Behaves like Merge(SourceModel=DestModel,nFirst,nLast,nDest,sal_False,sal_False,bUndo,!bMoveNoCopy);
469  void CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
470  sal_uInt16 nDestPos,
471  bool bUndo, bool bMoveNoCopy);
472 
473  // BegUndo() / EndUndo() enables you to group arbitrarily many UndoActions
474  // arbitrarily deeply. As comment for the UndoAction the first BegUndo(String) of all
475  // nestings will be used.
476  // In that case the NotifyUndoActionHdl will be called on the last EndUndo().
477  // No UndoAction will be generated for an empty group.
478  // All direct modifications on the SdrModel do not create an UndoActions.
479  // Actions on the SdrView however do generate those.
480  void BegUndo(); // open Undo group
481  void BegUndo(const OUString& rComment); // open Undo group
482  void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc); // open Undo group
483  void EndUndo(); // close Undo group
484  void AddUndo(std::unique_ptr<SdrUndoAction> pUndo);
485  sal_uInt16 GetUndoBracketLevel() const { return m_nUndoLevel; }
486  // only after the first BegUndo or before the last EndUndo:
487  void SetUndoComment(const OUString& rComment);
488  void SetUndoComment(const OUString& rComment, const OUString& rObjDescr);
489 
490  // The Undo management is only done if NotifyUndoAction-Handler is not set.
491  // Default is 16. Minimal MaxUndoActionCount is 1.
492  void SetMaxUndoActionCount(sal_uInt32 nCount);
493  void ClearUndoBuffer();
494 
495  bool HasUndoActions() const;
496  bool HasRedoActions() const;
497  void Undo();
498  void Redo();
499  void Repeat(SfxRepeatTarget&);
500 
501  // The application can set a handler here which collects the UndoActions einsammelt.
502  // The handler has the following signature:
503  // void NotifyUndoActionHdl(SfxUndoAction* pUndoAction);
504  // When calling the handler ownership is transferred;
505  // The UndoAction belongs to the Handler, not the SdrModel.
506  void SetNotifyUndoActionHdl(const std::function<void(std::unique_ptr<SdrUndoAction>)>& rLink) { m_aUndoLink=rLink; }
507 
510  void SetSdrUndoManager( SfxUndoManager* pUndoManager );
511  SfxUndoManager* GetSdrUndoManager() const;
512 
516  void SetSdrUndoFactory( SdrUndoFactory* pUndoFactory );
517 
520  SdrUndoFactory& GetSdrUndoFactory() const;
521 
522  // Accessor methods for Palettes, Lists and Tables
523  // FIXME: this badly needs re-factoring...
524  const XPropertyListRef& GetPropertyList( XPropertyListType t ) const { return maProperties[ t ]; }
525  void SetPropertyList( XPropertyListRef const & p ) { maProperties[ p->Type() ] = p; }
526 
527  // friendlier helpers
535 
536  // The DrawingEngine only references the StyleSheetPool, whoever
537  // made it needs to delete it.
538  SfxStyleSheetBasePool* GetStyleSheetPool() const { return mxStyleSheetPool.get(); }
539  void SetStyleSheetPool(SfxStyleSheetBasePool* pPool) { mxStyleSheetPool=pPool; }
540 
541  void SetStarDrawPreviewMode(bool bPreview);
542  bool IsStarDrawPreviewMode() const { return m_bStarDrawPreviewMode; }
543 
544  bool GetDisableTextEditUsesCommonUndoManager() const { return mbDisableTextEditUsesCommonUndoManager; }
545  void SetDisableTextEditUsesCommonUndoManager(bool bNew) { mbDisableTextEditUsesCommonUndoManager = bNew; }
546 
547  css::uno::Reference< css::uno::XInterface > const & getUnoModel();
548  void setUnoModel( const css::uno::Reference< css::uno::XInterface >& xModel );
549 
550  // these functions are used by the api to disable repaints during a
551  // set of api calls.
552  bool isLocked() const { return mbModelLocked; }
553  void setLock( bool bLock );
554 
555  void SetForbiddenCharsTable( const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars );
556  const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharsTable() const { return mpForbiddenCharactersTable;}
557 
558  void SetCharCompressType( CharCompressType nType );
559  CharCompressType GetCharCompressType() const { return mnCharCompressType; }
560 
561  void SetKernAsianPunctuation( bool bEnabled );
562  bool IsKernAsianPunctuation() const { return mbKernAsianPunctuation; }
563 
564  void SetAddExtLeading( bool bEnabled );
565  bool IsAddExtLeading() const { return mbAddExtLeading; }
566 
567  // tdf#99729 compatibility flag
568  void SetAnchoredTextOverflowLegacy(bool bEnabled);
569  bool IsAnchoredTextOverflowLegacy() const;
570 
571  void ReformatAllTextObjects();
572 
573  std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode );
574  void disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner );
575 
576  bool IsWriter() const { return !m_bMyPool; }
577 
578  // Used as a fallback in *::ReadUserDataSequence() to process common properties
579  void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue);
580  void WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues);
581 
583  virtual SvxNumType GetPageNumType() const;
584 
587  static void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel );
588 
589  bool IsInDestruction() const { return mbInDestruction;}
590 
591  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
592 
596  void EnableUndo( bool bEnable );
597 
601  bool IsUndoEnabled() const;
602 
603  // used to prevent object name change during page move
604  bool DoesMakePageObjectsNamesUnique() const { return mbMakePageObjectsNamesUnique; }
605  void DoMakePageObjectsNamesUnique(bool bDo) { mbMakePageObjectsNamesUnique = bDo; }
606 
607  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
608 };
609 
610 
611 #endif // INCLUDED_SVX_SVDMODEL_HXX
612 
613 /*
614  +-----------+
615  | SdrModel |
616  +--+------+-+
617  | +-----------+
618  +----+-----+ |
619  | ... | |
620  +----+---+ +----+---+ +-----+--------+
621  |SdrPage | |SdrPage | |SdrLayerAdmin |
622  +---+----+ +-+--+--++ +---+-------+--+
623  | | | | | +-------------------+
624  +----+----+ +-----+-----+ +-------+-------+
625  | ... | | ... | | ... |
626 +---+---+ +---+---+ +----+----+ +----+----+ +-----+------+ +------+-----+
627 |SdrObj | |SdrObj | |SdrLayer | |SdrLayer | |SdrLayerSet | |SdrLayerSet |
628 +-------+ +-------+ +---------+ +---------+ +------------+ +------------+
629 This class: SdrModel is the head of the data models for the StarView Drawing Engine.
630 
632 
633 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetUnitString(long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep)
Definition: dlgunit.hxx:26
FieldUnit
std::unique_ptr< SdrOutliner > m_pHitTestOutliner
Definition: svdmodel.hxx:182
OutlinerMode
SdrHintKind GetKind() const
Definition: svdmodel.hxx:124
CharCompressType GetCharCompressType() const
Definition: svdmodel.hxx:559
const XPropertyListRef & GetPropertyList(XPropertyListType t) const
Definition: svdmodel.hxx:524
void SetStyleSheetPool(SfxStyleSheetBasePool *pPool)
Definition: svdmodel.hxx:539
bool IsKernAsianPunctuation() const
Definition: svdmodel.hxx:562
static XLineEndListRef AsLineEndList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:395
bool IsStarDrawPreviewMode() const
Definition: svdmodel.hxx:542
const Fraction & GetScaleFraction() const
Definition: svdmodel.hxx:369
bool IsReadOnly(const OUString &rURL, bool *pbExist)
std::unique_ptr< std::deque< std::unique_ptr< SfxUndoAction > > > m_pUndoStack
Definition: svdmodel.hxx:190
std::unique_ptr< SdrUndoGroup > m_pCurrentUndoGroup
Definition: svdmodel.hxx:192
void impAddIncarnatedSdrObjectToSdrModel(const SdrObject &rSdrObject, SdrModel &rSdrModel)
Definition: svdobj.cxx:343
static XBitmapListRef AsBitmapList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:389
void SetNotifyUndoActionHdl(const std::function< void(std::unique_ptr< SdrUndoAction >)> &rLink)
Definition: svdmodel.hxx:506
std::vector< SdrPage * > maMaPag
Definition: svdmodel.hxx:165
Abstract base class (ABC) for all UndoActions of DrawingEngine.
Definition: svdundo.hxx:53
SdrHintKind
Definition: svdmodel.hxx:93
rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool
Definition: svdmodel.hxx:186
bool IsPickThroughTransparentTextFrames() const
Definition: svdmodel.hxx:435
std::unique_ptr< SdrOutlinerCache > mpOutlinerCache
Definition: svdmodel.hxx:215
XDashListRef GetDashList() const
Definition: svdmodel.hxx:528
bool IsSwapGraphics() const
Definition: svdmodel.hxx:429
SfxStyleSheet * mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj
Definition: svdmodel.hxx:188
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
const Size & GetMaxObjSize() const
Definition: svdmodel.hxx:375
struct _xmlTextWriter * xmlTextWriterPtr
sal_uInt16 m_nUndoLevel
Definition: svdmodel.hxx:193
OutputDevice * GetRefDevice() const
Definition: svdmodel.hxx:330
XPatternListRef GetPatternList() const
Definition: svdmodel.hxx:532
SvxNumType
void impRemoveIncarnatedSdrObjectToSdrModel(const SdrObject &rSdrObject, SdrModel &rSdrModel)
Definition: svdobj.cxx:347
const SdrObject * mpObj
Definition: svdmodel.hxx:113
void SetDefaultStyleSheet(SfxStyleSheet *pDefSS)
Definition: svdmodel.hxx:342
SfxStyleSheet * GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj() const
Definition: svdmodel.hxx:345
std::unique_ptr< SdrOutliner > m_pDrawOutliner
Definition: svdmodel.hxx:181
static XPatternListRef AsPatternList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:392
VclPtr< OutputDevice > m_pRefOutDev
Definition: svdmodel.hxx:185
MapUnit GetScaleUnit() const
Definition: svdmodel.hxx:367
SdrRepeatFunc
Definition: svdtypes.hxx:68
void setHandoutPageCount(sal_uInt16 nHandoutPageCount)
Definition: svdmodel.hxx:230
void SetMaxObjSize(const Size &rSiz)
Definition: svdmodel.hxx:376
css::uno::Reference< css::uno::XInterface > mxUnoModel
Definition: svdmodel.hxx:261
Fraction m_aObjUnit
Definition: svdmodel.hxx:169
bool isLocked() const
Definition: svdmodel.hxx:552
XLineEndListRef GetLineEndList() const
Definition: svdmodel.hxx:533
sal_uInt32 m_nMaxUndoCount
Definition: svdmodel.hxx:207
sfx2::LinkManager * GetLinkManager()
Definition: svdmodel.hxx:348
int m_nUIUnitDecimalMark
Definition: svdmodel.hxx:175
FieldUnit GetUIUnit() const
Definition: svdmodel.hxx:380
SdrOutliner & GetHitTestOutliner() const
Definition: svdmodel.hxx:319
static XColorListRef AsColorList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:386
std::unordered_set< const SdrObject * > maAllIncarnatedObjects
Definition: svdmodel.hxx:162
bool mbKernAsianPunctuation
Definition: svdmodel.hxx:222
XPropertyListType
Definition: xtable.hxx:131
std::unique_ptr< TextChain > m_pTextChain
Definition: svdmodel.hxx:209
bool IsAddExtLeading() const
Definition: svdmodel.hxx:565
CharCompressType
bool IsWriter() const
Definition: svdmodel.hxx:576
bool IsPasteResize() const
Definition: svdmodel.hxx:269
bool mbAddExtLeading
Definition: svdmodel.hxx:223
sal_uInt16 mnHandoutPageCount
Definition: svdmodel.hxx:220
sal_uInt16 getHandoutPageCount() const
Definition: svdmodel.hxx:229
XGradientListRef GetGradientList() const
Definition: svdmodel.hxx:534
SdrLayerAdmin & GetLayerAdmin()
Definition: svdmodel.hxx:312
The SdrUndoFactory can be set and retrieved from the SdrModel.
Definition: svdundo.hxx:702
bool const m_bReadOnly
SdrHintKind const meHint
Definition: svdmodel.hxx:112
void SetLinkManager(sfx2::LinkManager *pLinkMgr)
Definition: svdmodel.hxx:349
Fraction m_aUIScale
Definition: svdmodel.hxx:172
static bool bInit
Definition: objfac3d.cxx:31
Size m_aMaxObjSize
Definition: svdmodel.hxx:168
sal_uInt16 GetUndoBracketLevel() const
Definition: svdmodel.hxx:485
std::shared_ptr< SvxForbiddenCharactersTable > mpForbiddenCharactersTable
Definition: svdmodel.hxx:213
Abstract DrawObject.
Definition: svdobj.hxx:312
sal_uInt16 m_nDefaultTabulator
Definition: svdmodel.hxx:206
void SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(SfxStyleSheet *pDefSS)
Definition: svdmodel.hxx:346
void SetPickThroughTransparentTextFrames(bool bOn)
Definition: svdmodel.hxx:436
bool IsChanged() const
Definition: svdmodel.hxx:420
bool mbInDestruction
Definition: svdmodel.hxx:224
Aggregation of arbitrarily many UndoActions to a single UndoAction.
Definition: svdundo.hxx:85
bool GetDisableTextEditUsesCommonUndoManager() const
Definition: svdmodel.hxx:544
void SetPasteResize(bool bOn)
Definition: svdmodel.hxx:270
bool mbModelLocked
Definition: svdmodel.hxx:221
bool DoesMakePageObjectsNamesUnique() const
Definition: svdmodel.hxx:604
SfxItemPool * m_pItemPool
Definition: svdmodel.hxx:178
const std::shared_ptr< SvxForbiddenCharactersTable > & GetForbiddenCharsTable() const
Definition: svdmodel.hxx:556
const Fraction & GetUIScale() const
Definition: svdmodel.hxx:383
MapUnit m_eObjUnit
Definition: svdmodel.hxx:170
static XGradientListRef AsGradientList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:398
bool IsMPgNumsDirty() const
Definition: svdmodel.hxx:394
XHatchListRef GetHatchList() const
Definition: svdmodel.hxx:529
std::unique_ptr< SdrOutliner > m_pChainingOutliner
Definition: svdmodel.hxx:183
FieldUnit m_eUIUnit
Definition: svdmodel.hxx:171
SfxStyleSheet * m_pDefaultStyleSheet
Definition: svdmodel.hxx:187
XPropertyListType const t
Definition: xtable.cxx:373
SfxStyleSheet * GetDefaultStyleSheet() const
Definition: svdmodel.hxx:341
CharCompressType mnCharCompressType
Definition: svdmodel.hxx:219
::comphelper::IEmbeddedHelper * GetPersist() const
Definition: svdmodel.hxx:351
SfxStyleSheetBasePool * GetStyleSheetPool() const
Definition: svdmodel.hxx:538
sfx2::LinkManager * m_pLinkManager
Definition: svdmodel.hxx:189
std::unique_ptr< SdrModelImpl > mpImpl
Definition: svdmodel.hxx:218
Fraction m_aUIUnitFact
Definition: svdmodel.hxx:174
comphelper::IEmbeddedHelper * m_pEmbeddedHelper
Definition: svdmodel.hxx:180
bool mbChanged
std::unique_ptr< SdrLayerAdmin > m_pLayerAdmin
Definition: svdmodel.hxx:177
void DoMakePageObjectsNamesUnique(bool bDo)
Definition: svdmodel.hxx:605
std::unique_ptr< std::deque< std::unique_ptr< SfxUndoAction > > > m_pRedoStack
Definition: svdmodel.hxx:191
static XDashListRef AsDashList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:380
XBitmapListRef GetBitmapList() const
Definition: svdmodel.hxx:531
virtual SVX_DLLPRIVATE bool IsCreatingDataObj() const
Definition: svdmodel.hxx:267
OutputDevice * get() const
MapUnit
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:314
const SdrPage * GetPage() const
Definition: svdmodel.hxx:122
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
const SdrPage * mpPage
Definition: svdmodel.hxx:114
bool IsInDestruction() const
Definition: svdmodel.hxx:589
XColorListRef GetColorList() const
Definition: svdmodel.hxx:530
void SetDisableTextEditUsesCommonUndoManager(bool bNew)
Definition: svdmodel.hxx:545
void SetPersist(::comphelper::IEmbeddedHelper *p)
Definition: svdmodel.hxx:352
static XHatchListRef AsHatchList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:383
const SdrLayerAdmin & GetLayerAdmin() const
Definition: svdmodel.hxx:311
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
void SetPropertyList(XPropertyListRef const &p)
Definition: svdmodel.hxx:525
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
SfxItemPool & GetItemPool()
Definition: svdmodel.hxx:315
bool IsTransportContainer() const
Definition: svdmodel.hxx:268
std::vector< SdrPage * > maPages
Definition: svdmodel.hxx:166
o3tl::enumarray< XPropertyListType, XPropertyListRef > maProperties
Definition: svdmodel.hxx:227
sal_uInt16 GetDefaultTabulator() const
Definition: svdmodel.hxx:337
sal_Int32 mnDefTextHgt
Definition: svdmodel.hxx:184
bool IsPagNumsDirty() const
Definition: svdmodel.hxx:393
const SdrObject * GetObject() const
Definition: svdmodel.hxx:123
OUString m_aUIUnitStr
Definition: svdmodel.hxx:173