bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / svdmodel.hxx
blobe2dc48461c781a4375b555b1f64d3db1c7560211
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 #ifndef INCLUDED_SVX_SVDMODEL_HXX
21 #define INCLUDED_SVX_SVDMODEL_HXX
23 #include <functional>
24 #include <memory>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <cppuhelper/weakref.hxx>
27 #include <editeng/forbiddencharacterstable.hxx>
28 #include <editeng/outliner.hxx>
29 #include <rtl/ustring.hxx>
30 #include <tools/link.hxx>
31 #include <tools/weakbase.hxx>
32 #include <vcl/mapmod.hxx>
33 #include <svl/SfxBroadcaster.hxx>
34 #include <tools/datetime.hxx>
35 #include <tools/fract.hxx>
36 #include <svl/hint.hxx>
37 #include <o3tl/typed_flags_set.hxx>
38 #include <o3tl/enumarray.hxx>
40 #include <svl/style.hxx>
41 #include <svx/xtable.hxx>
42 #include <svx/pageitem.hxx>
43 #include <vcl/field.hxx>
44 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
46 class OutputDevice;
47 #include <svx/svdtypes.hxx>
48 #include <svx/svxdllapi.h>
50 #include <rtl/ref.hxx>
51 #include <deque>
53 #ifdef DBG_UTIL
54 // SdrObjectLifetimeWatchDog
55 #include <unordered_set>
56 #endif
58 #define DEGREE_CHAR u'\x00B0' /* U+00B0 DEGREE SIGN */
60 class SdrOutliner;
61 class SdrLayerAdmin;
62 class SdrObjList;
63 class SdrObject;
64 class SdrPage;
65 class SdrPageView;
66 class SdrTextObj;
67 class SdrUndoAction;
68 class SdrUndoGroup;
69 class AutoTimer;
70 class SfxItemPool;
71 class SfxItemSet;
72 class SfxRepeatTarget;
73 class SfxStyleSheet;
74 class SfxUndoAction;
75 class SfxUndoManager;
76 class XBitmapList;
77 class XColorList;
78 class XDashList;
79 class XGradientList;
80 class XHatchList;
81 class XLineEndList;
82 class SvxForbiddenCharactersTable;
83 class SvNumberFormatter;
84 class SdrOutlinerCache;
85 class SdrUndoFactory;
86 class ImageMap;
87 class TextChain;
88 enum class CharCompressType;
89 namespace comphelper
91 class IEmbeddedHelper;
92 class LifecycleProxy;
94 namespace sfx2
96 class LinkManager;
100 enum class SdrHintKind
102 LayerChange, // changed layer definition
103 LayerOrderChange, // order of layer changed (Insert/Remove/ChangePos)
104 PageOrderChange, // order of pages (object pages or master pages) changed (Insert/Remove/ChangePos)
105 ObjectChange, // object changed
106 ObjectInserted, // new object inserted
107 ObjectRemoved, // symbol object removed from list
108 ModelCleared, // deleted the whole model (no pages exist anymore). not impl.
109 RefDeviceChange, // RefDevice changed
110 DefaultTabChange, // Default tabulator width changed
111 SwitchToPage, // #94278# UNDO/REDO at an object evtl. on another page
112 BeginEdit, // Is called after the object has entered text edit mode
113 EndEdit // Is called after the object has left text edit mode
116 class SVX_DLLPUBLIC SdrHint: public SfxHint
118 private:
119 SdrHintKind const meHint;
120 const SdrObject* mpObj;
121 const SdrPage* mpPage;
123 public:
124 explicit SdrHint(SdrHintKind eNewHint);
125 explicit SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj);
126 explicit SdrHint(SdrHintKind eNewHint, const SdrPage* pPage);
127 explicit SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj, const SdrPage* pPage);
129 const SdrPage* GetPage() const { return mpPage;}
130 const SdrObject* GetObject() const { return mpObj;}
131 SdrHintKind GetKind() const { return meHint;}
134 ////////////////////////////////////////////////////////////////////////////////////////////////////
136 // SdrModel
137 // DlgEdModel
138 // FmFormModel
139 // ScDrawLayer
140 // SdDrawDocument
141 // SwDrawModel
142 // OReportModel
144 struct SdrModelImpl;
146 class SVX_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase
148 private:
149 #ifdef DBG_UTIL
150 // SdrObjectLifetimeWatchDog:
151 // Use maAllIncarnatedObjects to keep track of all SdrObjects incarnated using this SdrModel
152 // (what is now possible after the paradigm change that a SdrObject stays at a single SdrModel
153 // for it's whole lifetime).
154 // The two methods are exclusive, debug-only, only-accessible-by SdrObject accesses to else
155 // hidden/non-existing maAllIncarnatedObjects.
156 // SdrObject::SdrObject uses impAddIncarnatedSdrObjectToSdrModel, while SdrObject::~SdrObject
157 // uses impRemoveIncarnatedSdrObjectToSdrModel.
158 // There are two places which may trigger SAL_WARN warnings:
159 // - impRemoveIncarnatedSdrObjectToSdrModel when the to-be-removed SdrObject is not member of SdrModel
160 // - SdrModel::~SdrModel after all SdrObjects *should* be cleaned-up.
161 // SdrModel::~SdrModel will also - for convenience - Free the non-deleted SdrObjects if there
162 // are any.
163 // Using std::unordered_set will use quasi constant access times, so this watchdog will not
164 // be expensive. Nonetheless, only use with debug code. It may be seductive to use this in
165 // product code, too, especially if it will indeed trigger - but its intention is clearly
166 // to find/identify MemoryLeaks caused by SdrObjects
167 friend void impAddIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
168 friend void impRemoveIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
169 std::unordered_set< const SdrObject* > maAllIncarnatedObjects;
170 #endif
171 protected:
172 std::vector<SdrPage*> maMaPag; // master pages
173 std::vector<SdrPage*> maPages;
174 std::function<void(std::unique_ptr<SdrUndoAction>)> aUndoLink; // link to a NotifyUndo-Handler
175 Size aMaxObjSize; // e.g. for auto-growing text
176 Fraction aObjUnit; // description of the coordinate units for ClipBoard, Drag&Drop, ...
177 MapUnit eObjUnit; // see above
178 FieldUnit eUIUnit; // unit, scale (e.g. 1/1000) for the UI (status bar) is set by ImpSetUIUnit()
179 Fraction aUIScale; // see above
180 OUString aUIUnitStr; // see above
181 Fraction aUIUnitFact; // see above
182 int nUIUnitDecimalMark; // see above
184 std::unique_ptr<SdrLayerAdmin> pLayerAdmin;
185 SfxItemPool* pItemPool;
186 comphelper::IEmbeddedHelper*
187 m_pEmbeddedHelper; // helper for embedded objects to get rid of the SfxObjectShell
188 std::unique_ptr<SdrOutliner> pDrawOutliner; // an Outliner for outputting text
189 std::unique_ptr<SdrOutliner> pHitTestOutliner;// an Outliner for the HitTest
190 std::unique_ptr<SdrOutliner> pChainingOutliner; // an Outliner for chaining overflowing text
191 sal_Int32 mnDefTextHgt; // Default text height in logical units
192 VclPtr<OutputDevice> pRefOutDev; // ReferenceDevice for the EditEngine
193 rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool;
194 SfxStyleSheet* pDefaultStyleSheet;
195 SfxStyleSheet* mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; // #i119287#
196 sfx2::LinkManager* pLinkManager; // LinkManager
197 std::unique_ptr<std::deque<std::unique_ptr<SfxUndoAction>>> pUndoStack;
198 std::unique_ptr<std::deque<std::unique_ptr<SfxUndoAction>>> pRedoStack;
199 std::unique_ptr<SdrUndoGroup> pCurrentUndoGroup; // For multi-level
200 sal_uInt16 nUndoLevel; // undo nesting
201 bool bMyPool: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 bPagNumsDirty:1;
205 bool bMPgNumsDirty:1;
206 bool bTransportContainer:1; // doc is temporary object container, no display (e.g. clipboard)
207 bool bReadOnly:1;
208 bool bTransparentTextFrames:1;
209 bool bSwapGraphics:1;
210 bool bPasteResize:1; // Objects are being resized due to Paste with different MapMode
211 bool bStarDrawPreviewMode:1;
212 bool mbDisableTextEditUsesCommonUndoManager:1;
213 sal_uInt16 nDefaultTabulator;
214 sal_uInt32 nMaxUndoCount;
216 std::unique_ptr<TextChain> 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 long nLeft = 0,
244 long nRight = 0,
245 long nUpper = 0,
246 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 SVX_DLLPRIVATE void ImpCtor(
263 SfxItemPool* pPool,
264 ::comphelper::IEmbeddedHelper* pPers,
265 bool bDisablePropertyFiles);
267 // this is a weak reference to a possible living api wrapper for this model
268 css::uno::Reference< css::uno::XInterface > mxUnoModel;
270 public:
271 SVX_DLLPRIVATE virtual bool IsCreatingDataObj() const { return false; }
272 bool IsTransportContainer() const { return bTransportContainer; }
273 bool IsPasteResize() const { return bPasteResize; }
274 void SetPasteResize(bool bOn) { bPasteResize=bOn; }
275 // If a custom Pool is put here, the class will call methods
276 // on it (Put(), Remove()). On disposal of SdrModel the pool
277 // will be deleted with delete.
278 // If you give NULL instead, it will create an own pool (SdrItemPool)
279 // which will also be disposed in the destructor.
280 // If you do use a custom Pool, make sure you inherit from SdrItemPool,
281 // if you want to use symbol objects inherited from SdrAttrObj.
282 // If, however, you use objects inheriting from SdrObject you are free
283 // to chose a pool of your liking.
285 // tdf#118731 a bDisablePropertyFiles of true will disable ability to load
286 // XPropertyFiles describing defaults. Useful for UI preview widgets
287 explicit SdrModel(
288 SfxItemPool* pPool = nullptr,
289 ::comphelper::IEmbeddedHelper* pPers = nullptr,
290 bool bDisablePropertyFiles = false);
291 virtual ~SdrModel() override;
292 void ClearModel(bool bCalledFromDestructor);
294 // Override this to enable the Swap/LoadOnDemand of graphics.
295 // If rbDeleteAfterUse is set to sal_True the SvStream instance from
296 // the caller will be disposed after use.
297 // If this method returns NULL, a temporary file will be allocated for
298 // swapping.
299 // The stream from which the model was loaded or in which is was saved last
300 // needs to be delivered
301 virtual css::uno::Reference<
302 css::embed::XStorage> GetDocumentStorage() const;
303 css::uno::Reference<
304 css::io::XInputStream >
305 GetDocumentStream(OUString const& rURL,
306 ::comphelper::LifecycleProxy const & rProxy) const;
307 // Change the template attributes of the symbol objects to hard attributes
308 void BurnInStyleSheetAttributes();
309 // If you inherit from SdrPage you also need to inherit from SdrModel
310 // and implement both VM AllocPage() and AllocModel()...
311 virtual SdrPage* AllocPage(bool bMasterPage);
312 virtual SdrModel* AllocModel() const;
314 // Changes on the layers set the modified flag and broadcast on the model!
315 const SdrLayerAdmin& GetLayerAdmin() const { return *pLayerAdmin; }
316 SdrLayerAdmin& GetLayerAdmin() { return *pLayerAdmin; }
318 const SfxItemPool& GetItemPool() const { return *pItemPool; }
319 SfxItemPool& GetItemPool() { return *pItemPool; }
321 SdrOutliner& GetDrawOutliner(const SdrTextObj* pObj=nullptr) const;
323 SdrOutliner& GetHitTestOutliner() const { return *pHitTestOutliner; }
324 const SdrTextObj* GetFormattingTextObj() const;
325 // put the TextDefaults (Font,Height,Color) in a Set
326 void SetTextDefaults() const;
327 static void SetTextDefaults( SfxItemPool* pItemPool, sal_Int32 nDefTextHgt );
329 SdrOutliner& GetChainingOutliner(const SdrTextObj* pObj) const;
330 TextChain * GetTextChain() const;
332 // ReferenceDevice for the EditEngine
333 void SetRefDevice(OutputDevice* pDev);
334 OutputDevice* GetRefDevice() const { return pRefOutDev.get(); }
335 // If a new MapMode is set on the RefDevice (or similar)
336 void RefDeviceChanged(); // not yet implemented
337 // default font height in logical units
338 void SetDefaultFontHeight(sal_Int32 nVal);
339 // default tabulator width for the EditEngine
340 void SetDefaultTabulator(sal_uInt16 nVal);
341 sal_uInt16 GetDefaultTabulator() const { return nDefaultTabulator; }
343 // The DefaultStyleSheet will be used in every symbol object which is inserted
344 // in this model and does not have a StyleSheet set.
345 SfxStyleSheet* GetDefaultStyleSheet() const { return pDefaultStyleSheet; }
346 void SetDefaultStyleSheet(SfxStyleSheet* pDefSS) { pDefaultStyleSheet = pDefSS; }
348 // #i119287# default StyleSheet for SdrGrafObj and SdrOle2Obj
349 SfxStyleSheet* GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj() const { return mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; }
350 void SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(SfxStyleSheet* pDefSS) { mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj = pDefSS; }
352 sfx2::LinkManager* GetLinkManager() { return pLinkManager; }
353 void SetLinkManager( sfx2::LinkManager* pLinkMgr ) { pLinkManager = pLinkMgr; }
355 ::comphelper::IEmbeddedHelper* GetPersist() const { return m_pEmbeddedHelper; }
356 void SetPersist( ::comphelper::IEmbeddedHelper *p ) { m_pEmbeddedHelper = p; }
358 // Unit for the symbol coordination
359 // Default is 1 logical unit = 1/100mm (Unit=MapUnit::Map100thMM, Fract=(1,1)).
360 // Examples:
361 // MapUnit::MapPoint, Fraction(72,1) : 1 log Einh = 72 Point = 1 Inch
362 // MapUnit::MapPoint, Fraction(1,20) : 1 log Einh = 1/20 Point = 1 Twip
363 // MapUnit::MapTwip, Fraction(1,1) : 1 log Einh = 1 Twip
364 // MapUnit::Map100thMM, Fraction(1,10) : 1 log Einh = 1/1000mm
365 // MapUnit::MapMM, Fraction(1000,1) : 1 log Einh = 1000mm = 1m
366 // MapUnit::MapCM, Fraction(100,1) : 1 log Einh = 100cm = 1m
367 // MapUnit::MapCM, Fraction(100000,1): 1 log Einh = 100000cm = 1km
368 // (FWIW: you cannot represent light years).
369 // The scaling unit is needed for the Engine to serve the Clipboard
370 // with the correct sizes.
371 MapUnit GetScaleUnit() const { return eObjUnit; }
372 void SetScaleUnit(MapUnit eMap);
373 const Fraction& GetScaleFraction() const { return aObjUnit; }
374 void SetScaleFraction(const Fraction& rFrac);
375 // Setting both simultaneously performs a little better
376 void SetScaleUnit(MapUnit eMap, const Fraction& rFrac);
378 // maximal size e.g. for auto growing texts
379 const Size& GetMaxObjSize() const { return aMaxObjSize; }
380 void SetMaxObjSize(const Size& rSiz) { aMaxObjSize=rSiz; }
382 // For the View! to display sane numbers in the status bar: Default is mm.
383 void SetUIUnit(FieldUnit eUnit);
384 FieldUnit GetUIUnit() const { return eUIUnit; }
385 // The scale of the drawing. Default 1/1.
386 void SetUIScale(const Fraction& rScale);
387 const Fraction& GetUIScale() const { return aUIScale; }
388 // Setting both simultaneously performs a little better
389 void SetUIUnit(FieldUnit eUnit, const Fraction& rScale);
391 static OUString GetUnitString(FieldUnit eUnit);
392 OUString GetMetricString(long nVal, bool bNoUnitChars = false, sal_Int32 nNumDigits = -1) const;
393 static OUString GetAngleString(long nAngle);
394 static OUString GetPercentString(const Fraction& rVal);
396 // RecalcPageNums is ordinarily only called by the Page.
397 bool IsPagNumsDirty() const { return bPagNumsDirty; };
398 bool IsMPgNumsDirty() const { return bMPgNumsDirty; };
399 void RecalcPageNums(bool bMaster);
400 // After the Insert the Page belongs to the SdrModel.
401 virtual void InsertPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
402 virtual void DeletePage(sal_uInt16 nPgNum);
403 // Remove means transferring ownership to the caller (opposite of Insert)
404 virtual SdrPage* RemovePage(sal_uInt16 nPgNum);
405 virtual void MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
406 const SdrPage* GetPage(sal_uInt16 nPgNum) const;
407 SdrPage* GetPage(sal_uInt16 nPgNum);
408 sal_uInt16 GetPageCount() const;
409 virtual void PageListChanged();
411 // Masterpages
412 virtual void InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
413 void DeleteMasterPage(sal_uInt16 nPgNum);
414 // Remove means transferring ownership to the caller (opposite of Insert)
415 virtual SdrPage* RemoveMasterPage(sal_uInt16 nPgNum);
416 void MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
417 const SdrPage* GetMasterPage(sal_uInt16 nPgNum) const;
418 SdrPage* GetMasterPage(sal_uInt16 nPgNum);
419 sal_uInt16 GetMasterPageCount() const;
420 virtual void MasterPageListChanged();
422 // modified flag. Is set automatically when something changes on the Pages
423 // symbol objects. You need to reset it yourself, however, e.g. on Save().
424 bool IsChanged() const { return mbChanged; }
425 virtual void SetChanged(bool bFlg = true);
427 // If set to sal_True, graphics from graphics objects will:
428 // - not be loaded immediately when loading a document,
429 // but only once they are needed (e.g. displayed).
430 // - be pruned from memory if they are not needed.
431 // For that to work, override the virtual method GetDocumentStream().
432 // Default=FALSE. Flag is not persistent.
433 bool IsSwapGraphics() const { return bSwapGraphics; }
434 void SetSwapGraphics();
436 // Text frames without filling can be select with a mouse click by default (sal_False).
437 // With this flag set to true you can hit them only in the area in which text is to be
438 // found.
439 bool IsPickThroughTransparentTextFrames() const { return bTransparentTextFrames; }
440 void SetPickThroughTransparentTextFrames(bool bOn) { bTransparentTextFrames=bOn; }
442 // Can the model be changed at all?
443 // Is only evaluated by the possibility methods of the View.
444 // Direct manipulations on the model, ... do not respect this flag.
445 // Override this and return the appropriate ReadOnly status
446 // of the files, i.e. true or false. (Method is called multiple
447 // times, so use one flag only!)
448 virtual bool IsReadOnly() const;
449 void SetReadOnly(bool bYes);
451 // Mixing two SdrModels. Mind that rSourceModel is not const.
452 // The pages will not be copied but moved, when inserted.
453 // rSourceModel may very well be empty afterwards.
454 // nFirstPageNum,nLastPageNum: The pages to take from rSourceModel
455 // nDestPos..................: position to insert
456 // bMergeMasterPages.........: sal_True = needed MasterPages will be taken
457 // from rSourceModel
458 // sal_False= the MasterPageDescriptors of
459 // the pages of the rSourceModel will be
460 // mapped on the existing MasterPages.
461 // bUndo.....................: An undo action is generated for the merging.
462 // Undo is only for the target model, not for the
463 // rSourceModel.
464 // bTreadSourceAsConst.......: sal_True=the SourceModel will not be changed,
465 // so pages will be copied.
466 virtual void Merge(SdrModel& rSourceModel,
467 sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
468 sal_uInt16 nDestPos,
469 bool bMergeMasterPages, bool bAllMasterPages,
470 bool bUndo = true, bool bTreadSourceAsConst = false);
472 // Behaves like Merge(SourceModel=DestModel,nFirst,nLast,nDest,sal_False,sal_False,bUndo,!bMoveNoCopy);
473 void CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
474 sal_uInt16 nDestPos,
475 bool bUndo, bool bMoveNoCopy);
477 // BegUndo() / EndUndo() enables you to group arbitrarily many UndoActions
478 // arbitrarily deeply. As comment for the UndoAction the first BegUndo(String) of all
479 // nestings will be used.
480 // In that case the NotifyUndoActionHdl will be called on the last EndUndo().
481 // No UndoAction will be generated for an empty group.
482 // All direct modifications on the SdrModel do not create an UndoActions.
483 // Actions on the SdrView however do generate those.
484 void BegUndo(); // open Undo group
485 void BegUndo(const OUString& rComment); // open Undo group
486 void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc); // open Undo group
487 void EndUndo(); // close Undo group
488 void AddUndo(std::unique_ptr<SdrUndoAction> pUndo);
489 sal_uInt16 GetUndoBracketLevel() const { return nUndoLevel; }
490 // only after the first BegUndo or before the last EndUndo:
491 void SetUndoComment(const OUString& rComment);
492 void SetUndoComment(const OUString& rComment, const OUString& rObjDescr);
494 // The Undo management is only done if NotifyUndoAction-Handler is not set.
495 // Default is 16. Minimal MaxUndoActionCount is 1.
496 void SetMaxUndoActionCount(sal_uInt32 nCount);
497 void ClearUndoBuffer();
499 bool HasUndoActions() const;
500 bool HasRedoActions() const;
501 void Undo();
502 void Redo();
503 void Repeat(SfxRepeatTarget&);
505 // The application can set a handler here which collects the UndoActions einsammelt.
506 // The handler has the following signature:
507 // void NotifyUndoActionHdl(SfxUndoAction* pUndoAction);
508 // When calling the handler ownership is transferred;
509 // The UndoAction belongs to the Handler, not the SdrModel.
510 void SetNotifyUndoActionHdl(const std::function<void(std::unique_ptr<SdrUndoAction>)>& rLink) { aUndoLink=rLink; }
512 /** application can set its own undo manager, BegUndo, EndUndo and AddUndoAction
513 calls are routed to this interface if given */
514 void SetSdrUndoManager( SfxUndoManager* pUndoManager );
515 SfxUndoManager* GetSdrUndoManager() const;
517 /** applications can set their own undo factory to override creation of
518 undo actions. The SdrModel will become owner of the given SdrUndoFactory
519 and delete it upon its destruction. */
520 void SetSdrUndoFactory( SdrUndoFactory* pUndoFactory );
522 /** returns the models undo factory. This must be used to create
523 undo actions for this model. */
524 SdrUndoFactory& GetSdrUndoFactory() const;
526 // Accessor methods for Palettes, Lists and Tables
527 // FIXME: this badly needs re-factoring...
528 const XPropertyListRef& GetPropertyList( XPropertyListType t ) const { return maProperties[ t ]; }
529 void SetPropertyList( XPropertyListRef const & p ) { maProperties[ p->Type() ] = p; }
531 // friendlier helpers
532 XDashListRef GetDashList() const { return XPropertyList::AsDashList(GetPropertyList( XPropertyListType::Dash )); }
533 XHatchListRef GetHatchList() const { return XPropertyList::AsHatchList(GetPropertyList( XPropertyListType::Hatch )); }
534 XColorListRef GetColorList() const { return XPropertyList::AsColorList(GetPropertyList( XPropertyListType::Color )); }
535 XBitmapListRef GetBitmapList() const { return XPropertyList::AsBitmapList(GetPropertyList( XPropertyListType::Bitmap )); }
536 XPatternListRef GetPatternList() const { return XPropertyList::AsPatternList(GetPropertyList( XPropertyListType::Pattern )); }
537 XLineEndListRef GetLineEndList() const { return XPropertyList::AsLineEndList(GetPropertyList( XPropertyListType::LineEnd )); }
538 XGradientListRef GetGradientList() const { return XPropertyList::AsGradientList(GetPropertyList( XPropertyListType::Gradient )); }
540 // The DrawingEngine only references the StyleSheetPool, whoever
541 // made it needs to delete it.
542 SfxStyleSheetBasePool* GetStyleSheetPool() const { return mxStyleSheetPool.get(); }
543 void SetStyleSheetPool(SfxStyleSheetBasePool* pPool) { mxStyleSheetPool=pPool; }
545 void SetStarDrawPreviewMode(bool bPreview);
546 bool IsStarDrawPreviewMode() { return bStarDrawPreviewMode; }
548 bool GetDisableTextEditUsesCommonUndoManager() const { return mbDisableTextEditUsesCommonUndoManager; }
549 void SetDisableTextEditUsesCommonUndoManager(bool bNew) { mbDisableTextEditUsesCommonUndoManager = bNew; }
551 css::uno::Reference< css::uno::XInterface > const & getUnoModel();
552 void setUnoModel( const css::uno::Reference< css::uno::XInterface >& xModel );
554 // these functions are used by the api to disable repaints during a
555 // set of api calls.
556 bool isLocked() const { return mbModelLocked; }
557 void setLock( bool bLock );
559 void SetForbiddenCharsTable( const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars );
560 const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharsTable() const { return mpForbiddenCharactersTable;}
562 void SetCharCompressType( CharCompressType nType );
563 CharCompressType GetCharCompressType() const { return mnCharCompressType; }
565 void SetKernAsianPunctuation( bool bEnabled );
566 bool IsKernAsianPunctuation() const { return mbKernAsianPunctuation; }
568 void SetAddExtLeading( bool bEnabled );
569 bool IsAddExtLeading() const { return mbAddExtLeading; }
571 // tdf#99729 compatibility flag
572 void SetAnchoredTextOverflowLegacy(bool bEnabled);
573 bool IsAnchoredTextOverflowLegacy() const;
575 void ReformatAllTextObjects();
577 std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode );
578 void disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner );
580 bool IsWriter() const { return !bMyPool; }
582 // Used as a fallback in *::ReadUserDataSequence() to process common properties
583 void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue);
584 void WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues);
586 /** returns the numbering type that is used to format page fields in drawing shapes */
587 virtual SvxNumType GetPageNumType() const;
589 /** copies the items from the source set to the destination set. Both sets must have
590 same ranges but can have different pools. */
591 static void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel );
593 bool IsInDestruction() const { return mbInDestruction;}
595 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId();
597 virtual ImageMap* GetImageMapForObject(SdrObject*){return nullptr;};
599 /** enables (true) or disables (false) recording of undo actions
600 If undo actions are added while undo is disabled, they are deleted.
601 Disabling undo does not clear the current undo buffer! */
602 void EnableUndo( bool bEnable );
604 /** returns true if undo is currently enabled
605 This returns false if undo was disabled using EnableUndo( false ) and
606 also during the runtime of the Undo() and Redo() methods. */
607 bool IsUndoEnabled() const;
609 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
613 #endif // INCLUDED_SVX_SVDMODEL_HXX
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: */