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