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