tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / include / svx / svdmodel.hxx
blobb0d8bd7b36a5d422d751c52a4615c2f1f4c20a2d
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>
45 #include <unordered_set>
47 class OutputDevice;
48 class SdrOutliner;
49 class SdrLayerAdmin;
50 class SdrObjList;
51 class SdrObject;
52 class SdrPage;
53 class SdrPageView;
54 class SdrTextObj;
55 class SdrUndoAction;
56 class SdrUndoGroup;
57 class AutoTimer;
58 class SfxItemPool;
59 class SfxItemSet;
60 class SfxRepeatTarget;
61 class SfxStyleSheet;
62 class SfxUndoAction;
63 class SfxUndoManager;
64 class XBitmapList;
65 class XColorList;
66 class XDashList;
67 class XGradientList;
68 class XHatchList;
69 class XLineEndList;
70 class SvxForbiddenCharactersTable;
71 class SvNumberFormatter;
72 class SdrOutlinerCache;
73 class SdrUndoFactory;
74 class ImageMap;
75 class TextChain;
76 enum class CharCompressType;
77 enum class SdrCompatibilityFlag;
78 namespace comphelper
80 class IEmbeddedHelper;
81 class LifecycleProxy;
83 namespace sfx2
85 class LinkManager;
87 namespace com::sun::star::beans {
88 struct PropertyValue;
91 namespace model
93 class Theme;
96 namespace svx
98 class IThemeColorChanger;
101 constexpr const sal_Unicode DEGREE_CHAR = u'\x00B0'; /* U+00B0 DEGREE SIGN */
104 enum class SdrHintKind
106 LayerChange, // changed layer definition
107 LayerOrderChange, // order of layer changed (Insert/Remove/ChangePos)
108 PageOrderChange, // order of pages (object pages or master pages) changed (Insert/Remove/ChangePos)
109 ObjectChange, // object changed
110 ObjectInserted, // new object inserted
111 ObjectRemoved, // symbol object removed from list
112 ModelCleared, // deleted the whole model (no pages exist anymore). not impl.
113 RefDeviceChange, // RefDevice changed
114 DefaultTabChange, // Default tabulator width changed
115 SwitchToPage, // #94278# UNDO/REDO at an object evtl. on another page
116 BeginEdit, // Is called after the object has entered text edit mode
117 EndEdit // Is called after the object has left text edit mode
120 class SVXCORE_DLLPUBLIC SdrHint final : public SfxHint
122 private:
123 SdrHintKind meHint;
124 const SdrObject* mpObj;
125 const SdrPage* mpPage;
127 public:
128 explicit SdrHint(SdrHintKind eNewHint);
129 explicit SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj);
130 explicit SdrHint(SdrHintKind eNewHint, const SdrPage* pPage);
131 explicit SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj, const SdrPage* pPage);
133 const SdrPage* GetPage() const { return mpPage;}
134 const SdrObject* GetObject() const { return mpObj;}
135 SdrHintKind GetKind() const { return meHint;}
138 ////////////////////////////////////////////////////////////////////////////////////////////////////
140 // SdrModel
141 // DlgEdModel
142 // FmFormModel
143 // ScDrawLayer
144 // SdDrawDocument
145 // SwDrawModel
146 // OReportModel
148 struct SdrModelImpl;
150 class SVXCORE_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase
152 // We need to keep track of all the SdrObjects linked to this SdrModel so that we can
153 // shut them down cleanly, otherwise we end up with use-after-free issues.
155 // Use maAllIncarnatedObjects to keep track of all SdrObjects incarnated using this SdrModel
156 // (what is now possible after the paradigm change that a SdrObject stays at a single SdrModel
157 // for it's whole lifetime).
158 // The two methods are exclusive, debug-only, only-accessible-by SdrObject accesses to else
159 // hidden/non-existing maAllIncarnatedObjects.
160 // SdrObject::SdrObject uses impAddIncarnatedSdrObjectToSdrModel, while SdrObject::~SdrObject
161 // uses impRemoveIncarnatedSdrObjectToSdrModel.
162 // There are two places which may trigger SAL_WARN warnings:
163 // - impRemoveIncarnatedSdrObjectToSdrModel when the to-be-removed SdrObject is not member of SdrModel
164 // - SdrModel::~SdrModel after all SdrObjects *should* be cleaned-up.
165 // SdrModel::~SdrModel will also - for convenience - Free the non-deleted SdrObjects if there
166 // are any.
167 // Using std::unordered_set will use quasi constant access times, so this watchdog will not
168 // be expensive. Nonetheless, only use with debug code. It may be seductive to use this in
169 // product code, too, especially if it will indeed trigger - but its intention is clearly
170 // to find/identify MemoryLeaks caused by SdrObjects
171 friend void impAddIncarnatedSdrObjectToSdrModel(SdrObject& rSdrObject, SdrModel& rSdrModel);
172 friend void impRemoveIncarnatedSdrObjectToSdrModel(SdrObject& rSdrObject, SdrModel& rSdrModel);
173 std::unordered_set< SdrObject* > maAllIncarnatedObjects;
174 protected:
175 std::vector<rtl::Reference<SdrPage>> maMasterPages;
176 std::vector<rtl::Reference<SdrPage>> maPages;
177 std::function<void(std::unique_ptr<SdrUndoAction>)> m_aUndoLink; // link to a NotifyUndo-Handler
178 Size m_aMaxObjSize; // e.g. for auto-growing text
179 MapUnit m_eObjUnit; // see above
180 FieldUnit m_eUIUnit; // unit, scale (e.g. 1/1000) for the UI (status bar) is set by ImpSetUIUnit()
181 Fraction m_aUIScale; // see above
182 OUString m_aUIUnitStr; // see above
183 Fraction m_aUIUnitFact; // see above
184 int m_nUIUnitDecimalMark; // see above
186 std::unique_ptr<SdrLayerAdmin> m_pLayerAdmin;
187 rtl::Reference<SfxItemPool> m_pItemPool;
188 comphelper::IEmbeddedHelper* m_pEmbeddedHelper; // helper for embedded objects to get rid of the SfxObjectShell
189 std::unique_ptr<SdrOutliner> m_pDrawOutliner; // an Outliner for outputting text
190 std::unique_ptr<SdrOutliner> m_pHitTestOutliner;// an Outliner for the HitTest
191 std::unique_ptr<SdrOutliner> m_pChainingOutliner; // an Outliner for chaining overflowing text
192 sal_Int32 mnDefTextHgt; // Default text height in logical units
193 VclPtr<OutputDevice> m_pRefOutDev; // ReferenceDevice for the EditEngine
194 rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool;
195 SfxStyleSheet* m_pDefaultStyleSheet;
196 SfxStyleSheet* mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; // #i119287#
197 sfx2::LinkManager* m_pLinkManager; // LinkManager
198 std::deque<std::unique_ptr<SfxUndoAction>> m_aUndoStack;
199 std::deque<std::unique_ptr<SfxUndoAction>> m_aRedoStack;
200 std::unique_ptr<SdrUndoGroup> m_pCurrentUndoGroup; // For multi-level
201 sal_uInt16 m_nUndoLevel; // undo nesting
202 sal_uInt16 m_nPageNumsDirtyFrom = SAL_MAX_UINT16;
203 sal_uInt16 m_nMasterPageNumsDirtyFrom = SAL_MAX_UINT16;
204 bool m_bIsWriter:1; // to clean up pMyPool from 303a
205 bool m_bThemedControls:1; // If false UnoControls should not use theme colors
206 bool mbUndoEnabled:1; // If false no undo is recorded or we are during the execution of an undo action
207 bool mbChanged:1;
208 bool m_bTransportContainer:1; // doc is temporary object container, no display (e.g. clipboard)
209 bool m_bReadOnly:1;
210 bool m_bTransparentTextFrames:1;
211 bool m_bSwapGraphics:1;
212 bool m_bPasteResize:1; // Objects are being resized due to Paste with different MapMode
213 bool m_bStarDrawPreviewMode:1;
214 bool mbDisableTextEditUsesCommonUndoManager:1;
215 bool mbVOCInvalidationIsReliable:1; // does the app reliably invalidate the VOC, or do we need to rebuild the primitives on every render?
216 bool m_bIsPDFDocument:1;
217 sal_uInt16 m_nDefaultTabulator;
218 sal_uInt32 m_nMaxUndoCount;
220 std::unique_ptr<TextChain> m_pTextChain;
223 public:
224 std::shared_ptr<SvxForbiddenCharactersTable> mpForbiddenCharactersTable;
226 std::unique_ptr<SdrOutlinerCache> mpOutlinerCache;
227 //get a vector of all the SdrOutliner belonging to the model
228 std::vector<SdrOutliner*> GetActiveOutliners() const;
229 std::unique_ptr<SdrModelImpl> mpImpl;
230 CharCompressType mnCharCompressType;
231 sal_uInt16 mnHandoutPageCount;
232 bool mbModelLocked;
233 bool mbKernAsianPunctuation;
234 bool mbAddExtLeading;
235 bool mbInDestruction;
237 // Color, Dash, Line-End, Hatch, Gradient, Bitmap property lists ...
238 o3tl::enumarray<XPropertyListType, XPropertyListRef> maProperties;
240 sal_uInt16 getHandoutPageCount() const { return mnHandoutPageCount; }
241 void setHandoutPageCount( sal_uInt16 nHandoutPageCount ) { mnHandoutPageCount = nHandoutPageCount; }
243 // Adapt to given Size and Borders scaling all contained data, maybe
244 // including PresObj's in higher derivations
245 virtual void adaptSizeAndBorderForAllPages(
246 const Size& rNewSize,
247 tools::Long nLeft = 0,
248 tools::Long nRight = 0,
249 tools::Long nUpper = 0,
250 tools::Long nLower = 0);
252 protected:
253 void implDtorClearModel();
254 virtual css::uno::Reference< css::frame::XModel > createUnoModel();
256 private:
257 SdrModel(const SdrModel& rSrcModel) = delete;
258 void operator=(const SdrModel& rSrcModel) = delete;
259 bool operator==(const SdrModel& rCmpModel) const = delete;
260 SVX_DLLPRIVATE void ImpPostUndoAction(std::unique_ptr<SdrUndoAction> pUndo);
261 SVX_DLLPRIVATE void ImpSetUIUnit();
262 SVX_DLLPRIVATE void ImpSetOutlinerDefaults( SdrOutliner* pOutliner, bool bInit = false );
263 SVX_DLLPRIVATE void ImpReformatAllTextObjects();
264 SVX_DLLPRIVATE void ImpReformatAllEdgeObjects();
265 SVX_DLLPRIVATE void ImpCreateTables(bool bDisablePropertyFiles);
267 // this is a weak reference to a possible living api wrapper for this model
268 css::uno::Reference< css::frame::XModel > mxUnoModel;
270 // used to disable unique name checking during page move
271 bool mbMakePageObjectsNamesUnique = true;
272 bool m_bIsImpress = false;
274 public:
275 SVX_DLLPRIVATE virtual bool IsCreatingDataObj() const { return false; }
276 bool IsTransportContainer() const { return m_bTransportContainer; }
277 bool AreControlsThemed() { return m_bThemedControls; }
278 bool IsPasteResize() const { return m_bPasteResize; }
279 bool IsImpress() const { return m_bIsImpress; }
280 void SetImpress(bool bIsImpress) { m_bIsImpress = bIsImpress; };
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_nPageNumsDirtyFrom != SAL_MAX_UINT16; }
401 bool IsMPgNumsDirty() const { return m_nMasterPageNumsDirtyFrom != SAL_MAX_UINT16; }
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 bool IsPDFDocument() const { return m_bIsPDFDocument; }
589 void setPDFDocument(bool bIsPDFDocument)
591 m_bIsPDFDocument = bIsPDFDocument;
594 // Used as a fallback in *::ReadUserDataSequence() to process common properties
595 void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue);
596 void WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues);
598 /** returns the numbering type that is used to format page fields in drawing shapes */
599 virtual SvxNumType GetPageNumType() const;
601 /** copies the items from the source set to the destination set. Both sets must have
602 same ranges but can have different pools. */
603 static void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel& rNewModel );
605 bool IsInDestruction() const { return mbInDestruction;}
607 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
609 /** enables (true) or disables (false) recording of undo actions
610 If undo actions are added while undo is disabled, they are deleted.
611 Disabling undo does not clear the current undo buffer! */
612 void EnableUndo( bool bEnable );
614 /** returns true if undo is currently enabled
615 This returns false if undo was disabled using EnableUndo( false ) and
616 also during the runtime of the Undo() and Redo() methods. */
617 bool IsUndoEnabled() const;
619 // used to prevent object name change during page move
620 bool DoesMakePageObjectsNamesUnique() const { return mbMakePageObjectsNamesUnique; }
621 void DoMakePageObjectsNamesUnique(bool bDo) { mbMakePageObjectsNamesUnique = bDo; }
623 virtual sal_Int32 getImagePreferredDPI() const { return 0; }
625 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
627 bool IsVOCInvalidationIsReliable() const { return mbVOCInvalidationIsReliable; }
628 void SetVOCInvalidationIsReliable(bool b) { mbVOCInvalidationIsReliable = b; }
632 +-----------+
633 | SdrModel |
634 +--+------+-+
635 | +-----------+
636 +----+-----+ |
637 | ... | |
638 +----+---+ +----+---+ +-----+--------+
639 |SdrPage | |SdrPage | |SdrLayerAdmin |
640 +---+----+ +-+--+--++ +---+-------+--+
641 | | | | | +-------------------+
642 +----+----+ +-----+-----+ +-------+-------+
643 | ... | | ... | | ... |
644 +---+---+ +---+---+ +----+----+ +----+----+ +-----+------+ +------+-----+
645 |SdrObj | |SdrObj | |SdrLayer | |SdrLayer | |SdrLayerSet | |SdrLayerSet |
646 +-------+ +-------+ +---------+ +---------+ +------------+ +------------+
647 This class: SdrModel is the head of the data models for the StarView Drawing Engine.
649 ///////////////////////////////////////////////////////////////////////////////////////////////// */
651 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */