Coverage Report

Created: 2026-02-14 09:37

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