tdf#149529 crash on deref deleted ScDocument*
[LibreOffice.git] / include / svx / svdmodel.hxx
blobab9578a7bc93ab21b76c670aadb230a2a1c16bd0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <functional>
23 #include <memory>
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <editeng/forbiddencharacterstable.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>
36 #include <svl/style.hxx>
37 #include <svx/xtable.hxx>
39 #include <svx/svdtypes.hxx>
40 #include <svx/svxdllapi.h>
42 #include <rtl/ref.hxx>
43 #include <deque>
45 #ifdef DBG_UTIL
46 // SdrObjectLifetimeWatchDog
47 #include <unordered_set>
48 #endif
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;
73 class SvxForbiddenCharactersTable;
74 class SvNumberFormatter;
75 class SdrOutlinerCache;
76 class SdrUndoFactory;
77 class ImageMap;
78 class TextChain;
79 enum class CharCompressType;
80 namespace comphelper
82 class IEmbeddedHelper;
83 class LifecycleProxy;
85 namespace sfx2
87 class LinkManager;
89 namespace com::sun::star::beans {
90 struct PropertyValue;
93 namespace svx
95 class Theme;
98 constexpr const sal_Unicode DEGREE_CHAR = u'\x00B0'; /* U+00B0 DEGREE SIGN */
101 enum class SdrHintKind
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
117 class SVXCORE_DLLPUBLIC SdrHint final : public SfxHint
119 private:
120 SdrHintKind meHint;
121 const SdrObject* mpObj;
122 const SdrPage* mpPage;
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);
130 const SdrPage* GetPage() const { return mpPage;}
131 const SdrObject* GetObject() const { return mpObj;}
132 SdrHintKind GetKind() const { return meHint;}
135 ////////////////////////////////////////////////////////////////////////////////////////////////////
137 // SdrModel
138 // DlgEdModel
139 // FmFormModel
140 // ScDrawLayer
141 // SdDrawDocument
142 // SwDrawModel
143 // OReportModel
145 struct SdrModelImpl;
147 class SVXCORE_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase
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
185 std::unique_ptr<SdrLayerAdmin> m_pLayerAdmin;
186 rtl::Reference<SfxItemPool> m_pItemPool;
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
193 rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool;
194 SfxStyleSheet* m_pDefaultStyleSheet;
195 SfxStyleSheet* mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; // #i119287#
196 sfx2::LinkManager* m_pLinkManager; // LinkManager
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 sal_uInt16 m_nDefaultTabulator;
214 sal_uInt32 m_nMaxUndoCount;
216 std::unique_ptr<TextChain> m_pTextChain;
219 public:
220 std::shared_ptr<SvxForbiddenCharactersTable> mpForbiddenCharactersTable;
222 std::unique_ptr<SdrOutlinerCache> mpOutlinerCache;
223 //get a vector of all the SdrOutliner belonging to the model
224 std::vector<SdrOutliner*> GetActiveOutliners() const;
225 std::unique_ptr<SdrModelImpl> mpImpl;
226 CharCompressType mnCharCompressType;
227 sal_uInt16 mnHandoutPageCount;
228 bool mbModelLocked;
229 bool mbKernAsianPunctuation;
230 bool mbAddExtLeading;
231 bool mbInDestruction;
233 // Color, Dash, Line-End, Hatch, Gradient, Bitmap property lists ...
234 o3tl::enumarray<XPropertyListType, XPropertyListRef> maProperties;
236 sal_uInt16 getHandoutPageCount() const { return mnHandoutPageCount; }
237 void setHandoutPageCount( sal_uInt16 nHandoutPageCount ) { mnHandoutPageCount = nHandoutPageCount; }
239 // Adapt to given Size and Borders scaling all contained data, maybe
240 // including PresObj's in higher derivations
241 virtual void adaptSizeAndBorderForAllPages(
242 const Size& rNewSize,
243 tools::Long nLeft = 0,
244 tools::Long nRight = 0,
245 tools::Long nUpper = 0,
246 tools::Long nLower = 0);
248 protected:
249 virtual css::uno::Reference< css::uno::XInterface > createUnoModel();
251 private:
252 SdrModel(const SdrModel& rSrcModel) = delete;
253 void operator=(const SdrModel& rSrcModel) = delete;
254 bool operator==(const SdrModel& rCmpModel) const = delete;
255 SVX_DLLPRIVATE void ImpPostUndoAction(std::unique_ptr<SdrUndoAction> pUndo);
256 SVX_DLLPRIVATE void ImpSetUIUnit();
257 SVX_DLLPRIVATE void ImpSetOutlinerDefaults( SdrOutliner* pOutliner, bool bInit = false );
258 SVX_DLLPRIVATE void ImpReformatAllTextObjects();
259 SVX_DLLPRIVATE void ImpReformatAllEdgeObjects();
260 SVX_DLLPRIVATE void ImpCreateTables(bool bDisablePropertyFiles);
262 // this is a weak reference to a possible living api wrapper for this model
263 css::uno::Reference< css::uno::XInterface > mxUnoModel;
265 // used to disable unique name checking during page move
266 bool mbMakePageObjectsNamesUnique = true;
268 public:
269 SVX_DLLPRIVATE virtual bool IsCreatingDataObj() const { return false; }
270 bool IsTransportContainer() const { return m_bTransportContainer; }
271 bool IsPasteResize() const { return m_bPasteResize; }
272 void SetPasteResize(bool bOn) { m_bPasteResize=bOn; }
273 // If a custom Pool is put here, the class will call methods
274 // on it (Put(), Remove()). On disposal of SdrModel the pool
275 // will be deleted with delete.
276 // If you give NULL instead, it will create an own pool (SdrItemPool)
277 // which will also be disposed in the destructor.
278 // If you do use a custom Pool, make sure you inherit from SdrItemPool,
279 // if you want to use symbol objects inherited from SdrAttrObj.
280 // If, however, you use objects inheriting from SdrObject you are free
281 // to chose a pool of your liking.
283 // tdf#118731 a bDisablePropertyFiles of true will disable ability to load
284 // XPropertyFiles describing defaults. Useful for UI preview widgets
285 explicit SdrModel(
286 SfxItemPool* pPool = nullptr,
287 ::comphelper::IEmbeddedHelper* pPers = nullptr,
288 bool bDisablePropertyFiles = false);
289 virtual ~SdrModel() override;
290 void ClearModel(bool bCalledFromDestructor);
292 // Override this to enable the Swap/LoadOnDemand of graphics.
293 // If rbDeleteAfterUse is set to sal_True the SvStream instance from
294 // the caller will be disposed after use.
295 // If this method returns NULL, a temporary file will be allocated for
296 // swapping.
297 // The stream from which the model was loaded or in which is was saved last
298 // needs to be delivered
299 virtual css::uno::Reference<
300 css::embed::XStorage> GetDocumentStorage() const;
301 css::uno::Reference<
302 css::io::XInputStream >
303 GetDocumentStream(OUString const& rURL,
304 ::comphelper::LifecycleProxy const & rProxy) const;
305 // Change the template attributes of the symbol objects to hard attributes
306 void BurnInStyleSheetAttributes();
307 // If you inherit from SdrPage you also need to inherit from SdrModel
308 // and implement both VM AllocPage() and AllocModel()...
309 virtual rtl::Reference<SdrPage> AllocPage(bool bMasterPage);
310 virtual SdrModel* AllocModel() const;
312 // Changes on the layers set the modified flag and broadcast on the model!
313 const SdrLayerAdmin& GetLayerAdmin() const { return *m_pLayerAdmin; }
314 SdrLayerAdmin& GetLayerAdmin() { return *m_pLayerAdmin; }
316 const SfxItemPool& GetItemPool() const { return *m_pItemPool; }
317 SfxItemPool& GetItemPool() { return *m_pItemPool; }
319 SdrOutliner& GetDrawOutliner(const SdrTextObj* pObj=nullptr) const;
321 SdrOutliner& GetHitTestOutliner() const { return *m_pHitTestOutliner; }
322 const SdrTextObj* GetFormattingTextObj() const;
323 // put the TextDefaults (Font,Height,Color) in a Set
324 void SetTextDefaults() const;
325 static void SetTextDefaults( SfxItemPool* pItemPool, sal_Int32 nDefTextHgt );
327 SdrOutliner& GetChainingOutliner(const SdrTextObj* pObj) const;
328 TextChain * GetTextChain() const;
330 // ReferenceDevice for the EditEngine
331 void SetRefDevice(OutputDevice* pDev);
332 OutputDevice* GetRefDevice() const { return m_pRefOutDev.get(); }
333 // If a new MapMode is set on the RefDevice (or similar)
334 void RefDeviceChanged(); // not yet implemented
335 // default font height in logical units
336 void SetDefaultFontHeight(sal_Int32 nVal);
337 // default tabulator width for the EditEngine
338 void SetDefaultTabulator(sal_uInt16 nVal);
339 sal_uInt16 GetDefaultTabulator() const { return m_nDefaultTabulator; }
341 // The DefaultStyleSheet will be used in every symbol object which is inserted
342 // in this model and does not have a StyleSheet set.
343 SfxStyleSheet* GetDefaultStyleSheet() const { return m_pDefaultStyleSheet; }
344 void SetDefaultStyleSheet(SfxStyleSheet* pDefSS) { m_pDefaultStyleSheet = pDefSS; }
346 // #i119287# default StyleSheet for SdrGrafObj and SdrOle2Obj
347 SfxStyleSheet* GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj() const { return mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; }
348 void SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(SfxStyleSheet* pDefSS) { mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj = pDefSS; }
350 sfx2::LinkManager* GetLinkManager() { return m_pLinkManager; }
351 void SetLinkManager( sfx2::LinkManager* pLinkMgr ) { m_pLinkManager = pLinkMgr; }
353 ::comphelper::IEmbeddedHelper* GetPersist() const { return m_pEmbeddedHelper; }
354 void SetPersist( ::comphelper::IEmbeddedHelper *p ) { m_pEmbeddedHelper = p; }
356 // Unit for the symbol coordination
357 // Default is 1 logical unit = 1/100mm (Unit=MapUnit::Map100thMM, Fract=(1,1)).
358 // Examples:
359 // MapUnit::MapPoint, Fraction(72,1) : 1 log Einh = 72 Point = 1 Inch
360 // MapUnit::MapPoint, Fraction(1,20) : 1 log Einh = 1/20 Point = 1 Twip
361 // MapUnit::MapTwip, Fraction(1,1) : 1 log Einh = 1 Twip
362 // MapUnit::Map100thMM, Fraction(1,10) : 1 log Einh = 1/1000mm
363 // MapUnit::MapMM, Fraction(1000,1) : 1 log Einh = 1000mm = 1m
364 // MapUnit::MapCM, Fraction(100,1) : 1 log Einh = 100cm = 1m
365 // MapUnit::MapCM, Fraction(100000,1): 1 log Einh = 100000cm = 1km
366 // (FWIW: you cannot represent light years).
367 // The scaling unit is needed for the Engine to serve the Clipboard
368 // with the correct sizes.
369 MapUnit GetScaleUnit() const { return m_eObjUnit; }
370 void SetScaleUnit(MapUnit eMap);
371 const Fraction& GetScaleFraction() const { return m_aObjUnit; }
372 void SetScaleFraction(const Fraction& rFrac);
373 // Setting both simultaneously performs a little better
374 void SetScaleUnit(MapUnit eMap, const Fraction& rFrac);
376 // maximal size e.g. for auto growing texts
377 const Size& GetMaxObjSize() const { return m_aMaxObjSize; }
378 void SetMaxObjSize(const Size& rSiz) { m_aMaxObjSize=rSiz; }
380 // For the View! to display sane numbers in the status bar: Default is mm.
381 void SetUIUnit(FieldUnit eUnit);
382 FieldUnit GetUIUnit() const { return m_eUIUnit; }
383 // The scale of the drawing. Default 1/1.
384 void SetUIScale(const Fraction& rScale);
385 const Fraction& GetUIScale() const { return m_aUIScale; }
386 // Setting both simultaneously performs a little better
387 void SetUIUnit(FieldUnit eUnit, const Fraction& rScale);
389 static OUString GetUnitString(FieldUnit eUnit);
390 OUString GetMetricString(tools::Long nVal, bool bNoUnitChars = false, sal_Int32 nNumDigits = -1) const;
391 static OUString GetAngleString(Degree100 nAngle);
392 static OUString GetPercentString(const Fraction& rVal);
394 // RecalcPageNums is ordinarily only called by the Page.
395 bool IsPagNumsDirty() const { return m_bPagNumsDirty; };
396 bool IsMPgNumsDirty() const { return m_bMPgNumsDirty; };
397 void RecalcPageNums(bool bMaster);
398 // After the Insert the Page belongs to the SdrModel.
399 virtual void InsertPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
400 virtual void DeletePage(sal_uInt16 nPgNum);
401 // Remove means transferring ownership to the caller (opposite of Insert)
402 virtual rtl::Reference<SdrPage> RemovePage(sal_uInt16 nPgNum);
403 virtual void MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
404 const SdrPage* GetPage(sal_uInt16 nPgNum) const;
405 SdrPage* GetPage(sal_uInt16 nPgNum);
406 sal_uInt16 GetPageCount() const;
407 virtual void PageListChanged();
409 // Masterpages
410 virtual void InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
411 void DeleteMasterPage(sal_uInt16 nPgNum);
412 // Remove means transferring ownership to the caller (opposite of Insert)
413 virtual rtl::Reference<SdrPage> RemoveMasterPage(sal_uInt16 nPgNum);
414 void MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
415 const SdrPage* GetMasterPage(sal_uInt16 nPgNum) const;
416 SdrPage* GetMasterPage(sal_uInt16 nPgNum);
417 sal_uInt16 GetMasterPageCount() const;
418 virtual void MasterPageListChanged();
420 // modified flag. Is set automatically when something changes on the Pages
421 // symbol objects. You need to reset it yourself, however, e.g. on Save().
422 bool IsChanged() const { return mbChanged; }
423 virtual void SetChanged(bool bFlg = true);
425 // If set to sal_True, graphics from graphics objects will:
426 // - not be loaded immediately when loading a document,
427 // but only once they are needed (e.g. displayed).
428 // - be pruned from memory if they are not needed.
429 // For that to work, override the virtual method GetDocumentStream().
430 // Default=FALSE. Flag is not persistent.
431 bool IsSwapGraphics() const { return m_bSwapGraphics; }
432 void SetSwapGraphics();
434 // Text frames without filling can be select with a mouse click by default (sal_False).
435 // With this flag set to true you can hit them only in the area in which text is to be
436 // found.
437 bool IsPickThroughTransparentTextFrames() const { return m_bTransparentTextFrames; }
438 void SetPickThroughTransparentTextFrames(bool bOn) { m_bTransparentTextFrames=bOn; }
440 // Can the model be changed at all?
441 // Is only evaluated by the possibility methods of the View.
442 // Direct manipulations on the model, ... do not respect this flag.
443 // Override this and return the appropriate ReadOnly status
444 // of the files, i.e. true or false. (Method is called multiple
445 // times, so use one flag only!)
446 virtual bool IsReadOnly() const;
447 void SetReadOnly(bool bYes);
449 // Mixing two SdrModels. Mind that rSourceModel is not const.
450 // The pages will not be copied but moved, when inserted.
451 // rSourceModel may very well be empty afterwards.
452 // nFirstPageNum,nLastPageNum: The pages to take from rSourceModel
453 // nDestPos..................: position to insert
454 // bMergeMasterPages.........: sal_True = needed MasterPages will be taken
455 // from rSourceModel
456 // sal_False= the MasterPageDescriptors of
457 // the pages of the rSourceModel will be
458 // mapped on the existing MasterPages.
459 // bUndo.....................: An undo action is generated for the merging.
460 // Undo is only for the target model, not for the
461 // rSourceModel.
462 // bTreadSourceAsConst.......: sal_True=the SourceModel will not be changed,
463 // so pages will be copied.
464 virtual void Merge(SdrModel& rSourceModel,
465 sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
466 sal_uInt16 nDestPos,
467 bool bMergeMasterPages, bool bAllMasterPages,
468 bool bUndo = true, bool bTreadSourceAsConst = false);
470 // Behaves like Merge(SourceModel=DestModel,nFirst,nLast,nDest,sal_False,sal_False,bUndo,!bMoveNoCopy);
471 void CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
472 sal_uInt16 nDestPos,
473 bool bUndo, bool bMoveNoCopy);
475 // BegUndo() / EndUndo() enables you to group arbitrarily many UndoActions
476 // arbitrarily deeply. As comment for the UndoAction the first BegUndo(String) of all
477 // nestings will be used.
478 // In that case the NotifyUndoActionHdl will be called on the last EndUndo().
479 // No UndoAction will be generated for an empty group.
480 // All direct modifications on the SdrModel do not create an UndoActions.
481 // Actions on the SdrView however do generate those.
482 void BegUndo(); // open Undo group
483 void BegUndo(const OUString& rComment); // open Undo group
484 void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc); // open Undo group
485 void EndUndo(); // close Undo group
486 void AddUndo(std::unique_ptr<SdrUndoAction> pUndo);
487 sal_uInt16 GetUndoBracketLevel() const { return m_nUndoLevel; }
488 // only after the first BegUndo or before the last EndUndo:
489 void SetUndoComment(const OUString& rComment);
490 void SetUndoComment(const OUString& rComment, const OUString& rObjDescr);
492 // The Undo management is only done if NotifyUndoAction-Handler is not set.
493 // Default is 16. Minimal MaxUndoActionCount is 1.
494 void SetMaxUndoActionCount(sal_uInt32 nCount);
495 void ClearUndoBuffer();
497 bool HasUndoActions() const;
498 bool HasRedoActions() const;
499 void Undo();
500 void Redo();
501 void Repeat(SfxRepeatTarget&);
503 // The application can set a handler here which collects the UndoActions einsammelt.
504 // The handler has the following signature:
505 // void NotifyUndoActionHdl(SfxUndoAction* pUndoAction);
506 // When calling the handler ownership is transferred;
507 // The UndoAction belongs to the Handler, not the SdrModel.
508 void SetNotifyUndoActionHdl(const std::function<void(std::unique_ptr<SdrUndoAction>)>& rLink) { m_aUndoLink=rLink; }
510 /** application can set its own undo manager, BegUndo, EndUndo and AddUndoAction
511 calls are routed to this interface if given */
512 void SetSdrUndoManager( SfxUndoManager* pUndoManager );
513 SfxUndoManager* GetSdrUndoManager() const;
515 /** applications can set their own undo factory to override creation of
516 undo actions. The SdrModel will become owner of the given SdrUndoFactory
517 and delete it upon its destruction. */
518 void SetSdrUndoFactory( SdrUndoFactory* pUndoFactory );
520 /** returns the models undo factory. This must be used to create
521 undo actions for this model. */
522 SdrUndoFactory& GetSdrUndoFactory() const;
524 // Accessor methods for Palettes, Lists and Tables
525 // FIXME: this badly needs re-factoring...
526 const XPropertyListRef& GetPropertyList( XPropertyListType t ) const { return maProperties[ t ]; }
527 void SetPropertyList( XPropertyListRef const & p ) { maProperties[ p->Type() ] = p; }
529 // friendlier helpers
530 XDashListRef GetDashList() const { return XPropertyList::AsDashList(GetPropertyList( XPropertyListType::Dash )); }
531 XHatchListRef GetHatchList() const { return XPropertyList::AsHatchList(GetPropertyList( XPropertyListType::Hatch )); }
532 XColorListRef GetColorList() const { return XPropertyList::AsColorList(GetPropertyList( XPropertyListType::Color )); }
533 XBitmapListRef GetBitmapList() const { return XPropertyList::AsBitmapList(GetPropertyList( XPropertyListType::Bitmap )); }
534 XPatternListRef GetPatternList() const { return XPropertyList::AsPatternList(GetPropertyList( XPropertyListType::Pattern )); }
535 XLineEndListRef GetLineEndList() const { return XPropertyList::AsLineEndList(GetPropertyList( XPropertyListType::LineEnd )); }
536 XGradientListRef GetGradientList() const { return XPropertyList::AsGradientList(GetPropertyList( XPropertyListType::Gradient )); }
538 // The DrawingEngine only references the StyleSheetPool, whoever
539 // made it needs to delete it.
540 SfxStyleSheetBasePool* GetStyleSheetPool() const { return mxStyleSheetPool.get(); }
541 void SetStyleSheetPool(SfxStyleSheetBasePool* pPool) { mxStyleSheetPool=pPool; }
543 void SetTheme(std::unique_ptr<svx::Theme> pTheme);
544 svx::Theme* GetTheme();
546 void SetStarDrawPreviewMode(bool bPreview);
547 bool IsStarDrawPreviewMode() const { return m_bStarDrawPreviewMode; }
549 bool GetDisableTextEditUsesCommonUndoManager() const { return mbDisableTextEditUsesCommonUndoManager; }
550 void SetDisableTextEditUsesCommonUndoManager(bool bNew) { mbDisableTextEditUsesCommonUndoManager = bNew; }
552 css::uno::Reference< css::uno::XInterface > const & getUnoModel();
553 void setUnoModel( const css::uno::Reference< css::uno::XInterface >& xModel );
555 // these functions are used by the api to disable repaints during a
556 // set of api calls.
557 bool isLocked() const { return mbModelLocked; }
558 void setLock( bool bLock );
560 void SetForbiddenCharsTable( const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars );
561 const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharsTable() const { return mpForbiddenCharactersTable;}
563 void SetCharCompressType( CharCompressType nType );
564 CharCompressType GetCharCompressType() const { return mnCharCompressType; }
566 void SetKernAsianPunctuation( bool bEnabled );
567 bool IsKernAsianPunctuation() const { return mbKernAsianPunctuation; }
569 void SetAddExtLeading( bool bEnabled );
570 bool IsAddExtLeading() const { return mbAddExtLeading; }
572 // tdf#99729 compatibility flag
573 void SetAnchoredTextOverflowLegacy(bool bEnabled);
574 bool IsAnchoredTextOverflowLegacy() const;
576 void ReformatAllTextObjects();
578 std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode );
579 void disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner );
581 bool IsWriter() const { return m_bIsWriter; }
583 // Used as a fallback in *::ReadUserDataSequence() to process common properties
584 void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue);
585 void WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues);
587 /** returns the numbering type that is used to format page fields in drawing shapes */
588 virtual SvxNumType GetPageNumType() const;
590 /** copies the items from the source set to the destination set. Both sets must have
591 same ranges but can have different pools. */
592 static void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel );
594 bool IsInDestruction() const { return mbInDestruction;}
596 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
598 /** enables (true) or disables (false) recording of undo actions
599 If undo actions are added while undo is disabled, they are deleted.
600 Disabling undo does not clear the current undo buffer! */
601 void EnableUndo( bool bEnable );
603 /** returns true if undo is currently enabled
604 This returns false if undo was disabled using EnableUndo( false ) and
605 also during the runtime of the Undo() and Redo() methods. */
606 bool IsUndoEnabled() const;
608 // used to prevent object name change during page move
609 bool DoesMakePageObjectsNamesUnique() const { return mbMakePageObjectsNamesUnique; }
610 void DoMakePageObjectsNamesUnique(bool bDo) { mbMakePageObjectsNamesUnique = bDo; }
612 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
616 +-----------+
617 | SdrModel |
618 +--+------+-+
619 | +-----------+
620 +----+-----+ |
621 | ... | |
622 +----+---+ +----+---+ +-----+--------+
623 |SdrPage | |SdrPage | |SdrLayerAdmin |
624 +---+----+ +-+--+--++ +---+-------+--+
625 | | | | | +-------------------+
626 +----+----+ +-----+-----+ +-------+-------+
627 | ... | | ... | | ... |
628 +---+---+ +---+---+ +----+----+ +----+----+ +-----+------+ +------+-----+
629 |SdrObj | |SdrObj | |SdrLayer | |SdrLayer | |SdrLayerSet | |SdrLayerSet |
630 +-------+ +-------+ +---------+ +---------+ +------------+ +------------+
631 This class: SdrModel is the head of the data models for the StarView Drawing Engine.
633 ///////////////////////////////////////////////////////////////////////////////////////////////// */
635 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */