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