Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdobj.hxx
Line
Count
Source
1
/*
2
 * This file is part of the LibreOffice project.
3
 *
4
 * This Source Code Form is subject to the terms of the Mozilla Public
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
 *
8
 * This file incorporates work covered by the following license notice:
9
 *
10
 *   Licensed to the Apache Software Foundation (ASF) under one or more
11
 *   contributor license agreements. See the NOTICE file distributed
12
 *   with this work for additional information regarding copyright
13
 *   ownership. The ASF licenses this file to you under the Apache
14
 *   License, Version 2.0 (the "License"); you may not use this file
15
 *   except in compliance with the License. You may obtain a copy of
16
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
17
 */
18
19
#pragma once
20
21
#include <memory>
22
#include <com/sun/star/uno/Any.hxx>
23
#include <cppuhelper/weak.hxx>
24
#include <cppuhelper/weakref.hxx>
25
#include <rtl/ustring.hxx>
26
#include <vcl/outdev.hxx>
27
#include <svl/lstner.hxx>
28
#include <svl/poolitem.hxx>
29
#include <svl/typedwhich.hxx>
30
#include <tools/degree.hxx>
31
#include <svx/svdtypes.hxx>
32
#include <svx/svdobjkind.hxx>
33
#include <svx/svxdllapi.h>
34
#include <tools/UniqueID.hxx>
35
#include <tools/link.hxx>
36
#include <tools/gen.hxx>
37
#include <unotools/resmgr.hxx>
38
39
#include <unordered_set>
40
41
class SfxBroadcaster;
42
class E3dObject;
43
class E3dScene;
44
class OutlinerParaObject;
45
class Outliner;
46
class SdrDragStat;
47
class SdrHdl;
48
class SdrHdlList;
49
class SdrItemPool;
50
class SdrModel;
51
class SdrObjList;
52
class SdrObject;
53
class SdrOle2Obj;
54
class SdrPage;
55
class SdrPageView;
56
class SdrTextObj;
57
class SfxItemSet;
58
class SfxGrabBagItem;
59
class SfxStyleSheet;
60
class SfxItemPool;
61
class SdrVirtObj;
62
class SdrObjPlusData;
63
class SdrGluePoint;
64
class SdrGluePointList;
65
class SdrLayerIDSet;
66
class Fraction;
67
enum class PointerStyle;
68
class Graphic;
69
class SvxShape;
70
class SdrObjGeoData;
71
namespace basegfx
72
{
73
    class B2DPoint;
74
    class B2DPolyPolygon;
75
    class B2DHomMatrix;
76
}
77
78
namespace sdr { class ObjectUser; }
79
namespace sdr::properties { class BaseProperties; }
80
namespace sdr::contact { class ViewContact; }
81
namespace sdr::annotation { class ObjectAnnotationData; }
82
namespace com::sun::star::drawing { class XShape; }
83
namespace svx::diagram { class IDiagramHelper; }
84
85
86
enum class SdrInventor : sal_uInt32 {
87
    Unknown          = 0,
88
    BasicDialog      = sal_uInt32( 'D' | ('L' << 8) | ('G' << 16) | ('1' << 24) ),
89
    Default          = sal_uInt32( 'S' | ('V' << 8) | ('D' << 16) | ('r' << 24) ),
90
    E3d              = sal_uInt32( 'E' | ('3' << 8) | ('D' << 16) | ('1' << 24) ),
91
    FmForm           = sal_uInt32( 'F' | ('M' << 8) | ('0' << 16) | ('1' << 24) ),
92
    IMap             = sal_uInt32( 'I' | ('M' << 8) | ('A' << 16) | ('P' << 24) ),
93
    ReportDesign     = sal_uInt32( 'R' | ('P' << 8) | ('T' << 16) | ('1' << 24) ),
94
    ScOrSwDraw       = sal_uInt32( 'S' | ('C' << 8) | ('3' << 16) | ('0' << 24) ), // Used in sc/ and sw/
95
    SgaImap          = sal_uInt32( 'S' | ('D' << 8) | ('U' << 16) | ('D' << 24) ),
96
    StarDrawUserData = sal_uInt32( 'S' | ('D' << 8) | ('U' << 16) | ('D' << 24) ),
97
    Swg              = sal_uInt32( 'S' | ('W' << 8) | ('G' << 16) ),
98
};
99
100
enum class SdrUserCallType {
101
    MoveOnly,         // only moved, size unchanged
102
    Resize,           // size and maybe position changed
103
    ChangeAttr,       // attribute changed. Eventually new size, because of line width
104
    Delete,           // object is going to be deleted soon, no attributes anymore
105
    Inserted,         // inserted into an object list (e.g. Page)
106
    Removed,          // removed from an object list
107
    ChildMoveOnly,    // a child within a group has changed
108
    ChildResize,      // a child within a group has changed
109
    ChildChangeAttr,  // a child within a group has changed
110
    ChildDelete,      // a child within a group has changed
111
    ChildInserted,    // a child within a group has changed
112
    ChildRemoved      // a child within a group has changed
113
};
114
115
class SVXCORE_DLLPUBLIC SdrObjUserCall
116
{
117
public:
118
    virtual ~SdrObjUserCall();
119
    virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect);
120
    virtual void const* GetPDFAnchorStructureElementKey(SdrObject const& rObj);
121
};
122
123
class SVXCORE_DLLPUBLIC SdrObjMacroHitRec
124
{
125
public:
126
    Point                       aPos;
127
    const SdrLayerIDSet*        pVisiLayer;
128
    const SdrPageView*          pPageView;
129
    sal_uInt16                  nTol;
130
131
    SdrObjMacroHitRec();
132
};
133
134
/**
135
 * User data of a drawing object, e.g. application specific data.
136
 * Every drawing object can have an arbitrary amount of such records (SV list).
137
 * Whoever wants to save data here, must inherit from this and set a corresponding link in the factory.
138
 */
139
class SVXCORE_DLLPUBLIC SdrObjUserData
140
{
141
    SdrInventor                      m_nInventor;
142
    sal_uInt16                       m_nIdentifier;
143
144
    void operator=(const SdrObjUserData& rData) = delete;
145
    bool operator==(const SdrObjUserData& rData) const = delete;
146
    bool operator!=(const SdrObjUserData& rData) const = delete;
147
148
public:
149
    SdrObjUserData(SdrInventor nInv, sal_uInt16 nId);
150
    SdrObjUserData(const SdrObjUserData& rData);
151
    virtual ~SdrObjUserData();
152
153
    virtual std::unique_ptr<SdrObjUserData> Clone(SdrObject* pObj1) const = 0; // #i71039# NULL -> 0
154
16.7M
    SdrInventor GetInventor() const { return m_nInventor;}
155
15.5M
    sal_uInt16 GetId() const { return m_nIdentifier;}
156
};
157
158
159
/**
160
 * Provides information about various ZObject properties
161
 */
162
class SVXCORE_DLLPUBLIC SdrObjTransformInfoRec
163
{
164
public:
165
    bool bMoveAllowed : 1;             // if false, object cannot be moved
166
    bool bResizeFreeAllowed : 1;       // if false, object cannot be resized freely
167
    bool bResizePropAllowed : 1;       // if false, object cannot even be resized proportionally
168
    bool bRotateFreeAllowed : 1;       // if false, object cannot be rotated freely
169
    bool bRotate90Allowed : 1;         // if false, object cannot even be rotated in 90 degree steps
170
    bool bMirrorFreeAllowed : 1;       // if false, object cannot be mirrored freely
171
    bool bMirror45Allowed : 1;         // if false, object cannot even be mirrored over axes in a 45 degree raster
172
    bool bMirror90Allowed : 1;         // if false, object cannot even be mirrored over axes in a 90 degree raster
173
    bool bTransparenceAllowed : 1;     // if false, object does not have an interactive transparence control
174
    bool bShearAllowed : 1;            // if false, object cannot be sheared
175
    bool bEdgeRadiusAllowed : 1;
176
    bool bNoOrthoDesired : 1;          // is true for Rect; is false for BMP, MTF
177
    bool bNoContortion : 1;            // if false, contortion not possible (for crook, only true for PathObj and grouped PathObjs)
178
    bool bCanConvToPath : 1;           // if false, no conversion into PathObj possible
179
    bool bCanConvToPoly : 1;           // if false, no conversion into PolyObj possible
180
    bool bCanConvToContour : 1;        // if false, no conversion down to whole contour possible
181
    bool bCanConvToPathLineToArea : 1; // if false, no conversion into PathObj with transformation from LineToArea possible
182
    bool bCanConvToPolyLineToArea : 1; // if false, no conversion into PolyObj with transformation from LineToArea possible
183
184
    SdrObjTransformInfoRec();
185
};
186
187
////////////////////////////////////////////////////////////////////////////////////////////////////
188
//
189
//  SdrObject
190
//      SdrAttrObj
191
//          E3dObject
192
//              E3dCompoundObject
193
//                  E3dCubeObj
194
//                  E3dExtrudeObj
195
//                  E3dLatheObj
196
//                  E3dPolygonObj
197
//                  E3dSphereObj
198
//              E3dScene
199
//          SdrTextObj
200
//              SdrObjCustomShape
201
//                  OCustomShape
202
//              SdrEdgeObj
203
//              SdrMeasureObj
204
//              SdrPathObj
205
//              SdrRectObj
206
//                  SdrCaptionObj
207
//                  SdrCircObj
208
//                  SdrGrafObj
209
//                  SdrMediaObj
210
//                  SdrOle2Obj
211
//                      OOle2Obj
212
//                  SdrUnoObj
213
//                      DlgEdObj
214
//                          DlgEdForm
215
//                      OUnoObject
216
//                      FmFormObj
217
//              SdrTableObj
218
//      SdrObjGroup
219
//      SdrPageObj
220
//      SdrVirtObj
221
//          SwDrawVirtObj
222
//          SwVirtFlyDrawObj
223
//      SwFlyDrawObj
224
225
/// Abstract DrawObject
226
class SVXCORE_DLLPUBLIC SdrObject : public SfxListener, public cppu::OWeakObject
227
{
228
public:
229
    // Basic DiagramHelper support
230
    virtual const std::shared_ptr< svx::diagram::IDiagramHelper >& getDiagramHelper() const;
231
2.11k
    bool isDiagram() const { return bool(getDiagramHelper()); }
232
233
private:
234
    friend class                SdrObjListIter;
235
    friend class                SdrObjList;
236
    friend class                SdrVirtObj;
237
    friend class                SdrRectObj;
238
239
    // OperationSmiley: Allow at each SdrObject to set a FillGeometryDefiningShape,
240
    // so that for SdrObjects where this is set, the definition of a defined FillStyle
241
    // will use this, but the local geometry will be filled. This allows to fill
242
    // multiple shapes with a unified fill, e.g think about CustomShapes.
243
    // Currently this is *only* used for CustomShapes, but may be developed to get a
244
    // common mechanism - usages for it are easy to be found. The current limitation
245
    // to CustomShapes allows to think about these SdrObjects to 'vanish' during the
246
    // lifetime of 'this' - the SdrObjects without SdrPage and SdrModel are used as helper
247
    // objects for SdrObjCustomShape and thus their lifetime is limited to the lifetime
248
    // of this local object. For unifying this mechanism, some weak reference of
249
    // SdrObjects would have to be thought about (not easy with the current implementation).
250
    // So - allow *only* EnhancedCustomShape2d (which creates the visualizations for
251
    // SdrObjCustomShape) to set this. Already allow unified read to use it - thus already
252
    // allowing to implement as standard case for all kinds of SdrObjects.
253
    friend class EnhancedCustomShape2d;
254
    const SdrObject*            mpFillGeometryDefiningShape;
255
10.5k
    void setFillGeometryDefiningShape(const SdrObject* pNew) { mpFillGeometryDefiningShape = pNew; }
256
public:
257
38
    const SdrObject* getFillGeometryDefiningShape() const { return mpFillGeometryDefiningShape; }
258
259
private:
260
    // the SdrModel this objects was created with, unchanged during SdrObject lifetime
261
    SdrModel&                   mrSdrModelFromSdrObject;
262
263
public:
264
    // A SdrObject always needs a SdrModel for lifetime (Pool, ...)
265
    SdrObject(SdrModel& rSdrModel);
266
    // Copy constructor
267
    SdrObject(SdrModel& rSdrModel, SdrObject const & rSource);
268
269
    virtual void SAL_CALL acquire() noexcept override final;
270
    virtual void SAL_CALL release() noexcept override final;
271
272
0
    sal_uInt64 GetUniqueID() const { return maUniqueID.getID(); }
273
274
    // SdrModel/SdrPage access on SdrObject level
275
    SdrPage* getSdrPageFromSdrObject() const;
276
    SdrModel& getSdrModelFromSdrObject() const;
277
278
    // access to possible children (SdrObjGroup/E3dScene)
279
    virtual SdrObjList* getChildrenOfSdrObject() const;
280
281
    // access to parent
282
    SdrObjList* getParentSdrObjListFromSdrObject() const;
283
    SdrObject* getParentSdrObjectFromSdrObject() const;
284
285
private:
286
    SVX_DLLPRIVATE void setParentOfSdrObject(SdrObjList* pNew);
287
288
public:
289
    // react on model/page change
290
    virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage);
291
292
    void AddObjectUser(sdr::ObjectUser& rNewUser);
293
    void RemoveObjectUser(sdr::ObjectUser& rOldUser);
294
295
    sdr::contact::ViewContact& GetViewContact() const;
296
297
    virtual sdr::properties::BaseProperties& GetProperties() const;
298
299
    // DrawContact support: Methods for handling Object changes
300
    void ActionChanged() const;
301
302
    static SdrItemPool& GetGlobalDrawObjectItemPool();
303
    void SetRelativeWidth( double nValue );
304
    void SetRelativeWidthRelation( sal_Int16 eValue );
305
    void SetRelativeHeight( double nValue );
306
    void SetRelativeHeightRelation( sal_Int16 eValue );
307
    const double* GetRelativeWidth() const;
308
    sal_Int16 GetRelativeWidthRelation() const;
309
    const double* GetRelativeHeight() const;
310
    sal_Int16 GetRelativeHeightRelation() const;
311
312
    /// @param bNotMyself = true: set only ObjList to dirty, don't mark this object as dirty.
313
    ///
314
    /// This is needed for instance for NbcMove, because usually one moves SnapRect and aOutRect
315
    /// at the same time to avoid recomputation.
316
    virtual void SetBoundAndSnapRectsDirty(bool bNotMyself = false, bool bRecursive = true);
317
318
    // this method is only for access from Property objects
319
    virtual void SetBoundRectDirty();
320
321
    SfxItemPool & GetObjectItemPool() const;
322
323
    void AddListener(SfxListener& rListener);
324
    void RemoveListener(SfxListener& rListener);
325
326
    void AddReference(SdrVirtObj& rVrtObj);
327
    void DelReference(SdrVirtObj& rVrtObj);
328
    virtual SdrInventor GetObjInventor() const;
329
    virtual SdrObjKind GetObjIdentifier() const;
330
    virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
331
332
    // Layer interface
333
    virtual SdrLayerID GetLayer() const;
334
    virtual void NbcSetLayer(SdrLayerID nLayer);
335
    virtual void SetLayer(SdrLayerID nLayer);
336
    bool isVisibleOnAnyOfTheseLayers(const SdrLayerIDSet& rSet) const;
337
338
    void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle& rBoundRect) const;
339
340
    // #i68101#
341
    // An object may have a user-set Name (Get/SetName()), e.g SdrGrafObj, SdrObjGroup
342
    // or SdrOle2Obj.
343
    // It may also have a Title and a Description for accessibility purposes.
344
    virtual void SetName(const OUString& rStr, const bool bSetChanged = true);
345
    virtual const OUString & GetName() const;
346
    void MakeNameUnique();
347
    void MakeNameUnique(std::unordered_set<OUString>& rNameSet);
348
    virtual void SetTitle(const OUString& rStr);
349
    virtual OUString GetTitle() const;
350
    virtual void SetDescription(const OUString& rStr);
351
    virtual OUString GetDescription() const;
352
    virtual void SetDecorative(bool isDecorative);
353
    virtual bool IsDecorative() const;
354
355
    // Object representing an annotation
356
147k
    bool isAnnotationObject() const { return bool(mpAnnotationData); }
357
    void setAsAnnotationObject();
358
    std::unique_ptr<sdr::annotation::ObjectAnnotationData>& getAnnotationData();
359
360
    // for group objects
361
    bool IsGroupObject() const;
362
    virtual SdrObjList* GetSubList() const;
363
364
    /// The order number (aka ZOrder, aka z-index) determines whether a
365
    /// SdrObject is located above or below another.  Objects are painted from
366
    /// lowest to highest order number.  If the order of SdrObjects in the
367
    /// SdrObjList is changed, the bObjOrdNumsDirty flag is set on the SdrPage
368
    /// and the next GetOrdNum() call recalculates the order number of all
369
    /// SdrObjects in the SdrObjList.
370
    sal_uInt32 GetOrdNum() const;
371
372
    /// Ensure this object is sorted immediately after rFirst
373
    /// ie. rFirst.GetOrdNum() + 1 == this->GetOrdNum()
374
    void ensureSortedImmediatelyAfter(const SdrObject& rFirst);
375
376
    // setting the order number should only happen from the model or from the page
377
    void SetOrdNum(sal_uInt32 nNum);
378
379
    // GrabBagItem for interim interop purposes
380
    void GetGrabBagItem(css::uno::Any& rVal) const;
381
382
    virtual void SetGrabBagItem(const css::uno::Any& rVal);
383
384
    // Return the position in the navigation order for the called object.
385
    // Note that this method may update the navigation position of the
386
    // called and of other SdrObjects.  Therefore this method can not be
387
    // const.
388
    // @return
389
    //     If no navigation position has been explicitly defined then the
390
    //     result of GetOrdNum() is returned.
391
    sal_uInt32 GetNavigationPosition() const;
392
393
    // To make clearer that this method may trigger RecalcBoundRect and thus may be
394
    // expensive and sometimes problematic (inside a bigger object change You will get
395
    // non-useful BoundRects sometimes) i rename that method from GetBoundRect() to
396
    // GetCurrentBoundRect().
397
    virtual const tools::Rectangle& GetCurrentBoundRect() const;
398
399
    // To have a possibility to get the last calculated BoundRect e.g for producing
400
    // the first rectangle for repaints (old and new need to be used) without forcing
401
    // a RecalcBoundRect (which may be problematical and expensive sometimes) i add here
402
    // a new method for accessing the last BoundRect.
403
    virtual const tools::Rectangle& GetLastBoundRect() const;
404
405
    virtual void RecalcBoundRect();
406
407
    void BroadcastObjectChange() const;
408
409
    SfxBroadcaster* GetBroadcaster() const;
410
411
    // set modified-flag in the model
412
    virtual void SetChanged();
413
414
    // Tooling for painting a single object to an OutputDevice. This will be needed as long
415
    // as not all painting is changed to use DrawContact objects.
416
    void SingleObjectPainter(OutputDevice& rOut) const;
417
    bool LineGeometryUsageIsNecessary() const;
418
419
    // RotGrfFlyFrame: If true, this SdrObject supports only limited rotation, that
420
    // means no change of the rotation point (only centered) and no shear allowed
421
    virtual bool HasLimitedRotation() const;
422
423
    // Returns a copy of the object. Every inherited class must reimplement this.
424
    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const = 0;
425
    // helper, since Clone always return the type of the current subclass
426
    template<class T>
427
    static rtl::Reference<T> Clone(T const & rObj, SdrModel& rTargetModel)
428
0
    {
429
0
        rtl::Reference<SdrObject> newObj = rObj.CloneSdrObject(rTargetModel);
430
0
        return static_cast<T*>(newObj.get());
431
0
    }
Unexecuted instantiation: rtl::Reference<SdrGrafObj> SdrObject::Clone<SdrGrafObj>(SdrGrafObj const&, SdrModel&)
Unexecuted instantiation: rtl::Reference<E3dCompoundObject> SdrObject::Clone<E3dCompoundObject>(E3dCompoundObject const&, SdrModel&)
Unexecuted instantiation: rtl::Reference<SdrEdgeObj> SdrObject::Clone<SdrEdgeObj>(SdrEdgeObj const&, SdrModel&)
Unexecuted instantiation: rtl::Reference<SdrPathObj> SdrObject::Clone<SdrPathObj>(SdrPathObj const&, SdrModel&)
Unexecuted instantiation: rtl::Reference<SdrTextObj> SdrObject::Clone<SdrTextObj>(SdrTextObj const&, SdrModel&)
Unexecuted instantiation: rtl::Reference<sdr::table::SdrTableObj> SdrObject::Clone<sdr::table::SdrTableObj>(sdr::table::SdrTableObj const&, SdrModel&)
Unexecuted instantiation: rtl::Reference<SdrMediaObj> SdrObject::Clone<SdrMediaObj>(SdrMediaObj const&, SdrModel&)
432
433
    // Overwriting this object makes no sense, it is too complicated for that
434
    SdrObject& operator=(const SdrObject& rObj) = delete;
435
    SdrObject& operator=(SdrObject&& rObj) = delete;
436
437
    // TakeObjName...() is for the display in the UI, e.g. "3 frames selected"
438
    virtual OUString TakeObjNameSingul() const;
439
    virtual OUString TakeObjNamePlural() const;
440
441
    /// The Xor-Polygon is required by the View to drag the object.
442
    /// All polygons within the PolyPolygon are interpreted as PolyLine.
443
    /// To get a closed Polygon, close it explicitly.
444
    virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
445
446
    /// contour for TextToContour
447
    virtual basegfx::B2DPolyPolygon TakeContour() const;
448
449
    /// Via GetHdlCount the number of Handles can be retrieved.
450
    /// Normally 8, if it's a line 2.
451
    /// For Polygon objects (Polygon/Spline/Bezier) the number may be much
452
    /// larger.  Polygon objects are also allowed to select a point of a
453
    /// selected object.  The handle of that point will then be replaced by
454
    /// a new set of handles (PlusHdl).  For a Polygon this would be a simple
455
    /// selection Handle, for a Bezier curve this may be up to 3 Handles
456
    /// (including Weights).
457
    /// GetHdl() and GetPlusHdl() must create Handle instances with new!
458
    /// An object that returns true from HasSpacialDrag() must provide these
459
    /// methods (incl. FillHdlList()).
460
    virtual sal_uInt32 GetHdlCount() const;
461
    virtual void AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const;
462
    virtual void AddToHdlList(SdrHdlList& rHdlList) const;
463
    virtual void addCropHandles(SdrHdlList& rTarget) const;
464
465
    /// The standard transformations (Move,Resize,Rotate,Mirror,Shear) are
466
    /// taken over by the View (TakeXorPoly(),...).
467
    /// Object type specific dragging like corner radius of Rectangle,
468
    /// control points of Splines, weights of Bezier curves, pointer of
469
    /// Label objects must be handled by the object itself.
470
    /// To keep the Model free of state, the state is kept in the View
471
    /// and then passed to the object. EndDrag usually returns true for success,
472
    /// false may be returned if the dragging did not modify the object,
473
    /// where the View already handles the case that the pointer was not
474
    /// moved at all.
475
    virtual bool hasSpecialDrag() const;
476
    virtual bool beginSpecialDrag(SdrDragStat& rDrag) const;
477
    virtual bool applySpecialDrag(SdrDragStat& rDrag);
478
    virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const;
479
    virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const;
480
481
    // FullDrag support. This is for standard interactions and for SdrObjOwn
482
    // support. If supportsFullDrag() returns true, getFullDragClone has to
483
    // return a cloned SdrObject (who's ownership it loses) at which modifications
484
    // like Move(), Scale(), etc or applySpecialDrag() will be executed. That
485
    // object will be visualized on overlay for full drag, but should not be
486
    // part of the model, thus not changing anything since it's only a temporary
487
    // helper object for interaction
488
    virtual bool supportsFullDrag() const;
489
    virtual rtl::Reference<SdrObject> getFullDragClone() const;
490
491
    /// Every object must be able to create itself interactively.
492
    /// On MouseDown first an object is created, and its BegCreate() method
493
    /// is called.  On every MouseMove, MovCreate() is called.  BrkCreate()
494
    /// is called if the user cancels the interactive object creation.
495
    /// EndCreate() is called on the MouseUp event.  If EndCreate() returns
496
    /// true, the creation is finished; the object is inserted into the
497
    /// corresponding list.  Otherwise it is assumed that further points
498
    /// are necessary to create the object (Polygon, ...).  The parameter
499
    /// eCmd contains the number of mouse clicks (if the application
500
    /// provides it).
501
    /// BckCreate() will undo the previous EndCreate(), e.g. to delete the
502
    /// last point of the Polygon.  If BckCreate() returns false, creation
503
    /// is cancelled.
504
    virtual bool BegCreate(SdrDragStat& rStat);
505
    virtual bool MovCreate(SdrDragStat& rStat); // if true, Xor needs to be repainted
506
    virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
507
    virtual bool BckCreate(SdrDragStat& rStat);
508
    virtual void BrkCreate(SdrDragStat& rStat);
509
510
    /// get the cursor/pointer that signals creating this object
511
    virtual PointerStyle GetCreatePointer() const;
512
513
    /// Polygon dragged by the user when creating the object
514
    virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const;
515
516
    /// The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and
517
    /// SetLogicRect call the corresponding Nbc-methods, send a Repaint
518
    /// broadcast and set the Modified state on the Model.
519
    /// Derived classes should usually only override the Nbc methods.
520
    /// Nbc means "no broadcast".
521
    virtual void NbcMove  (const Size& rSiz);
522
    virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
523
    virtual bool IsSizeValid(Size aTargetSize);
524
    virtual void NbcCrop  (const basegfx::B2DPoint& rRef, double fxFact, double fyFact);
525
    virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) = 0;
526
    // Utility for call sites that don't have sin and cos handy
527
    void NbcRotate(const Point& rRef, Degree100 nAngle);
528
    virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
529
    virtual void NbcShear (const Point& rRef, Degree100 nAngle, double tn, bool bVShear);
530
531
    virtual void Move  (const Size& rSiz);
532
    virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true);
533
    virtual void Crop  (const basegfx::B2DPoint& rRef, double fxFact, double fyFact);
534
    virtual void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs);
535
    virtual void Mirror(const Point& rRef1, const Point& rRef2);
536
    virtual void Shear (const Point& rRef, Degree100 nAngle, double tn, bool bVShear);
537
538
    /// The relative position of a SdrObject is the distance of the upper
539
    /// left corner of the logic bounding rectangle (SnapRect) to the anchor.
540
    virtual void NbcSetRelativePos(const Point& rPnt);
541
    virtual void SetRelativePos(const Point& rPnt);
542
    virtual Point GetRelativePos() const;
543
    void ImpSetAnchorPos(const Point& rPnt);
544
    virtual void NbcSetAnchorPos(const Point& rPnt);
545
    virtual void SetAnchorPos(const Point& rPnt);
546
547
    /// Snap is not done on the BoundRect but if possible on logic coordinates
548
    /// (i.e. without considering stroke width, ...)
549
    /// SetSnapRect() tries to size the Object so that it fits into the
550
    /// passed Rect (without stroke width, ...)
551
    virtual void RecalcSnapRect();
552
    virtual const tools::Rectangle& GetSnapRect() const;
553
    virtual void SetSnapRect(const tools::Rectangle& rRect);
554
    virtual void NbcSetSnapRect(const tools::Rectangle& rRect);
555
556
    // Logic Rect: for the Rect for instance without regard to rotation angle, shear, ...
557
    virtual const tools::Rectangle& GetLogicRect() const;
558
    virtual void SetLogicRect(const tools::Rectangle& rRect);
559
    // @param bAdaptTextMinSize pass false if you know it is safe to avoid the cost of doing
560
    //              text layout right now.
561
    virtual void NbcSetLogicRect(const tools::Rectangle& rRect, bool bAdaptTextMinSize = true);
562
563
    // the default is to set the logic rect to the given rectangle rMaxRect. If the shape
564
    // has an intrinsic aspect ratio it may set the logic rect so the aspect
565
    // ratio is kept but still inside the rectangle rMaxRect.
566
    // If bShrinkOnly is set to true, the size of the current logic rect will not
567
    // be changed if it is smaller than the given rectangle rMaxRect.
568
    virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false );
569
570
    // rotation and shear angle
571
    virtual Degree100 GetRotateAngle() const;
572
    virtual Degree100 GetShearAngle(bool bVertical = false) const;
573
574
    /// snap to special points of an Object (polygon points, center of circle)
575
    virtual sal_uInt32 GetSnapPointCount() const;
576
    virtual Point GetSnapPoint(sal_uInt32 i) const;
577
578
    // For objects, whose points can be moved individually.
579
    // (e.g. polygons, polylines, lines)
580
    // The points of those objects are selected (if necessary multiselection),
581
    // deleted, inserted, or as a multiselection moved or rotated...
582
    // Only such objects can have PlusHandles (e.g. the weights of a Bezier curve).
583
    virtual bool IsPolyObj() const;
584
    virtual sal_uInt32 GetPointCount() const;
585
    virtual Point GetPoint(sal_uInt32 i) const;
586
    void SetPoint(const Point& rPnt, sal_uInt32 i);
587
    virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i);
588
589
    // get all geometrical data for undo/redo
590
    virtual std::unique_ptr<SdrObjGeoData> GetGeoData() const;
591
    virtual void SetGeoData(const SdrObjGeoData& rGeo);
592
593
    // ItemSet access
594
    const SfxItemSet& GetMergedItemSet() const;
595
    void SetMergedItem(const SfxPoolItem& rItem);
596
    void ClearMergedItem(const sal_uInt16 nWhich = 0);
597
    // @param bAdjustTextFrameWidthAndHeight pass false if you know it is safe to avoid the cost of doing
598
    //              text layout right now.
599
    void SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems = false, bool bAdjustTextFrameWidthAndHeight = true);
600
    const SfxPoolItem& GetMergedItem(const sal_uInt16 nWhich) const;
601
    template<class T>
602
    const T&           GetMergedItem( TypedWhichId<T> nWhich ) const
603
2.46M
    {
604
2.46M
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
2.46M
    }
SdrCustomShapeGeometryItem const& SdrObject::GetMergedItem<SdrCustomShapeGeometryItem>(TypedWhichId<SdrCustomShapeGeometryItem>) const
Line
Count
Source
603
983k
    {
604
983k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
983k
    }
XLineWidthItem const& SdrObject::GetMergedItem<XLineWidthItem>(TypedWhichId<XLineWidthItem>) const
Line
Count
Source
603
5.91k
    {
604
5.91k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
5.91k
    }
XLineColorItem const& SdrObject::GetMergedItem<XLineColorItem>(TypedWhichId<XLineColorItem>) const
Line
Count
Source
603
7.48k
    {
604
7.48k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
7.48k
    }
Unexecuted instantiation: SvxFontHeightItem const& SdrObject::GetMergedItem<SvxFontHeightItem>(TypedWhichId<SvxFontHeightItem>) const
Unexecuted instantiation: SfxBoolItem const& SdrObject::GetMergedItem<SfxBoolItem>(TypedWhichId<SfxBoolItem>) const
SdrTextFitToSizeTypeItem const& SdrObject::GetMergedItem<SdrTextFitToSizeTypeItem>(TypedWhichId<SdrTextFitToSizeTypeItem>) const
Line
Count
Source
603
17.9k
    {
604
17.9k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
17.9k
    }
SdrMetricItem const& SdrObject::GetMergedItem<SdrMetricItem>(TypedWhichId<SdrMetricItem>) const
Line
Count
Source
603
69.6k
    {
604
69.6k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
69.6k
    }
SdrTextVertAdjustItem const& SdrObject::GetMergedItem<SdrTextVertAdjustItem>(TypedWhichId<SdrTextVertAdjustItem>) const
Line
Count
Source
603
17.4k
    {
604
17.4k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
17.4k
    }
SdrTextHorzAdjustItem const& SdrObject::GetMergedItem<SdrTextHorzAdjustItem>(TypedWhichId<SdrTextHorzAdjustItem>) const
Line
Count
Source
603
17.4k
    {
604
17.4k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
17.4k
    }
SvxFrameDirectionItem const& SdrObject::GetMergedItem<SvxFrameDirectionItem>(TypedWhichId<SvxFrameDirectionItem>) const
Line
Count
Source
603
15.8k
    {
604
15.8k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
15.8k
    }
XFillStyleItem const& SdrObject::GetMergedItem<XFillStyleItem>(TypedWhichId<XFillStyleItem>) const
Line
Count
Source
603
523k
    {
604
523k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
523k
    }
XFillColorItem const& SdrObject::GetMergedItem<XFillColorItem>(TypedWhichId<XFillColorItem>) const
Line
Count
Source
603
5.74k
    {
604
5.74k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
5.74k
    }
XFillGradientItem const& SdrObject::GetMergedItem<XFillGradientItem>(TypedWhichId<XFillGradientItem>) const
Line
Count
Source
603
559
    {
604
559
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
559
    }
XFillBitmapItem const& SdrObject::GetMergedItem<XFillBitmapItem>(TypedWhichId<XFillBitmapItem>) const
Line
Count
Source
603
700
    {
604
700
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
700
    }
XFillBmpStretchItem const& SdrObject::GetMergedItem<XFillBmpStretchItem>(TypedWhichId<XFillBmpStretchItem>) const
Line
Count
Source
603
16
    {
604
16
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
16
    }
XFillBmpTileItem const& SdrObject::GetMergedItem<XFillBmpTileItem>(TypedWhichId<XFillBmpTileItem>) const
Line
Count
Source
603
700
    {
604
700
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
700
    }
XFillTransparenceItem const& SdrObject::GetMergedItem<XFillTransparenceItem>(TypedWhichId<XFillTransparenceItem>) const
Line
Count
Source
603
6.09k
    {
604
6.09k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
6.09k
    }
XLineStyleItem const& SdrObject::GetMergedItem<XLineStyleItem>(TypedWhichId<XLineStyleItem>) const
Line
Count
Source
603
493k
    {
604
493k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
493k
    }
Unexecuted instantiation: SdrGrafCropItem const& SdrObject::GetMergedItem<SdrGrafCropItem>(TypedWhichId<SdrGrafCropItem>) const
XLineEndItem const& SdrObject::GetMergedItem<XLineEndItem>(TypedWhichId<XLineEndItem>) const
Line
Count
Source
603
59
    {
604
59
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
59
    }
XLineEndWidthItem const& SdrObject::GetMergedItem<XLineEndWidthItem>(TypedWhichId<XLineEndWidthItem>) const
Line
Count
Source
603
59
    {
604
59
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
59
    }
XLineEndCenterItem const& SdrObject::GetMergedItem<XLineEndCenterItem>(TypedWhichId<XLineEndCenterItem>) const
Line
Count
Source
603
59
    {
604
59
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
59
    }
XLineStartItem const& SdrObject::GetMergedItem<XLineStartItem>(TypedWhichId<XLineStartItem>) const
Line
Count
Source
603
59
    {
604
59
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
59
    }
XLineStartWidthItem const& SdrObject::GetMergedItem<XLineStartWidthItem>(TypedWhichId<XLineStartWidthItem>) const
Line
Count
Source
603
59
    {
604
59
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
59
    }
XLineStartCenterItem const& SdrObject::GetMergedItem<XLineStartCenterItem>(TypedWhichId<XLineStartCenterItem>) const
Line
Count
Source
603
59
    {
604
59
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
59
    }
Unexecuted instantiation: XFillHatchItem const& SdrObject::GetMergedItem<XFillHatchItem>(TypedWhichId<XFillHatchItem>) const
Unexecuted instantiation: XFormTextStyleItem const& SdrObject::GetMergedItem<XFormTextStyleItem>(TypedWhichId<XFormTextStyleItem>) const
SdrOnOffItem const& SdrObject::GetMergedItem<SdrOnOffItem>(TypedWhichId<SdrOnOffItem>) const
Line
Count
Source
603
778
    {
604
778
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
778
    }
SdrTextFixedCellHeightItem const& SdrObject::GetMergedItem<SdrTextFixedCellHeightItem>(TypedWhichId<SdrTextFixedCellHeightItem>) const
Line
Count
Source
603
15.9k
    {
604
15.9k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
15.9k
    }
SfxStringItem const& SdrObject::GetMergedItem<SfxStringItem>(TypedWhichId<SfxStringItem>) const
Line
Count
Source
603
277k
    {
604
277k
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
277k
    }
SfxInt16Item const& SdrObject::GetMergedItem<SfxInt16Item>(TypedWhichId<SfxInt16Item>) const
Line
Count
Source
603
26
    {
604
26
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
26
    }
XSecondaryFillColorItem const& SdrObject::GetMergedItem<XSecondaryFillColorItem>(TypedWhichId<XSecondaryFillColorItem>) const
Line
Count
Source
603
536
    {
604
536
        return static_cast<const T&>(GetMergedItem(sal_uInt16(nWhich)));
605
536
    }
Unexecuted instantiation: SvxCharScaleWidthItem const& SdrObject::GetMergedItem<SvxCharScaleWidthItem>(TypedWhichId<SvxCharScaleWidthItem>) const
Unexecuted instantiation: SvxKerningItem const& SdrObject::GetMergedItem<SvxKerningItem>(TypedWhichId<SvxKerningItem>) const
Unexecuted instantiation: SvxFontItem const& SdrObject::GetMergedItem<SvxFontItem>(TypedWhichId<SvxFontItem>) const
Unexecuted instantiation: SvxPostureItem const& SdrObject::GetMergedItem<SvxPostureItem>(TypedWhichId<SvxPostureItem>) const
Unexecuted instantiation: SvxWeightItem const& SdrObject::GetMergedItem<SvxWeightItem>(TypedWhichId<SvxWeightItem>) const
Unexecuted instantiation: SwFormatFrameSize const& SdrObject::GetMergedItem<SwFormatFrameSize>(TypedWhichId<SwFormatFrameSize>) const
Unexecuted instantiation: SvxFieldItem const& SdrObject::GetMergedItem<SvxFieldItem>(TypedWhichId<SvxFieldItem>) const
606
607
    // syntactical sugar for ItemSet accesses
608
    void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems = false);
609
610
    // NotPersistAttr for Layer, ObjName, geometrical transformations etc.
611
    void TakeNotPersistAttr(SfxItemSet& rAttr) const;
612
    void ApplyNotPersistAttr(const SfxItemSet& rAttr);
613
    void NbcApplyNotPersistAttr(const SfxItemSet& rAttr);
614
615
    // if bDontRemoveHardAttr is false, set all attributes, which were set in the style sheet, to their default value
616
    // if true, all hard attributes keep their values
617
    void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr);
618
    // @param bAdjustTextFrameWidthAndHeight pass false if you know it is safe to avoid the cost of doing
619
    //              text layout right now.
620
    void NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bAdjustTextFrameWidthAndHeight = true);
621
    SfxStyleSheet* GetStyleSheet() const;
622
623
    virtual bool HasTextEdit() const;
624
625
    // keep text in outliner's format
626
    // SetOutlinerParaObject: transfer ownership of *pTextObject!
627
    void SetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject);
628
    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject, bool bAdjustTextFrameWidthAndHeight = true);
629
    virtual OutlinerParaObject* GetOutlinerParaObject() const;
630
    virtual void NbcReformatText();
631
632
    void BurnInStyleSheetAttributes();
633
634
    // macro abilities, e.g. a rectangle as PushButton.
635
    virtual bool HasMacro() const;
636
    virtual SdrObject* CheckMacroHit (const SdrObjMacroHitRec& rRec) const;
637
    virtual PointerStyle GetMacroPointer (const SdrObjMacroHitRec& rRec) const;
638
    virtual void PaintMacro (OutputDevice& rOut, const tools::Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const;
639
    virtual bool DoMacro (const SdrObjMacroHitRec& rRec);
640
    bool IsMacroHit(const SdrObjMacroHitRec& rRec) const;
641
642
    // Connectors
643
    // (see also documentation in SvdoEdge.hxx, SdrEdgeObj, as well as SvdGlue.hxx and SvdGlEV.hxx)
644
    //
645
    // There are nodes and edges. In theory an edge can also be a node, but this isn't implemented yet.
646
    // A node has a number of gluepoints, onto which edges can glued to
647
    // An edge can be either
648
    // - without any connection to any node,
649
    // - or connected on one end to a node, while the other end is not connected,
650
    // - or connected on both ends with exactly one node each.
651
    // The edge is listener for its up to two nodes.
652
    // Whenever a node is moved or resized, all its connected edges follow.
653
    // This is also true for SetGluePoint()... on the node.
654
    // On the other hand, moving/resizing an edge breaks the connection.
655
656
    // automatic gluepoints:
657
    // a node object must provide four vertex and corner positions
658
    // usually 0: top, 1: right, 2: bottom, 3: left
659
    virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const;
660
661
    // usually:
662
    // 0: top-left, 1: top-right, 2: bottom-right, 3: bottom-left
663
    virtual SdrGluePoint GetCornerGluePoint(sal_uInt16 nNum) const;
664
665
    // list of all gluepoints, can be NULL
666
    virtual const SdrGluePointList* GetGluePointList() const;
667
668
    // after changing the GluePointList, one has to call the object's SendRepaintBroadcast!
669
    virtual SdrGluePointList* ForceGluePointList();
670
671
    // to be set temporarily when transforming related object(?)
672
    void SetGlueReallyAbsolute(bool bOn);
673
    void NbcRotateGluePoints(const Point& rRef, Degree100 nAngle, double sn, double cs);
674
    void NbcMirrorGluePoints(const Point& rRef1, const Point& rRef2);
675
    void NbcShearGluePoints (const Point& rRef, double tn, bool bVShear);
676
677
    // if bTail1 is true, line start, otherwise line end
678
    // if pObj is null disconnect
679
    virtual void ConnectToNode(bool bTail1, SdrObject* pObj);
680
    virtual void DisconnectFromNode(bool bTail1);
681
    virtual SdrObject* GetConnectedNode(bool bTail1) const;
682
683
    // sets the writing mode of the object's context
684
    // Objects which itself do not support different writing modes will ignore this call.
685
    // Objects which support different writing modes, but have an own, explicit writing mode set,
686
    // will also ignore this call.
687
    // Objects which support different writing modes, and whose own mode is set to css.text.WritingMode2.CONTEXT,
688
    // will use the given writing mode to calculate their "effective writing mode".
689
    // The behaviour of this method is undefined if you pass css.text.WritingMode2.CONTEXT.
690
    // @param _nContextWritingMode
691
    //     the effective writing mode of the context of the object
692
    virtual void    SetContextWritingMode( const sal_Int16 _nContextWritingMode );
693
694
    // If an object is able to convert itself into a polygon or into a Bezier curve (or into both),
695
    // then the following methods should be overridden.
696
    // E.g., convert a RectObj with line width 10, SOLID_PEN into a polygon:
697
    // In the bLineToArea=false mode a PolyObj with four supporting points,
698
    // line width 10 and SOLID_PEN shall be created.
699
    // On the contrary in the bLineToArea=true mode the generated object should
700
    // still have a line attribute NULL_PEN, and the line (also line pattern)
701
    // itself should be emulated by the polygon area, which thereby can be
702
    // manipulated by the user afterwards.
703
    // The RectObj therefore can only convert correctly if it has an area attribute NULL_BRUSH.
704
    // In this case it would have to:
705
    // - set SOLID_BRUSH with the color of the given pen,
706
    // - set NULL_PEN, and
707
    // - generate tools::PolyPolygon with two polygons with four supporting points each.
708
    // In each case the return value is a SdrObject*, because it is also
709
    // allowed to return group objects (e.g. for SdrTextObj).
710
    // In the case of the conversion from TextObj to PathObj,
711
    // both modi (bLineToArea=true/false) would be identical.
712
    // The methods' default implementations report "I'm unable to do this" (false/null).
713
    virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const;
714
    rtl::Reference<SdrObject> ConvertToPolyObj(bool bBezier, bool bLineToArea) const;
715
716
    // convert this path object to contour object; bForceLineDash converts even
717
    // when there is no filled new polygon created from line-to-polygon conversion,
718
    // specially used for XLINE_DASH and 3D conversion
719
    rtl::Reference<SdrObject> ConvertToContourObj(SdrObject* pRet, bool bForceLineDash = false) const;
720
private:
721
    rtl::Reference<SdrObject> ImpConvertToContourObj(bool bForceLineDash);
722
public:
723
724
    // if true, reference onto an object
725
639k
    bool IsVirtualObj() const { return m_bVirtObj;}
726
727
    // is true, if object can probably be filled
728
    // is false, if object has probably line ends
729
    // is invalid, if this is a group object
730
46.1k
    bool IsClosedObj() const { return m_bClosedObj;}
731
732
    // tdf#118662 reorganize inserted state, no local bool needed anymore,
733
    // it depends on being a member of a SdrObjList
734
    void InsertedStateChange();
735
2.25M
    bool IsInserted() const { return nullptr != getParentSdrObjListFromSdrObject(); }
736
737
4.57k
    bool IsEdgeObj() const { return m_bIsEdge;}
738
60
    bool Is3DObj() const { return m_bIs3DObj;}
739
37.0k
    bool IsUnoObj() const { return m_bIsUnoObj;}
740
    void SetMoveProtect(bool bProt);
741
35.2k
    bool IsMoveProtect() const { return m_bMovProt;}
742
    void SetResizeProtect(bool bProt);
743
226k
    bool IsResizeProtect() const { return m_bSizProt;}
744
    virtual void SetPrintable(bool isPrintable);
745
    virtual bool IsPrintable() const;
746
    virtual void SetVisible(bool isVisible);
747
    virtual bool IsVisible() const;
748
    void SetMarkProtect(bool bProt);
749
28
    bool IsMarkProtect() const { return m_bMarkProt;}
750
2.28M
    virtual bool IsSdrTextObj() const { return false; }
751
0
    virtual bool IsSdrOle2Obj() const { return false; }
752
0
    virtual bool IsTextPath() const { return false ; }
753
754
    /// Whether the aspect ratio should be kept by default when resizing.
755
0
    virtual bool shouldKeepAspectRatio() const { return false; }
756
757
    // application specific data
758
    sal_uInt16 GetUserDataCount() const;
759
    SdrObjUserData* GetUserData(sal_uInt16 nNum) const;
760
761
    void AppendUserData(std::unique_ptr<SdrObjUserData> pData);
762
763
    // removes the record from the list and performs delete (FreeMem+Dtor).
764
    void DeleteUserData(sal_uInt16 nNum);
765
766
    // access to the UNO representation of the shape
767
    virtual css::uno::Reference< css::drawing::XShape > getUnoShape();
768
769
    static SdrObject* getSdrObjectFromXShape( const css::uno::Reference< css::uno::XInterface >& xInt );
770
771
    // notifies a change in the given property, to all applicable listeners registered at the associated SvxShape
772
    //
773
    // This method is equivalent to calling getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty ),
774
    // exception that it is allowed to be called when there does not yet exist an associated SvxShape - in which
775
    // case the method will silently return without doing anything.
776
    void notifyShapePropertyChange( const OUString& rPropName ) const;
777
778
    // transformation interface for StarOfficeAPI. This implements support for
779
    // homogen 3x3 matrices containing the transformation of the SdrObject. At the
780
    // moment it contains a shearX, rotation and translation, but for setting all linear
781
    // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
782
    //
783
    // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
784
    // with the base geometry and returns TRUE. Otherwise it returns FALSE.
785
    virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const;
786
787
    // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
788
    // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
789
    // to use (0,0) as upper left and will be scaled to the given size in the matrix.
790
    virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon);
791
792
    // give info if object is in destruction
793
    bool IsInDestruction() const;
794
795
    // return if fill is != XFILL_NONE
796
    bool HasFillStyle() const;
797
    bool HasLineStyle() const;
798
799
    // on import of OLE object from MS documents the BLIP size might be retrieved,
800
    // the following methods are used to control it;
801
    // usually this data makes no sense after the import is finished, since the object
802
    // might be resized
803
0
    const tools::Rectangle& GetBLIPSizeRectangle() const { return maBLIPSizeRectangle;}
804
    void SetBLIPSizeRectangle( const tools::Rectangle& aRect );
805
806
    // #i121917#
807
    virtual bool HasText() const;
808
809
    bool Equals(const SdrObject&) const;
810
811
    virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
812
813
    /// Is this a textbox of a drawinglayer shape?
814
    virtual bool IsTextBox() const;
815
816
    void SetEmptyPresObj(bool bEpt);
817
741k
    bool IsEmptyPresObj() const { return m_bEmptyPresObj;}
818
    void SetCustomPromptText(const OUString& aVal);
819
258k
    OUString GetCustomPromptText() const { return m_aCustomPromptText; }
820
    void SetNotVisibleAsMaster(bool bFlg);
821
0
    bool IsNotVisibleAsMaster() const { return m_bNotVisibleAsMaster;}
822
    void SetUserCall(SdrObjUserCall* pUser);
823
5.08M
    SdrObjUserCall* GetUserCall() const { return m_pUserCall;}
824
    /// @see mbDoNotInsertIntoPageAutomatically
825
    void SetDoNotInsertIntoPageAutomatically(bool bSet);
826
    /// @see mbDoNotInsertIntoPageAutomatically
827
33.9k
    bool IsDoNotInsertIntoPageAutomatically() const { return mbDoNotInsertIntoPageAutomatically;}
828
829
    // Warning: this method should only be used if you really know what you're doing
830
2.27k
    sal_uInt32 GetOrdNumDirect() const { return m_nOrdNum;}
831
832
    // #i25616#
833
508k
    bool DoesSupportTextIndentingOnLineWidthChange() const { return mbSupportTextIndentingOnLineWidthChange;}
834
835
    const Point& GetAnchorPos() const;
836
837
    // #i25616#
838
350
    bool LineIsOutsideGeometry() const { return mbLineIsOutsideGeometry;}
839
840
    // Set the position in the navigation position to the given value.
841
    // This method is typically used only by the model after a change to
842
    // the navigation order.
843
    // This method does not change the navigation position of other
844
    // objects.
845
    // Use SdrObjList::SetObjectNavigationPosition() instead.
846
    void SetNavigationPosition (const sal_uInt32 nPosition);
847
848
    /// Sets a new UNO representation of the shape
849
    ///
850
    /// Calling this function is only allowed for the UNO representation
851
    /// itself!
852
    ///
853
    /// The default implementation of this function sets the new UNO
854
    /// shape. Derived classes should override the function to handle
855
    /// any other actions that are needed when the shape is being
856
    /// changed.
857
    ///
858
    /// The implementation _must_ call the same method of its parent
859
    /// class (preferably as the first step)!
860
    virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& _rxUnoShape );
861
862
1.79M
    const css::uno::WeakReference< css::drawing::XShape >& getWeakUnoShape() const { return maWeakUnoShape; }
863
864
    // return true if a bg was set, false otherwise
865
    bool setSuitableOutlinerBg(Outliner& rOutliner) const;
866
    // If fillstyle is drawing::FillStyle_BITMAP, returns the graphic.
867
    const Graphic* getFillGraphic() const;
868
869
0
    const OUString& getHyperlink() const { return msHyperlink; }
870
16
    void setHyperlink(const OUString& sHyperlink) { msHyperlink = sHyperlink; }
871
872
    void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const noexcept;
873
874
protected:
875
    const tools::Rectangle& getOutRectangle() const;
876
14.5M
    bool isOutRectangleSet() const { return m_bOutRectangleSet; }
877
    void setOutRectangleConst(tools::Rectangle const& rRectangle) const; // need to do something about this
878
    void setOutRectangle(tools::Rectangle const& rRectangle);
879
    void resetOutRectangle();
880
    void moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta);
881
882
    mutable tools::Rectangle m_aOutRect;     // surrounding rectangle for Paint (incl. LineWidth, ...)
883
    mutable bool                m_bOutRectangleSet; // empty is a valid rectangle, so we need a separate flag to know when the cached value is not yet set
884
    Point                       m_aAnchor;      // anchor position (Writer)
885
    SdrObjUserCall*             m_pUserCall;
886
    std::unique_ptr<SdrObjPlusData>
887
                                m_pPlusData;    // Broadcaster, UserData, connectors, ... (this is the Bitsack)
888
    // object is only pointing to another one
889
    bool                        m_bVirtObj : 1;
890
    bool                        m_bSnapRectDirty : 1;
891
    // the following flags will be streamed
892
    bool                        m_bMovProt : 1;   // if true, the position is protected
893
    bool                        m_bSizProt : 1;   // if true, the size is protected
894
    // If bEmptyPresObj is true, it is a presentation object that has no content yet.
895
    // The flag's default value is false.
896
    // The management is done by the application.
897
    // Neither assign operator nor cloning copies the flag!
898
    // The flag is persistent.
899
    bool                        m_bEmptyPresObj : 1; // empty presentation object (Draw)
900
    // if true, object is invisible as object of the MasterPage
901
    bool                        m_bNotVisibleAsMaster : 1;
902
    // if true, the object is closed, i.e. no line, arc...
903
    bool                        m_bClosedObj : 1;
904
    bool                        m_bIsEdge : 1;
905
    bool                        m_bIs3DObj : 1;
906
    bool                        m_bIsUnoObj : 1;
907
    // #i25616#
908
    bool                        mbLineIsOutsideGeometry : 1;
909
    // #i25616#
910
    bool                        mbSupportTextIndentingOnLineWidthChange : 1;
911
    // custom prompt text for empty presentation object
912
    OUString                    m_aCustomPromptText;
913
914
    std::unique_ptr<sdr::annotation::ObjectAnnotationData> mpAnnotationData;
915
916
    virtual ~SdrObject() override;
917
918
    virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() = 0;
919
920
    virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact();
921
922
    static void ImpCommonDragCalcRect(const SdrDragStat& rDrag, tools::Rectangle& rTmpRect, const Point& rPos);
923
    tools::Rectangle ImpDragCalcRect(const SdrDragStat& rDrag) const;
924
925
    // for GetDragComment
926
    OUString ImpGetDescriptionStr(TranslateId pStrCacheID) const;
927
928
    void ImpForcePlusData();
929
930
    OUString GetMetrStr(tools::Long nVal) const;
931
932
    /// A derived class must override these 3 methods if it has own geometric
933
    /// data that must be saved for Undo.
934
    /// NewGeoData() creates an empty instance of a class derived from
935
    /// SdrObjGeoData.
936
    virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const;
937
    virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
