Coverage Report

Created: 2025-11-16 09:57

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
409M
    const SdrPage*   GetPage() const { return mpPage;}
114
378k
    const SdrObject* GetObject() const { return mpObj;}
115
1.09G
    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
protected:
234
    void implDtorClearModel();
235
    virtual css::uno::Reference< css::frame::XModel > createUnoModel();
236
237
private:
238
    SdrModel(const SdrModel& rSrcModel) = delete;
239
    void operator=(const SdrModel& rSrcModel) = delete;
240
    bool operator==(const SdrModel& rCmpModel) const = delete;
241
    SVX_DLLPRIVATE void ImpPostUndoAction(std::unique_ptr<SdrUndoAction> pUndo);
242
    SVX_DLLPRIVATE void ImpSetUIUnit();
243
    SVX_DLLPRIVATE void ImpSetOutlinerDefaults( SdrOutliner* pOutliner, bool bInit = false );
244
    SVX_DLLPRIVATE void ImpReformatAllTextObjects();
245
    SVX_DLLPRIVATE void ImpReformatAllEdgeObjects();
246
    SVX_DLLPRIVATE void ImpCreateTables(bool bDisablePropertyFiles);
247
248
    // this is a weak reference to a possible living api wrapper for this model
249
    css::uno::Reference< css::frame::XModel > mxUnoModel;
250
251
    // used to disable unique name checking during page move
252
    bool mbMakePageObjectsNamesUnique = true;
253
    bool m_bIsImpress = false;
254
    bool m_bShowMargin = true;
255
256
public:
257
39.5k
    SVX_DLLPRIVATE virtual bool IsCreatingDataObj() const { return false; }
258
28.0k
    bool     IsTransportContainer() const { return m_bTransportContainer; }
259
0
    bool     AreControlsThemed() { return m_bThemedControls; }
260
3.06M
    bool     IsPasteResize() const        { return m_bPasteResize; }
261
0
    bool     IsImpress() const { return m_bIsImpress; }
262
39.2k
    void     SetImpress(bool bIsImpress) { m_bIsImpress = bIsImpress; };
263
0
    bool     IsShowMargin() const { return m_bShowMargin; }
264
0
    void     SetShowMargin(bool bShowMargin) { m_bShowMargin = bShowMargin; }
265
0
    void     SetPasteResize(bool bOn) { m_bPasteResize=bOn; }
266
    // If a custom Pool is put here, the class will call methods
267
    // on it (Put(), Remove()). On disposal of SdrModel the pool
268
    // will be deleted with   delete.
269
    // If you give NULL instead, it will create an own pool (SdrItemPool)
270
    // which will also be disposed in the destructor.
271
    // If you do use a custom Pool, make sure you inherit from SdrItemPool,
272
    // if you want to use symbol objects inherited from SdrAttrObj.
273
    // If, however, you use objects inheriting from SdrObject you are free
274
    // to choose a pool of your liking.
275
    //
276
    // tdf#118731 a bDisablePropertyFiles of true will disable ability to load
277
    // XPropertyFiles describing defaults. Useful for UI preview widgets
278
    explicit SdrModel(
279
        SfxItemPool* pPool = nullptr,
280
        ::comphelper::IEmbeddedHelper* pPers = nullptr,
281
        bool bDisablePropertyFiles = false);
282
    virtual ~SdrModel() override;
283
    void ClearModel(bool bCalledFromDestructor);
284
285
    // Override this to enable the Swap/LoadOnDemand of graphics.
286
    // If rbDeleteAfterUse is set to sal_True the SvStream instance from
287
    // the caller will be disposed after use.
288
    // If this method returns NULL, a temporary file will be allocated for
289
    // swapping.
290
    // The stream from which the model was loaded or in which is was saved last
291
    // needs to be delivered
292
    virtual css::uno::Reference<
293
                css::embed::XStorage> GetDocumentStorage() const;
294
    css::uno::Reference<
295
            css::io::XInputStream >
296
        GetDocumentStream(OUString const& rURL,
297
                ::comphelper::LifecycleProxy const & rProxy) const;
298
    // Change the template attributes of the symbol objects to hard attributes
299
    void BurnInStyleSheetAttributes();
300
    // If you inherit from SdrPage you also need to inherit from SdrModel
301
    // and implement both VM AllocPage() and AllocModel()...
302
    virtual rtl::Reference<SdrPage>  AllocPage(bool bMasterPage);
303
    virtual SdrModel* AllocModel() const;
304
305
    // Changes on the layers set the modified flag and broadcast on the model!
306
60.5k
    const SdrLayerAdmin& GetLayerAdmin() const                  { return *m_pLayerAdmin; }
307
2.73M
    SdrLayerAdmin&       GetLayerAdmin()                        { return *m_pLayerAdmin; }
308
309
15.0k
    const SfxItemPool&   GetItemPool() const                    { return *m_pItemPool; }
310
5.06M
    SfxItemPool&         GetItemPool()                          { return *m_pItemPool; }
311
312
    SdrOutliner&         GetDrawOutliner(const SdrTextObj* pObj=nullptr) const;
313
314
95.7k
    SdrOutliner&         GetHitTestOutliner() const { return *m_pHitTestOutliner; }
315
    const SdrTextObj*    GetFormattingTextObj() const;
316
    // put the TextDefaults (Font,Height,Color) in a Set
317
    void                 SetTextDefaults() const;
318
    static void          SetTextDefaults( SfxItemPool* pItemPool, sal_Int32 nDefTextHgt );
319
320
    SdrOutliner&         GetChainingOutliner(const SdrTextObj* pObj) const;
321
    TextChain *          GetTextChain() const;
322
323
    // ReferenceDevice for the EditEngine
324
    void                 SetRefDevice(OutputDevice* pDev);
325
2.74M
    OutputDevice*        GetRefDevice() const                   { return m_pRefOutDev.get(); }
326
    // If a new MapMode is set on the RefDevice (or similar)
327
    void                 RefDeviceChanged(); // not yet implemented
328
    // default font height in logical units
329
    void                 SetDefaultFontHeight(sal_Int32 nVal);
330
    // default tabulator width for the EditEngine
331
    void                 SetDefaultTabulator(sal_uInt16 nVal);
332
588k
    sal_uInt16           GetDefaultTabulator() const            { return m_nDefaultTabulator; }
333
334
    // The DefaultStyleSheet will be used in every symbol object which is inserted
335
    // in this model and does not have a StyleSheet set.
336
1.91M
    SfxStyleSheet*       GetDefaultStyleSheet() const             { return m_pDefaultStyleSheet; }
337
44.2k
    void                 SetDefaultStyleSheet(SfxStyleSheet* pDefSS) { m_pDefaultStyleSheet = pDefSS; }
338
339
    // #i119287# default StyleSheet for SdrGrafObj and SdrOle2Obj
340
15.7k
    SfxStyleSheet* GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj() const { return mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj; }
341
23.8k
    void SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(SfxStyleSheet* pDefSS) { mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj = pDefSS; }
342
343
2.22M
    sfx2::LinkManager*   GetLinkManager()                         { return m_pLinkManager; }
344
135k
    void                 SetLinkManager( sfx2::LinkManager* pLinkMgr ) { m_pLinkManager = pLinkMgr; }
345
346
19.6k
    ::comphelper::IEmbeddedHelper*     GetPersist() const               { return m_pEmbeddedHelper; }
347
150k
    void                 SetPersist( ::comphelper::IEmbeddedHelper *p ) { m_pEmbeddedHelper = p; }
348
349
    // Unit for the symbol coordination
350
    // Default is 1 logical unit = 1/100mm (Unit=MapUnit::Map100thMM, Fract=(1,1)).
351
    // Examples:
352
    //   MapUnit::MapPoint,    Fraction(72,1)    : 1 log Einh = 72 Point   = 1 Inch
353
    //   MapUnit::MapPoint,    Fraction(1,20)    : 1 log Einh = 1/20 Point = 1 Twip
354
    //   MapUnit::MapTwip,     Fraction(1,1)     : 1 log Einh = 1 Twip
355
    //   MapUnit::Map100thMM, Fraction(1,10)    : 1 log Einh = 1/1000mm
356
    //   MapUnit::MapMM,       Fraction(1000,1)  : 1 log Einh = 1000mm     = 1m
357
    //   MapUnit::MapCM,       Fraction(100,1)   : 1 log Einh = 100cm      = 1m
358
    //   MapUnit::MapCM,       Fraction(100000,1): 1 log Einh = 100000cm   = 1km
359
    // (FWIW: you cannot represent light years).
360
    // The scaling unit is needed for the Engine to serve the Clipboard
361
    // with the correct sizes.
362
206k
    MapUnit          GetScaleUnit() const                       { return m_eObjUnit; }
363
    void             SetScaleUnit(MapUnit eMap);
364
365
    // maximal size e.g. for auto growing texts
366
16.1k
    const Size&      GetMaxObjSize() const                      { return m_aMaxObjSize; }
367
0
    void             SetMaxObjSize(const Size& rSiz)            { m_aMaxObjSize=rSiz; }
368
369
    // For the View! to display sane numbers in the status bar: Default is mm.
370
    void             SetUIUnit(FieldUnit eUnit);
371
0
    FieldUnit        GetUIUnit() const                          { return m_eUIUnit; }
372
    // The scale of the drawing. Default 1/1.
373
    void             SetUIScale(const Fraction& rScale);
374
0
    const Fraction&  GetUIScale() const                         { return m_aUIScale; }
375
    // Setting both simultaneously performs a little better
376
    void             SetUIUnit(FieldUnit eUnit, const Fraction& rScale);
377
378
    static OUString  GetUnitString(FieldUnit eUnit);
379
    OUString         GetMetricString(tools::Long nVal, bool bNoUnitChars = false, sal_Int32 nNumDigits = -1) const;
380
    static OUString  GetAngleString(Degree100 nAngle);
381
    static OUString  GetPercentString(const Fraction& rVal);
382
383
    // RecalcPageNums is ordinarily only called by the Page.
384
607k
    bool             IsPagNumsDirty() const                     { return m_nPageNumsDirtyFrom != SAL_MAX_UINT16; }
385
86.6k
    bool             IsMPgNumsDirty() const                     { return m_nMasterPageNumsDirtyFrom != SAL_MAX_UINT16; }
386
    void             RecalcPageNums(bool bMaster);
387
    // After the Insert the Page belongs to the SdrModel.
388
    virtual void     InsertPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
389
    virtual void     DeletePage(sal_uInt16 nPgNum);
390
    // Remove means transferring ownership to the caller (opposite of Insert)
391
    virtual rtl::Reference<SdrPage> RemovePage(sal_uInt16 nPgNum);
392
    virtual void     MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
393
    const SdrPage*   GetPage(sal_uInt16 nPgNum) const;
394
    SdrPage*         GetPage(sal_uInt16 nPgNum);
395
    sal_uInt16       GetPageCount() const;
396
    virtual void     PageListChanged();
397
398
    // Masterpages
399
    virtual void     InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF);
400
    void             DeleteMasterPage(sal_uInt16 nPgNum);
401
    // Remove means transferring ownership to the caller (opposite of Insert)
402
    virtual rtl::Reference<SdrPage> RemoveMasterPage(sal_uInt16 nPgNum);
403
    void             MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos);
404
    const SdrPage*   GetMasterPage(sal_uInt16 nPgNum) const;
405
    SdrPage*         GetMasterPage(sal_uInt16 nPgNum);
406
    sal_uInt16       GetMasterPageCount() const;
407
    virtual void     MasterPageListChanged();
408
409
    // modified flag. Is set automatically when something changes on the Pages
410
    // symbol objects. You need to reset it yourself, however, e.g. on Save().
411
28.4k
    bool IsChanged() const { return mbChanged; }
412
    virtual void SetChanged(bool bFlg = true);
413
414
    // If set to sal_True, graphics from graphics objects will:
415
    // - not be loaded immediately when loading a document,
416
    //   but only once they are needed (e.g. displayed).
417
    // - be pruned from memory if they are not needed.
418
    // For that to work, override the virtual method GetDocumentStream().
419
    // Default=FALSE. Flag is not persistent.
420
0
    bool            IsSwapGraphics() const { return m_bSwapGraphics; }
421
    void            SetSwapGraphics();
422
423
    // Text frames without filling can be select with a mouse click by default (sal_False).
424
    // With this flag set to true you can hit them only in the area in which text is to be
425
    // found.
426
0
    bool            IsPickThroughTransparentTextFrames() const  { return m_bTransparentTextFrames; }
427
8.61k
    void            SetPickThroughTransparentTextFrames(bool bOn) { m_bTransparentTextFrames=bOn; }
428
429
    // Can the model be changed at all?
430
    // Is only evaluated by the possibility methods of the View.
431
    // Direct manipulations on the model, ... do not respect this flag.
432
    // Override this and return the appropriate ReadOnly status
433
    // of the files, i.e. true or false. (Method is called multiple
434
    // times, so use one flag only!)
435
    virtual bool IsReadOnly() const;
436
    void     SetReadOnly(bool bYes);
437
438
    // Mixing two SdrModels. Mind that rSourceModel is not const.
439
    // The pages will not be copied but moved, when inserted.
440
    // rSourceModel may very well be empty afterwards.
441
    // nFirstPageNum,nLastPageNum: The pages to take from rSourceModel
442
    // nDestPos..................: position to insert
443
    // bMergeMasterPages.........: sal_True = needed MasterPages will be taken
444
    //                                   from rSourceModel
445
    //                             sal_False= the MasterPageDescriptors of
446
    //                                   the pages of the rSourceModel will be
447
    //                                   mapped on the existing  MasterPages.
448
    // bUndo.....................: An undo action is generated for the merging.
449
    //                             Undo is only for the target model, not for the
450
    //                             rSourceModel.
451
    // bTreadSourceAsConst.......: sal_True=the SourceModel will not be changed,
452
    //                             so pages will be copied.
453
    virtual void Merge(SdrModel& rSourceModel,
454
               sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
455
               sal_uInt16 nDestPos,
456
               bool bMergeMasterPages, bool bAllMasterPages,
457
               bool bUndo = true, bool bTreadSourceAsConst = false);
458
459
    // Behaves like Merge(SourceModel=DestModel,nFirst,nLast,nDest,sal_False,sal_False,bUndo,!bMoveNoCopy);
460
    void CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
461
                   sal_uInt16 nDestPos,
462
                   bool bUndo, bool bMoveNoCopy);
463
464
    // BegUndo() / EndUndo() enables you to group arbitrarily many UndoActions
465
    // arbitrarily deeply. As comment for the UndoAction the first BegUndo(String) of all
466
    // nestings will be used.
467
    // In that case the NotifyUndoActionHdl will be called on the last EndUndo().
468
    // No UndoAction will be generated for an empty group.
469
    // All direct modifications on the SdrModel do not create an UndoActions.
470
    // Actions on the SdrView however do generate those.
471
    void BegUndo();                       // open Undo group
472
    void BegUndo(const OUString& rComment); // open Undo group
473
    void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc); // open Undo group
474
    void EndUndo();                       // close Undo group
475
    void AddUndo(std::unique_ptr<SdrUndoAction> pUndo);
476
0
    sal_uInt16 GetUndoBracketLevel() const                       { return m_nUndoLevel; }
477
    // only after the first BegUndo or before the last EndUndo:
478
    void SetUndoComment(const OUString& rComment);
479
    void SetUndoComment(const OUString& rComment, const OUString& rObjDescr);
480
481
    // The Undo management is only done if NotifyUndoAction-Handler is not set.
482
    // Default is 16. Minimal MaxUndoActionCount is 1.
483
    void  SetMaxUndoActionCount(sal_uInt32 nCount);
484
    void  ClearUndoBuffer();
485
486
    bool HasUndoActions() const;
487
    bool HasRedoActions() const;
488
    void Undo();
489
    void Redo();
490
    void Repeat(SfxRepeatTarget&);
491
492
    // The application can set a handler here which collects the UndoActions einsammelt.
493
    // The handler has the following signature:
494
    //   void NotifyUndoActionHdl(SfxUndoAction* pUndoAction);
495
    // When calling the handler ownership is transferred;
496
    // The UndoAction belongs to the Handler, not the SdrModel.
497
155k
    void        SetNotifyUndoActionHdl(const std::function<void(std::unique_ptr<SdrUndoAction>)>& rLink)  { m_aUndoLink=rLink; }
498
499
    /** application can set its own undo manager, BegUndo, EndUndo and AddUndoAction
500
        calls are routed to this interface if given */
501
    void SetSdrUndoManager( SfxUndoManager* pUndoManager );
502
    SfxUndoManager* GetSdrUndoManager() const;
503
504
    /** applications can set their own undo factory to override creation of
505
        undo actions. The SdrModel will become owner of the given SdrUndoFactory
506
        and delete it upon its destruction. */
507
    void SetSdrUndoFactory( SdrUndoFactory* pUndoFactory );
508
509
    /** returns the models undo factory. This must be used to create
510
        undo actions for this model. */
511
    SdrUndoFactory& GetSdrUndoFactory() const;
512
513
    // Accessor methods for Palettes, Lists and Tables
514
    // FIXME: this badly needs re-factoring...
515
1.66M
    const XPropertyListRef& GetPropertyList( XPropertyListType t ) const { return maProperties[ t ]; }
516
20.4k
    void             SetPropertyList( XPropertyListRef const & p ) { maProperties[ p->Type() ] = p; }
517
518
    // friendlier helpers
519
119k
    XDashListRef     GetDashList() const     { return XPropertyList::AsDashList(GetPropertyList( XPropertyListType::Dash )); }
520
258k
    XHatchListRef    GetHatchList() const    { return XPropertyList::AsHatchList(GetPropertyList( XPropertyListType::Hatch )); }
521
258k
    XColorListRef    GetColorList() const    { return XPropertyList::AsColorList(GetPropertyList( XPropertyListType::Color )); }
522
258k
    XBitmapListRef   GetBitmapList() const   { return XPropertyList::AsBitmapList(GetPropertyList( XPropertyListType::Bitmap )); }
523
258k
    XPatternListRef  GetPatternList() const  { return XPropertyList::AsPatternList(GetPropertyList( XPropertyListType::Pattern )); }
524
119k
    XLineEndListRef  GetLineEndList() const  { return XPropertyList::AsLineEndList(GetPropertyList( XPropertyListType::LineEnd )); }
525
258k
    XGradientListRef GetGradientList() const { return XPropertyList::AsGradientList(GetPropertyList( XPropertyListType::Gradient )); }
526
527
    // The DrawingEngine only references the StyleSheetPool, whoever
528
    // made it needs to delete it.
529
6.80M
    SfxStyleSheetBasePool* GetStyleSheetPool() const         { return mxStyleSheetPool.get(); }
530
59.7k
    void SetStyleSheetPool(SfxStyleSheetBasePool* pPool)     { mxStyleSheetPool=pPool; }
531
532
    void setTheme(std::shared_ptr<model::Theme> const& pTheme);
533
    std::shared_ptr<model::Theme> const& getTheme() const;
534
535
    void    SetStarDrawPreviewMode(bool bPreview);
536
0
    bool    IsStarDrawPreviewMode() const { return m_bStarDrawPreviewMode; }
537
538
0
    bool GetDisableTextEditUsesCommonUndoManager() const { return mbDisableTextEditUsesCommonUndoManager; }
539
20
    void SetDisableTextEditUsesCommonUndoManager(bool bNew) { mbDisableTextEditUsesCommonUndoManager = bNew; }
540
541
    css::uno::Reference< css::frame::XModel > const & getUnoModel();
542
    void setUnoModel( const css::uno::Reference< css::frame::XModel >& xModel );
543
544
    // these functions are used by the api to disable repaints during a
545
    // set of api calls.
546
28.7M
    bool isLocked() const { return mbModelLocked; }
547
    void setLock( bool bLock );
548
549
    void            SetForbiddenCharsTable( const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars );
550
1.99M
    const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharsTable() const { return mpForbiddenCharactersTable;}
551
552
    void SetCharCompressType( CharCompressType nType );
553
588k
    CharCompressType GetCharCompressType() const { return mnCharCompressType; }
554
555
    void SetKernAsianPunctuation( bool bEnabled );
556
1.96M
    bool IsKernAsianPunctuation() const { return mbKernAsianPunctuation; }
557
558
    void SetAddExtLeading( bool bEnabled );
559
1.96M
    bool IsAddExtLeading() const { return mbAddExtLeading; }
560
561
    void SetCompatibilityFlag(SdrCompatibilityFlag eFlag, bool bEnabled);
562
    /// @returns state of the SdrCompatibilityFlag
563
    bool GetCompatibilityFlag(SdrCompatibilityFlag eFlag) const;
564
565
    void ReformatAllTextObjects();
566
567
    std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode );
568
    void disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner );
569
570
277k
    bool IsWriter() const { return m_bIsWriter; }
571
0
    void SetWriterIdle(bool bIsWriterIdle) { m_bIsWriterIdle = bIsWriterIdle; }
572
203k
    bool IsWriterIdle() const { return m_bIsWriterIdle; }
573
574
0
    bool IsPDFDocument() const { return m_bIsPDFDocument; }
575
    void setPDFDocument(bool bIsPDFDocument)
576
0
    {
577
0
        m_bIsPDFDocument = bIsPDFDocument;
578
0
    }
579
580
    // Used as a fallback in *::ReadUserDataSequence() to process common properties
581
    void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue);
582
    void WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues);
583
584
    /** returns the numbering type that is used to format page fields in drawing shapes */
585
    virtual SvxNumType GetPageNumType() const;
586
587
    /** copies the items from the source set to the destination set. Both sets must have
588
        same ranges but can have different pools. */
589
    static void MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel& rNewModel );
590
591
5.06M
    bool IsInDestruction() const { return mbInDestruction;}
592
593
    static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
594
595
    /** enables (true) or disables (false) recording of undo actions
596
        If undo actions are added while undo is disabled, they are deleted.
597
        Disabling undo does not clear the current undo buffer! */
598
    void EnableUndo( bool bEnable );
599
600
    /** returns true if undo is currently enabled
601
        This returns false if undo was disabled using EnableUndo( false ) and
602
        also during the runtime of the Undo() and Redo() methods. */
603
    bool IsUndoEnabled() const;
604
605
    // used to prevent object name change during page move
606
0
    bool DoesMakePageObjectsNamesUnique() const { return mbMakePageObjectsNamesUnique; }
607
0
    void DoMakePageObjectsNamesUnique(bool bDo) { mbMakePageObjectsNamesUnique = bDo; }
608
609
0
    virtual sal_Int32 getImagePreferredDPI() const { return 0; }
610
611
    virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
612
613
2.64k
    bool IsVOCInvalidationIsReliable() const { return mbVOCInvalidationIsReliable; }
614
20.4k
    void SetVOCInvalidationIsReliable(bool b) { mbVOCInvalidationIsReliable = b; }
615
};
616
617
/*
618
            +-----------+
619
            | SdrModel  |
620
            +--+------+-+
621
               |      +-----------+
622
          +----+-----+            |
623
          |   ...    |            |
624
     +----+---+ +----+---+  +-----+--------+
625
     |SdrPage | |SdrPage |  |SdrLayerAdmin |
626
     +---+----+ +-+--+--++  +---+-------+--+
627
         |        |  |  |       |       +-------------------+
628
    +----+----+           +-----+-----+             +-------+-------+
629
    |   ...   |           |    ...    |             |      ...      |
630
+---+---+ +---+---+  +----+----+ +----+----+  +-----+------+ +------+-----+
631
|SdrObj | |SdrObj |  |SdrLayer | |SdrLayer |  |SdrLayerSet | |SdrLayerSet |
632
+-------+ +-------+  +---------+ +---------+  +------------+ +------------+
633
This class: SdrModel is the head of the data models for the StarView Drawing Engine.
634
635
///////////////////////////////////////////////////////////////////////////////////////////////// */
636
637
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */