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