938
    virtual void RestoreGeoData(const SdrObjGeoData& rGeo);
939
940
    // internal versions
941
    const SfxItemSet& GetObjectItemSet() const;
942
    void SetObjectItem(const SfxPoolItem& rItem);
943
    void SetObjectItemSet(const SfxItemSet& rSet);
944
    const SfxPoolItem& GetObjectItem(const sal_uInt16 nWhich) const;
945
    template<class T> const T& GetObjectItem( TypedWhichId<T> nWhich ) const
946
591k
    {
947
591k
        return static_cast<const T&>(GetObjectItem(sal_uInt16(nWhich)));
948
591k
    }
SdrEdgeKindItem const& SdrObject::GetObjectItem<SdrEdgeKindItem>(TypedWhichId<SdrEdgeKindItem>) const
Line
Count
Source
946
59.4k
    {
947
59.4k
        return static_cast<const T&>(GetObjectItem(sal_uInt16(nWhich)));
948
59.4k
    }
SdrOnOffItem const& SdrObject::GetObjectItem<SdrOnOffItem>(TypedWhichId<SdrOnOffItem>) const
Line
Count
Source
946
362k
    {
947
362k
        return static_cast<const T&>(GetObjectItem(sal_uInt16(nWhich)));
948
362k
    }
XLineStyleItem const& SdrObject::GetObjectItem<XLineStyleItem>(TypedWhichId<XLineStyleItem>) const
Line
Count
Source
946
350
    {
947
350
        return static_cast<const T&>(GetObjectItem(sal_uInt16(nWhich)));
948
350
    }
XLineWidthItem const& SdrObject::GetObjectItem<XLineWidthItem>(TypedWhichId<XLineWidthItem>) const
Line
Count
Source
946
325
    {
947
325
        return static_cast<const T&>(GetObjectItem(sal_uInt16(nWhich)));
948
325
    }
Unexecuted instantiation: XFillStyleItem const& SdrObject::GetObjectItem<XFillStyleItem>(TypedWhichId<XFillStyleItem>) const
Unexecuted instantiation: SdrGrafTransparenceItem const& SdrObject::GetObjectItem<SdrGrafTransparenceItem>(TypedWhichId<SdrGrafTransparenceItem>) const
SdrTextFitToSizeTypeItem const& SdrObject::GetObjectItem<SdrTextFitToSizeTypeItem>(TypedWhichId<SdrTextFitToSizeTypeItem>) const
Line
Count
Source
946
167k
    {
947
167k
        return static_cast<const T&>(GetObjectItem(sal_uInt16(nWhich)));
948
167k
    }
SvxWritingModeItem const& SdrObject::GetObjectItem<SvxWritingModeItem>(TypedWhichId<SvxWritingModeItem>) const
Line
Count
Source
946
1.94k
    {
947
1.94k
        return static_cast<const T&>(GetObjectItem(sal_uInt16(nWhich)));
948
1.94k
    }
949
950
    const SfxItemSet* getBackgroundFillSet() const;
951
952
    // @param bAdjustTextFrameWidthAndHeight pass false if you know it is safe to avoid the cost of doing
953
    //              text layout right now.
954
    virtual void InternalSetStyleSheet(SfxStyleSheet* pNewStyleSheet,
955
                    bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true);
956
957
private:
958
    struct Impl;
959
    std::unique_ptr<Impl>             mpImpl;
960
    SdrObjList*                       mpParentOfSdrObject;     // list that includes this object
961
    sal_uInt32                        m_nOrdNum;      // order number of the object in the list
962
    class UniqueID                          maUniqueID;
963
    std::unique_ptr<SfxGrabBagItem>   m_pGrabBagItem; // holds the GrabBagItem property
964
    // Position in the navigation order. SAL_MAX_UINT32 when not used.
965
    sal_uInt32                        mnNavigationPosition;
966
    SdrLayerID                        mnLayerID;
967
    bool                              m_bNoPrint : 1;   // if true, the object is not printed.
968
    bool                              mbVisible : 1;  // if false, the object is not visible on screen (but maybe on printer, depending on bNoprint
969
    bool                              m_bMarkProt : 1;  // marking forbidden, persistent
970
    // on import of OLE object from MS documents the BLIP size might be retrieved,
971
    // in this case the following member is initialized as nonempty rectangle
972
    tools::Rectangle                         maBLIPSizeRectangle;
973
    std::unique_ptr<sdr::properties::BaseProperties>
974
                                      mpProperties;
975
    std::unique_ptr<sdr::contact::ViewContact>
976
                                      mpViewContact;
977
978
    // do not use directly, always use getSvxShape() if you have to, because not all
979
    // SdrObjects have an associated SvxShape subclass (e.g. reportdesign)
980
    SvxShape*                   mpSvxShape;
981
    css::uno::WeakReference< css::drawing::XShape >
982
                                maWeakUnoShape;
983
984
    // HACK: Do not automatically insert newly created object into a page.
985
    // The user needs to do it manually later.
986
    bool                        mbDoNotInsertIntoPageAutomatically;
987
    // Hyperlink for the whole shape
988
    OUString msHyperlink;
989
990
    // only for internal use!
991
    SvxShape* getSvxShape();
992
993
    SdrObject( const SdrObject& ) = delete;
994
};
995
996
SVXCORE_DLLPUBLIC E3dScene* DynCastE3dScene(SdrObject*);
997
0
inline const E3dScene* DynCastE3dScene(const SdrObject* p) { return DynCastE3dScene(const_cast<SdrObject*>(p)); }
998
SVXCORE_DLLPUBLIC E3dObject* DynCastE3dObject(SdrObject*);
999
260
inline const E3dObject* DynCastE3dObject(const SdrObject* p) { return DynCastE3dObject(const_cast<SdrObject*>(p)); }
1000
SVXCORE_DLLPUBLIC SdrTextObj* DynCastSdrTextObj(SdrObject*);
1001
0
inline const SdrTextObj* DynCastSdrTextObj(const SdrObject* p) { return DynCastSdrTextObj(const_cast<SdrObject*>(p)); }
1002
SVXCORE_DLLPUBLIC SdrOle2Obj* DynCastSdrOle2Obj(SdrObject*);
1003
0
inline const SdrOle2Obj* DynCastSdrOle2Obj(const SdrObject* p) { return DynCastSdrOle2Obj(const_cast<SdrObject*>(p)); }
1004
1005
1006
struct SdrObjCreatorParams
1007
{
1008
    SdrInventor nInventor;
1009
    SdrObjKind nObjIdentifier;
1010
    SdrModel&   rSdrModel;
1011
};
1012
1013
/**
1014
 * Whoever creates his own objects must set a link in the SdrObjFactory class.
1015
 * The handler must have the following signature:
1016
 *      void Hdl(SdrObjFactory*)
1017
 * He must take a look at the referenced instance's nInventor and nIdentifier values,
1018
 * and must create a new drawing object instance accordingly.
1019
 * He must also make the pNewObj pointer reference to this instance.
1020
 */
1021
class SVXCORE_DLLPUBLIC SdrObjFactory
1022
{
1023
public:
1024
    static rtl::Reference<SdrObject> MakeNewObject(
1025
        SdrModel& rSdrModel,
1026
        SdrInventor nInventor,
1027
        SdrObjKind nObjIdentifier,
1028
        const tools::Rectangle* pSnapRect = nullptr);
1029
1030
    static void InsertMakeObjectHdl(Link<SdrObjCreatorParams, rtl::Reference<SdrObject>> const & rLink);
1031
    static void RemoveMakeObjectHdl(Link<SdrObjCreatorParams, rtl::Reference<SdrObject>> const & rLink);
1032
1033
private:
1034
    static SVX_DLLPRIVATE rtl::Reference<SdrObject> CreateObjectFromFactory(
1035
        SdrModel& rSdrModel,
1036
        SdrInventor nInventor,
1037
        SdrObjKind nIdentifier);
1038
1039
    SdrObjFactory() = delete;
1040
};
1041
1042
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */