1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_SVDOBJ_HXX
21 #define INCLUDED_SVX_SVDOBJ_HXX
24 #include <com/sun/star/uno/Any.hxx>
25 #include <cppuhelper/weakref.hxx>
26 #include <rtl/ustring.hxx>
27 #include <vcl/vclptr.hxx>
28 #include <svl/lstner.hxx>
29 #include <svl/poolitem.hxx>
30 #include <svx/svdtypes.hxx>
31 #include <svx/xenum.hxx>
32 #include <svx/svxdllapi.h>
33 #include <svx/shapeproperty.hxx>
34 #include <tools/link.hxx>
35 #include <tools/weakbase.hxx>
36 #include <tools/mapunit.hxx>
37 #include <tools/gen.hxx>
44 class OutlinerParaObject
;
61 class XFillAttrSetItem
;
62 class XLineAttrSetItem
;
64 namespace tools
{ class PolyPolygon
; }
68 class SdrObjUserDataList
;
71 class SdrGluePointList
;
98 } // end of namespace contact
103 class PropertyChangeNotifier
;
107 OBJ_NONE
= 0, /// abstract object (SdrObject)
108 OBJ_GRUP
= 1, /// object group
109 OBJ_LINE
= 2, /// line
110 OBJ_RECT
= 3, /// rectangle (round corners optional)
111 OBJ_CIRC
= 4, /// circle, ellipse
112 OBJ_SECT
= 5, /// circle section
113 OBJ_CARC
= 6, /// circle arc
114 OBJ_CCUT
= 7, /// circle cut
115 OBJ_POLY
= 8, /// polygon, PolyPolygon
116 OBJ_PLIN
= 9, /// PolyLine
117 OBJ_PATHLINE
=10, /// open Bezier-curve
118 OBJ_PATHFILL
=11, /// closed Bezier-curve
119 OBJ_FREELINE
=12, /// open free-hand line
120 OBJ_FREEFILL
=13, /// closed free-hand line
121 OBJ_SPLNLINE
=14, /// natural cubic Spline (ni)
122 OBJ_SPLNFILL
=15, /// periodic cubic Spline (ni)
123 OBJ_TEXT
=16, /// text object
124 OBJ_TEXTEXT
=17, /// text extension frame (ni)
125 OBJ_TITLETEXT
=20, /// TitleText, special text object for StarDraw
126 OBJ_OUTLINETEXT
=21, /// OutlineText, special text object for StarDraw
127 OBJ_GRAF
=22, /// foreign graphic (StarView Graphic)
128 OBJ_OLE2
=23, /// OLE object
129 OBJ_EDGE
=24, /// connector object
130 OBJ_CAPTION
=25, /// caption object
131 OBJ_PATHPOLY
=26, /// Polygon/PolyPolygon represented by SdrPathObj
132 OBJ_PATHPLIN
=27, /// Polyline represented by SdrPathObj
133 OBJ_PAGE
=28, /// object that represents a SdrPage
134 OBJ_MEASURE
=29, /// measurement object
135 OBJ_FRAME
=31, /// continuously activated OLE (PlugIn-Frame or similar)
136 OBJ_UNO
=32, /// Universal Network Object packed into SvDraw object
137 OBJ_CUSTOMSHAPE
=33, /// custom shape
138 OBJ_MEDIA
=34, /// media shape
139 OBJ_TABLE
=35, /// table
143 enum class SdrInventor
: sal_uInt32
{
145 BasicDialog
= sal_uInt32( 'D' | ('L' << 8) | ('G' << 16) | ('1' << 24) ),
146 Default
= sal_uInt32( 'S' | ('V' << 8) | ('D' << 16) | ('r' << 24) ),
147 E3d
= sal_uInt32( 'E' | ('3' << 8) | ('D' << 16) | ('1' << 24) ),
148 FmForm
= sal_uInt32( 'F' | ('M' << 8) | ('0' << 16) | ('1' << 24) ),
149 IMap
= sal_uInt32( 'I' | ('M' << 8) | ('A' << 16) | ('P' << 24) ),
150 ReportDesign
= sal_uInt32( 'R' | ('P' << 8) | ('T' << 16) | ('1' << 24) ),
151 ScOrSwDraw
= sal_uInt32( 'S' | ('C' << 8) | ('3' << 16) | ('0' << 24) ), // Used in sc/ and sw/
152 SgaImap
= sal_uInt32( 'S' | ('D' << 8) | ('U' << 16) | ('D' << 24) ),
153 StarDrawUserData
= sal_uInt32( 'S' | ('D' << 8) | ('U' << 16) | ('D' << 24) ),
154 Swg
= sal_uInt32( 'S' | ('W' << 8) | ('G' << 16) ),
157 enum class SdrUserCallType
{
158 MoveOnly
, // only moved, size unchanged
159 Resize
, // size and maybe position changed
160 ChangeAttr
, // attribute changed. Eventually new size, because of line width
161 Delete
, // object is going to be deleted soon, no attributes anymore
162 Inserted
, // inserted into an object list (e.g. Page)
163 Removed
, // removed from an object list
164 ChildMoveOnly
, // a child within a group has changed
165 ChildResize
, // a child within a group has changed
166 ChildChangeAttr
, // a child within a group has changed
167 ChildDelete
, // a child within a group has changed
168 ChildInserted
, // a child within a group has changed
169 ChildRemoved
// a child within a group has changed
172 class SVX_DLLPUBLIC SdrObjUserCall
175 virtual ~SdrObjUserCall();
176 virtual void Changed(const SdrObject
& rObj
, SdrUserCallType eType
, const tools::Rectangle
& rOldBoundRect
);
179 class SVX_DLLPUBLIC SdrObjMacroHitRec
184 VclPtr
<OutputDevice
> pOut
;
185 const SdrLayerIDSet
* pVisiLayer
;
186 const SdrPageView
* pPageView
;
194 * User data of a drawing object, e.g. application specific data.
195 * Every drawing object can have an arbitrary amount of such records (SV list).
196 * Whoever wants to save data here, must inherit from this and set a corresponding link in the factory.
198 class SVX_DLLPUBLIC SdrObjUserData
201 SdrInventor nInventor
;
202 sal_uInt16 nIdentifier
;
205 void operator=(const SdrObjUserData
& rData
) = delete;
206 bool operator==(const SdrObjUserData
& rData
) const = delete;
207 bool operator!=(const SdrObjUserData
& rData
) const = delete;
210 SdrObjUserData(SdrInventor nInv
, sal_uInt16 nId
);
211 SdrObjUserData(const SdrObjUserData
& rData
);
212 virtual ~SdrObjUserData();
214 virtual SdrObjUserData
* Clone(SdrObject
* pObj1
) const = 0; // #i71039# NULL -> 0
215 SdrInventor
GetInventor() const { return nInventor
;}
216 sal_uInt16
GetId() const { return nIdentifier
;}
220 * All geometrical data of an arbitrary object for use in undo/redo
222 class SVX_DLLPUBLIC SdrObjGeoData
225 tools::Rectangle aBoundRect
;
227 std::unique_ptr
<SdrGluePointList
>
234 SdrLayerID mnLayerID
;
238 virtual ~SdrObjGeoData();
242 * Provides information about various ZObject properties
244 class SVX_DLLPUBLIC SdrObjTransformInfoRec
247 bool bSelectAllowed
: 1; // if false, object cannot be selected
248 bool bMoveAllowed
: 1; // if false, object cannot be moved
249 bool bResizeFreeAllowed
: 1; // if false, object cannot be resized freely
250 bool bResizePropAllowed
: 1; // if false, object cannot even be resized proportionally
251 bool bRotateFreeAllowed
: 1; // if false, object cannot be rotated freely
252 bool bRotate90Allowed
: 1; // if false, object cannot even be rotated in 90 degree steps
253 bool bMirrorFreeAllowed
: 1; // if false, object cannot be mirrored freely
254 bool bMirror45Allowed
: 1; // if false, object cannot even be mirrored over axes in a 45 degree raster
255 bool bMirror90Allowed
: 1; // if false, object cannot even be mirrored over axes in a 90 degree raster
256 bool bTransparenceAllowed
: 1; // if false, object does not have an interactive transparence control
257 bool bGradientAllowed
: 1; // if false, object does not have an interactive gradient control
258 bool bShearAllowed
: 1; // if false, object cannot be sheared
259 bool bEdgeRadiusAllowed
: 1;
260 bool bNoOrthoDesired
: 1; // is true for Rect; is false for BMP, MTF
261 bool bNoContortion
: 1; // if false, contortion not possible (for crook, only true for PathObj and grouped PathObjs)
262 bool bCanConvToPath
: 1; // if false, no conversion into PathObj possible
263 bool bCanConvToPoly
: 1; // if false, no conversion into PolyObj possible
264 bool bCanConvToContour
: 1; // if false, no conversion down to whole contour possible
265 bool bCanConvToPathLineToArea
: 1; // if false, no conversion into PathObj with transformation from LineToArea possible
266 bool bCanConvToPolyLineToArea
: 1; // if false, no conversion into PolyObj with transformation from LineToArea possible
268 SdrObjTransformInfoRec();
271 /// Abstract DrawObject
274 class SVX_DLLPUBLIC SdrObject
: public SfxListener
, public tools::WeakBase
< SdrObject
>
276 friend class SdrObjListIter
;
277 friend class SdrVirtObj
;
278 friend class SdrRectObj
;
279 friend class SdrDelayBroadcastObjectChange
;
284 void AddObjectUser(sdr::ObjectUser
& rNewUser
);
285 void RemoveObjectUser(sdr::ObjectUser
& rOldUser
);
287 sdr::contact::ViewContact
& GetViewContact() const;
289 virtual sdr::properties::BaseProperties
& GetProperties() const;
291 // DrawContact support: Methods for handling Object changes
292 void ActionChanged() const;
294 static SdrItemPool
& GetGlobalDrawObjectItemPool();
295 void SetRelativeWidth( double nValue
);
296 void SetRelativeWidthRelation( sal_Int16 eValue
);
297 void SetRelativeHeight( double nValue
);
298 void SetRelativeHeightRelation( sal_Int16 eValue
);
299 const double* GetRelativeWidth() const;
300 sal_Int16
GetRelativeWidthRelation() const;
301 const double* GetRelativeHeight() const;
302 sal_Int16
GetRelativeHeightRelation() const;
303 // evil calc grid/shape drawlayer syncing
304 const Point
& GetGridOffset() const { return aGridOffset
; }
305 void SetGridOffset( const Point
& rGridOffset
){ aGridOffset
= rGridOffset
; }
307 /// @param bNotMyself = true: set only ObjList to dirty, don't mark this object as dirty.
309 /// This is needed for instance for NbcMove, because usually one moves SnapRect and aOutRect
310 /// at the same time to avoid recomputation.
311 virtual void SetRectsDirty(bool bNotMyself
= false);
313 // frees the SdrObject pointed to by the argument
314 // In case the object has an SvxShape, which has the ownership of the object, it
315 // is actually *not* deleted.
316 static void Free( SdrObject
*& _rpObject
);
318 // this method is only for access from Property objects
319 virtual void SetBoundRectDirty();
321 virtual void SetObjList(SdrObjList
* pNewObjList
);
322 SdrObjList
* GetObjList() const { return pObjList
;}
324 virtual void SetPage(SdrPage
* pNewPage
);
325 SdrPage
* GetPage() const { return pPage
;}
327 virtual void SetModel(SdrModel
* pNewModel
);
328 SdrModel
* GetModel() const { return pModel
;}
329 SfxItemPool
& GetObjectItemPool() const;
331 void AddListener(SfxListener
& rListener
);
332 void RemoveListener(SfxListener
& rListener
);
334 void AddReference(SdrVirtObj
& rVrtObj
);
335 void DelReference(SdrVirtObj
& rVrtObj
);
336 virtual SdrInventor
GetObjInventor() const;
337 virtual sal_uInt16
GetObjIdentifier() const;
338 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const;
341 virtual SdrLayerID
GetLayer() const;
342 virtual void NbcSetLayer(SdrLayerID nLayer
);
343 virtual void SetLayer(SdrLayerID nLayer
);
344 // renaming GetSdrLayerIDSet -> getMergedHierarchySdrLayerIDSet to make clear what happens here. rSet needs to be empty.
345 void getMergedHierarchySdrLayerIDSet(SdrLayerIDSet
& rSet
) const;
347 void SendUserCall(SdrUserCallType eUserCall
, const tools::Rectangle
& rBoundRect
) const;
350 // An object may have a user-set Name (Get/SetName()), e.g SdrGrafObj, SdrObjGroup
352 // It may also have a Title and a Description for accessibility purposes.
353 void SetName(const OUString
& rStr
);
354 OUString
GetName() const;
355 void SetTitle(const OUString
& rStr
);
356 OUString
GetTitle() const;
357 void SetDescription(const OUString
& rStr
);
358 OUString
GetDescription() const;
361 bool IsGroupObject() const;
362 virtual SdrObjList
* GetSubList() const;
363 SdrObject
* GetUpGroup() const;
365 /// The order number (aka ZOrder, aka z-index) determines whether a
366 /// SdrObject is located above or below another. Objects are painted from
367 /// lowest to highest order number. If the order of SdrObjects in the
368 /// SdrObjList is changed, the bObjOrdNumsDirty flag is set on the SdrPage
369 /// and the next GetOrdNum() call recalculates the order number of all
370 /// SdrObjects in the SdrObjList.
371 sal_uInt32
GetOrdNum() const;
373 // setting the order number should only happen from the model or from the page
374 void SetOrdNum(sal_uInt32 nNum
);
376 // GrabBagItem for interim interop purposes
377 void GetGrabBagItem(css::uno::Any
& rVal
) const;
379 void SetGrabBagItem(const css::uno::Any
& rVal
);
381 // Return the position in the navigation order for the called object.
382 // Note that this method may update the navigation position of the
383 // called and of other SdrObjects. Therefore this method can not be
386 // If no navigation position has been explicitly defined then the
387 // result of GetOrdNum() is returned.
388 sal_uInt32
GetNavigationPosition();
390 // To make clearer that this method may trigger RecalcBoundRect and thus may be
391 // expensive and sometimes problematic (inside a bigger object change You will get
392 // non-useful BoundRects sometimes) i rename that method from GetBoundRect() to
393 // GetCurrentBoundRect().
394 virtual const tools::Rectangle
& GetCurrentBoundRect() const;
396 // To have a possibility to get the last calculated BoundRect e.g for producing
397 // the first rectangle for repaints (old and new need to be used) without forcing
398 // a RecalcBoundRect (which may be problematical and expensive sometimes) i add here
399 // a new method for accessing the last BoundRect.
400 virtual const tools::Rectangle
& GetLastBoundRect() const;
402 virtual void RecalcBoundRect();
404 void BroadcastObjectChange() const;
406 const SfxBroadcaster
* GetBroadcaster() const;
408 // set modified-flag in the model
409 virtual void SetChanged();
411 // Tooling for painting a single object to a OutputDevice. This will be needed as long
412 // as not all painting is changed to use DrawContact objects.
413 void SingleObjectPainter(OutputDevice
& rOut
) const;
414 bool LineGeometryUsageIsNecessary() const;
416 // Returns a copy of the object. Every inherited class must reimplement this (in class Foo
417 // it should be sufficient to do "virtual Foo* Clone() const { return CloneHelper< Foo >(); }".
418 // Note that this function uses operator= internally.
419 virtual SdrObject
* Clone() const;
421 // implemented mainly for the purposes of Clone()
422 SdrObject
& operator=(const SdrObject
& rObj
);
424 // TakeObjName...() is for the display in the UI, e.g. "3 frames selected"
425 virtual OUString
TakeObjNameSingul() const;
426 virtual OUString
TakeObjNamePlural() const;
428 /// The Xor-Polygon is required by the View to drag the object.
429 /// All polygons within the PolyPolygon are interpreted as PolyLine.
430 /// To get a closed Polygon, close it explicitly.
431 virtual basegfx::B2DPolyPolygon
TakeXorPoly() const;
433 /// contour for TextToContour
434 virtual basegfx::B2DPolyPolygon
TakeContour() const;
436 /// Via GetHdlCount the number of Handles can be retrieved.
437 /// Normally 8, if it's a line 2.
438 /// For Polygon objects (Polygon/Spline/Bezier) the number may be much
439 /// larger. Polygon objects are also allowed to select a point of a
440 /// selected object. The handle of that point will then be replaced by
441 /// a new set of handles (PlusHdl). For a Polygon this would be a simple
442 /// selection Handle, for a Bezier curve this may be up to 3 Handles
443 /// (including Weights).
444 /// GetHdl() and GetPlusHdl() must create Handle instances with new!
445 /// An object that returns true from HasSpacialDrag() must provide these
446 /// methods (incl. FillHdlList()).
447 virtual sal_uInt32
GetHdlCount() const;
448 virtual SdrHdl
* GetHdl(sal_uInt32 nHdlNum
) const;
449 virtual sal_uInt32
GetPlusHdlCount(const SdrHdl
& rHdl
) const;
450 virtual SdrHdl
* GetPlusHdl(const SdrHdl
& rHdl
, sal_uInt32 nPlNum
) const;
451 virtual void AddToHdlList(SdrHdlList
& rHdlList
) const;
452 virtual void addCropHandles(SdrHdlList
& rTarget
) const;
454 /// The standard transformations (Move,Resize,Rotate,Mirror,Shear) are
455 /// taken over by the View (TakeXorPoly(),...).
456 /// Object type specific dragging like corner radius of Rectangle,
457 /// control points of Splines, weights of Bezier curves, pointer of
458 /// Label objects must be handled by the object itself.
459 /// To keep the Model free of state, the state is kept in the View
460 /// and then passed to the object. EndDrag usually returns true for success,
461 /// false may be returned if the dragging did not modify the object,
462 /// where the View already handles the case that the pointer was not
464 virtual bool hasSpecialDrag() const;
465 virtual bool beginSpecialDrag(SdrDragStat
& rDrag
) const;
466 virtual bool applySpecialDrag(SdrDragStat
& rDrag
);
467 virtual OUString
getSpecialDragComment(const SdrDragStat
& rDrag
) const;
468 virtual basegfx::B2DPolyPolygon
getSpecialDragPoly(const SdrDragStat
& rDrag
) const;
470 // FullDrag support. This is for standard interactions and for SdrObjOwn
471 // support. If supportsFullDrag() returns true, getFullDragClone has to
472 // return a cloned SdrObject (who's ownership it loses) at which modifications
473 // like Move(), Scale(), etc or applySpecialDrag() will be executed. That
474 // object will be visualized on overlay for full drag, but should not be
475 // part of the model, thus not changing anything since it's only a temporary
476 // helper object for interaction
477 virtual bool supportsFullDrag() const;
478 virtual SdrObject
* getFullDragClone() const;
480 /// Every object must be able to create itself interactively.
481 /// On MouseDown first an object is created, and its BegCreate() method
482 /// is called. On every MouseMove, MovCreate() is called. BrkCreate()
483 /// is called if the user cancels the interactive object creation.
484 /// EndCreate() is called on the MouseUp event. If EndCreate() returns
485 /// true, the creation is finished; the object is inserted into the
486 /// corresponding list. Otherwise it is assumed that further points
487 /// are necessary to create the object (Polygon, ...). The parameter
488 /// eCmd contains the number of mouse clicks (if the application
490 /// BckCreate() will undo the previous EndCreate(), e.g. to delete the
491 /// last point of the Polygon. If BckCreate() returns false, creation
493 virtual bool BegCreate(SdrDragStat
& rStat
);
494 virtual bool MovCreate(SdrDragStat
& rStat
); // if true, Xor needs to be repainted
495 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
);
496 virtual bool BckCreate(SdrDragStat
& rStat
);
497 virtual void BrkCreate(SdrDragStat
& rStat
);
499 /// get the cursor/pointer that signals creating this object
500 virtual Pointer
GetCreatePointer() const;
502 /// Polygon dragged by the user when creating the object
503 virtual basegfx::B2DPolyPolygon
TakeCreatePoly(const SdrDragStat
& rDrag
) const;
505 /// The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and
506 /// SetLogicRect call the corresponding Nbc-methods, send a Repaint
507 /// broadcast and set the Modified state on the Model.
508 /// Derived classes should usually only override the Nbc methods.
509 /// Nbc means "no broadcast".
510 virtual void NbcMove (const Size
& rSiz
);
511 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
512 virtual void NbcCrop (const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
513 virtual void NbcRotate(const Point
& rRef
, long nAngle
, double sn
, double cs
);
514 virtual void NbcMirror(const Point
& rRef1
, const Point
& rRef2
);
515 virtual void NbcShear (const Point
& rRef
, long nAngle
, double tn
, bool bVShear
);
517 virtual void Move (const Size
& rSiz
);
518 virtual void Resize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
, bool bUnsetRelative
= true);
519 virtual void Crop (const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
520 virtual void Rotate(const Point
& rRef
, long nAngle
, double sn
, double cs
);
521 virtual void Mirror(const Point
& rRef1
, const Point
& rRef2
);
522 virtual void Shear (const Point
& rRef
, long nAngle
, double tn
, bool bVShear
);
524 /// The relative position of a SdrObject is the distance of the upper
525 /// left corner of the logic bounding rectangle (SnapRect) to the anchor.
526 virtual void NbcSetRelativePos(const Point
& rPnt
);
527 virtual void SetRelativePos(const Point
& rPnt
);
528 virtual Point
GetRelativePos() const;
529 void ImpSetAnchorPos(const Point
& rPnt
);
530 virtual void NbcSetAnchorPos(const Point
& rPnt
);
531 virtual void SetAnchorPos(const Point
& rPnt
);
533 /// Snap is not done on the BoundRect but if possible on logic coordinates
534 /// (i.e. without considering stroke width, ...)
535 /// SetSnapRect() tries to size the Object so that it fits into the
536 /// passed Rect (without stroke width, ...)
537 virtual void RecalcSnapRect();
538 virtual const tools::Rectangle
& GetSnapRect() const;
539 virtual void SetSnapRect(const tools::Rectangle
& rRect
);
540 virtual void NbcSetSnapRect(const tools::Rectangle
& rRect
);
542 // Logic Rect: for the Rect for instance without regard to rotation angle, shear, ...
543 virtual const tools::Rectangle
& GetLogicRect() const;
544 virtual void SetLogicRect(const tools::Rectangle
& rRect
);
545 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
);
547 // the default is to set the logic rect to the given rectangle rMaxRect. If the shape
548 // has an intrinsic aspect ratio it may set the logic rect so the aspect
549 // ratio is kept but still inside the rectangle rMaxRect.
550 // If bShrinkOnly is set to true, the size of the current logic rect will not
551 // be changed if it is smaller than the given rectangle rMaxRect.
552 virtual void AdjustToMaxRect( const tools::Rectangle
& rMaxRect
, bool bShrinkOnly
= false );
554 // rotation and shear angle
555 virtual long GetRotateAngle() const;
556 virtual long GetShearAngle(bool bVertical
= false) const;
558 /// snap to special points of an Object (polygon points, center of circle)
559 virtual sal_uInt32
GetSnapPointCount() const;
560 virtual Point
GetSnapPoint(sal_uInt32 i
) const;
562 // For objects, whose points can be moved individually.
563 // (e.g. polygons, polylines, lines)
564 // The points of those objects are selected (if necessary multiselection),
565 // deleted, inserted, or as a multiselection moved or rotated...
566 // Only such objects can have PlusHandles (e.g. the weights of an Bezier curve).
567 virtual bool IsPolyObj() const;
568 virtual sal_uInt32
GetPointCount() const;
569 virtual Point
GetPoint(sal_uInt32 i
) const;
570 void SetPoint(const Point
& rPnt
, sal_uInt32 i
);
571 virtual void NbcSetPoint(const Point
& rPnt
, sal_uInt32 i
);
573 // get all geometrical data for undo/redo
574 virtual SdrObjGeoData
* GetGeoData() const;
575 virtual void SetGeoData(const SdrObjGeoData
& rGeo
);
578 const SfxItemSet
& GetMergedItemSet() const;
579 void SetMergedItem(const SfxPoolItem
& rItem
);
580 void ClearMergedItem(const sal_uInt16 nWhich
= 0);
581 void SetMergedItemSet(const SfxItemSet
& rSet
, bool bClearAllItems
= false);
582 const SfxPoolItem
& GetMergedItem(const sal_uInt16 nWhich
) const;
584 // syntactical sugar for ItemSet accesses
585 void SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, bool bClearAllItems
= false);
587 // NotPersistAttr for Layer, ObjName, geometrical transformations etc.
588 void TakeNotPersistAttr(SfxItemSet
& rAttr
) const;
589 void ApplyNotPersistAttr(const SfxItemSet
& rAttr
);
590 void NbcApplyNotPersistAttr(const SfxItemSet
& rAttr
);
592 // if bDontRemoveHardAttr is false, set all attributes, which were set in the style sheet, to their default value
593 // if true, all hard attributes keep their values
594 void SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, bool bDontRemoveHardAttr
);
595 virtual void NbcSetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, bool bDontRemoveHardAttr
);
596 SfxStyleSheet
* GetStyleSheet() const;
598 virtual bool HasTextEdit() const;
600 // returns true if TextEditMode started
601 virtual bool BegTextEdit(SdrOutliner
& rOutl
);
602 virtual void EndTextEdit(SdrOutliner
& rOutl
);
604 // keep text in outliner's format
605 // SetOutlinerParaObject: transfer ownership of *pTextObject!
606 void SetOutlinerParaObject(OutlinerParaObject
* pTextObject
);
607 virtual void NbcSetOutlinerParaObject(OutlinerParaObject
* pTextObject
);
608 virtual OutlinerParaObject
* GetOutlinerParaObject() const;
609 virtual void NbcReformatText();
610 virtual void ReformatText();
612 void BurnInStyleSheetAttributes();
614 // macro abilities, e.g. a rectangle as PushButton.
615 virtual bool HasMacro() const;
616 virtual SdrObject
* CheckMacroHit (const SdrObjMacroHitRec
& rRec
) const;
617 virtual Pointer
GetMacroPointer (const SdrObjMacroHitRec
& rRec
) const;
618 virtual void PaintMacro (OutputDevice
& rOut
, const tools::Rectangle
& rDirtyRect
, const SdrObjMacroHitRec
& rRec
) const;
619 virtual bool DoMacro (const SdrObjMacroHitRec
& rRec
);
620 virtual OUString
GetMacroPopupComment(const SdrObjMacroHitRec
& rRec
) const;
621 bool IsMacroHit(const SdrObjMacroHitRec
& rRec
) const;
624 // (see also documentation in SvdoEdge.hxx, SdrEdgeObj, as well as SvdGlue.hxx and SvdGlEV.hxx)
626 // There are nodes and edges. In theory an edge can also be a node, but this isn't implemented yet.
627 // A node has a number of glue points, onto which edges can glued to
628 // An edge can be either
629 // - without any connection to any node,
630 // - or connected on one end to a node, while the other end is not connected,
631 // - or connected on both ends with exactly one node each.
632 // The edge is listener for its up to two nodes.
633 // Whenever a node is moved or resized, all its connected edges follow.
634 // This is also true for SetGluePoint()... on the node.
635 // On the other hand, moving/resizing an edge breaks the connection.
638 virtual bool IsNode() const;
640 // automatic glue points:
641 // a node object must provide four vertex and corner positions
642 // usually 0: top, 1: right, 2: bottom, 3: left
643 virtual SdrGluePoint
GetVertexGluePoint(sal_uInt16 nNum
) const;
646 // 0: top-left, 1: top-right, 2: bottom-right, 3: bottom-left
647 virtual SdrGluePoint
GetCornerGluePoint(sal_uInt16 nNum
) const;
649 // list of all glue points, can be NULL
650 virtual const SdrGluePointList
* GetGluePointList() const;
652 // after changing the GluePointList, one has to call the object's SendRepaintBroadcast!
653 virtual SdrGluePointList
* ForceGluePointList();
655 // to be set temporarily when transforming related object(?)
656 void SetGlueReallyAbsolute(bool bOn
);
657 void NbcRotateGluePoints(const Point
& rRef
, long nAngle
, double sn
, double cs
);
658 void NbcMirrorGluePoints(const Point
& rRef1
, const Point
& rRef2
);
659 void NbcShearGluePoints (const Point
& rRef
, double tn
, bool bVShear
);
661 // if bTail1 is true, line start, otherwise line end
662 // if pObj is null disconnect
663 virtual void ConnectToNode(bool bTail1
, SdrObject
* pObj
);
664 virtual void DisconnectFromNode(bool bTail1
);
665 virtual SdrObject
* GetConnectedNode(bool bTail1
) const;
667 // sets the writing mode of the object's context
668 // Objects which itself do not support different writing modes will ignore this call.
669 // Objects which support different writing modes, but have an own, explicit writing mode set,
670 // will also ignore this call.
671 // Objects which support different writing modes, and whose own mode is set to css.text.WritingMode2.CONTEXT,
672 // will use the given writing mode to calculate their "effective writing mode".
673 // The behaviour of this method is undefined if you pass css.text.WritingMode2.CONTEXT.
674 // @param _nContextWritingMode
675 // the effective writing mode of the context of the object
676 virtual void SetContextWritingMode( const sal_Int16 _nContextWritingMode
);
678 // If an object is able to convert itself into a polygon or into a Bezier curve (or into both),
679 // then the following methods should be overridden.
680 // E.g., convert a RectObj with line width 10, SOLID_PEN into a polygon:
681 // In the bLineToArea=false mode a PolyObj with four supporting points,
682 // line width 10 and SOLID_PEN shall be created.
683 // On the contrary in the bLineToArea=true mode the generated object should
684 // still have a line attribute NULL_PEN, and the line (also line pattern)
685 // itself should be emulated by the polygon area, which thereby can be
686 // manipulated by the user afterwards.
687 // The RectObj therefore can only convert correctly if it has an area attribute NULL_BRUSH.
688 // In this case it would have to:
689 // - set SOLID_BRUSH with the color of the given pen,
690 // - set NULL_PEN, and
691 // - generate tools::PolyPolygon with two polygons with four supporting points each.
692 // In each case the return value is a SdrObject*, because it is also
693 // allowed to return group objects (e.g. for SdrTextObj).
694 // In the case of the conversion from TextObj to PathObj,
695 // both modi (bLineToArea=true/false) would be identical.
696 // The methods' default implementations report "I'm unable to do this" (false/null).
697 virtual SdrObject
* DoConvertToPolyObj(bool bBezier
, bool bAddText
) const;
698 SdrObject
* ConvertToPolyObj(bool bBezier
, bool bLineToArea
) const;
700 // convert this path object to contour object; bForceLineDash converts even
701 // when there is no filled new polygon created from line-to-polygon conversion,
702 // specially used for XLINE_DASH and 3D conversion
703 SdrObject
* ConvertToContourObj(SdrObject
* pRet
, bool bForceLineDash
= false) const;
704 static SdrObject
* ImpConvertToContourObj(SdrObject
* pRet
, bool bForceLineDash
);
706 // if true, reference onto an object
707 bool IsVirtualObj() const { return bVirtObj
;}
709 // is true, if object can probably be filled
710 // is false, if object has probably line ends
711 // is invalid, if this is a group object
712 bool IsClosedObj() const { return bClosedObj
;}
714 bool IsEdgeObj() const { return bIsEdge
;}
715 bool Is3DObj() const { return bIs3DObj
;}
716 bool IsUnoObj() const { return bIsUnoObj
;}
717 void SetInserted(bool bIns
);
718 bool IsInserted() const { return bInserted
;}
719 void SetMoveProtect(bool bProt
);
720 bool IsMoveProtect() const { return bMovProt
;}
721 void SetResizeProtect(bool bProt
);
722 bool IsResizeProtect() const { return bSizProt
;}
723 void SetPrintable(bool bPrn
);
724 bool IsPrintable() const { return !bNoPrint
;}
725 void SetVisible(bool bVisible
);
726 bool IsVisible() const { return mbVisible
;}
727 void SetMarkProtect(bool bProt
);
728 bool IsMarkProtect() const { return bMarkProt
;}
730 // application specific data
731 sal_uInt16
GetUserDataCount() const;
732 SdrObjUserData
* GetUserData(sal_uInt16 nNum
) const;
734 void AppendUserData(SdrObjUserData
* pData
);
736 // removes the record from the list and performs delete (FreeMem+Dtor).
737 void DeleteUserData(sal_uInt16 nNum
);
739 // switch ItemPool for this object
740 void MigrateItemPool(SfxItemPool
* pSrcPool
, SfxItemPool
* pDestPool
, SdrModel
* pNewModel
);
742 // access to the UNO representation of the shape
743 virtual css::uno::Reference
< css::uno::XInterface
> getUnoShape();
745 static SdrObject
* getSdrObjectFromXShape( const css::uno::Reference
< css::uno::XInterface
>& xInt
);
747 // retrieves the instance responsible for notifying changes in the properties of the shape associated with
751 // There already exists an SvxShape instance associated with the SdrObject
752 // @throws css::uno::RuntimeException
753 // if there does nt yet exists an SvxShape instance associated with the SdrObject.
754 svx::PropertyChangeNotifier
& getShapePropertyChangeNotifier();
756 // notifies a change in the given property, to all applicable listeners registered at the associated SvxShape
758 // This method is equivalent to calling getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty ),
759 // exception that it is allowed to be called when there does not yet exist an associated SvxShape - in which
760 // case the method will silently return without doing anything.
761 void notifyShapePropertyChange( const svx::ShapeProperty _eProperty
) const;
763 // transformation interface for StarOfficeAPI. This implements support for
764 // homogen 3x3 matrices containing the transformation of the SdrObject. At the
765 // moment it contains a shearX, rotation and translation, but for setting all linear
766 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
768 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
769 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
770 virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix
& rMatrix
, basegfx::B2DPolyPolygon
& rPolyPolygon
) const;
772 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
773 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
774 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
775 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix
& rMatrix
, const basegfx::B2DPolyPolygon
& rPolyPolygon
);
777 // give info if object is in destruction
778 bool IsInDestruction() const;
780 // return if fill is != XFILL_NONE
781 bool HasFillStyle() const;
782 bool HasLineStyle() const;
784 // on import of OLE object from MS documents the BLIP size might be retrieved,
785 // the following methods are used to control it;
786 // usually this data makes no sense after the import is finished, since the object
788 const tools::Rectangle
& GetBLIPSizeRectangle() const { return maBLIPSizeRectangle
;}
789 void SetBLIPSizeRectangle( const tools::Rectangle
& aRect
);
792 virtual bool HasText() const;
794 OString
stringify() const;
796 virtual void dumpAsXml(struct _xmlTextWriter
* pWriter
) const;
798 void SetEmptyPresObj(bool bEpt
);
799 bool IsEmptyPresObj() const { return bEmptyPresObj
;}
800 void SetNotVisibleAsMaster(bool bFlg
);
801 bool IsNotVisibleAsMaster() const { return bNotVisibleAsMaster
;}
802 void SetUserCall(SdrObjUserCall
* pUser
);
803 SdrObjUserCall
* GetUserCall() const { return pUserCall
;}
804 /// @see mbDoNotInsertIntoPageAutomatically
805 void SetDoNotInsertIntoPageAutomatically(bool bSet
);
806 /// @see mbDoNotInsertIntoPageAutomatically
807 bool IsDoNotInsertIntoPageAutomatically() const { return mbDoNotInsertIntoPageAutomatically
;}
809 // Warning: this method should only be used if you really know what you're doing
810 sal_uInt32
GetOrdNumDirect() const { return nOrdNum
;}
813 bool DoesSupportTextIndentingOnLineWidthChange() const { return mbSupportTextIndentingOnLineWidthChange
;}
815 const Point
& GetAnchorPos() const;
818 bool LineIsOutsideGeometry() const { return mbLineIsOutsideGeometry
;}
820 // Set the position in the navigation position to the given value.
821 // This method is typically used only by the model after a change to
822 // the navigation order.
823 // This method does not change the navigation position of other
825 // Use SdrObjList::SetObjectNavigationPosition() instead.
826 void SetNavigationPosition (const sal_uInt32 nPosition
);
828 // sets a new UNO representation of the shape
829 // This is only a public interface function. The actual work is
830 // done by impl_setUnoShape().
831 // Calling this function is only allowed for the UNO representation
833 void setUnoShape( const css::uno::Reference
<css::uno::XInterface
>& _rxUnoShape
);
835 const css::uno::WeakReference
< css::uno::XInterface
>& getWeakUnoShape() const { return maWeakUnoShape
; }
838 tools::Rectangle aOutRect
; // surrounding rectangle for Paint (incl. LineWdt, ...)
839 Point aAnchor
; // anchor position (Writer)
842 SdrObjUserCall
* pUserCall
;
843 SdrObjPlusData
* pPlusData
; // Broadcaster, UserData, connectors, ... (this is the Bitsack)
844 // object is only pointing to another one
846 bool bSnapRectDirty
: 1;
847 // the following flags will be streamed
848 bool bMovProt
: 1; // if true, the position is protected
849 bool bSizProt
: 1; // if true, the size is protected
850 // If bEmptyPresObj is true, it is a presentation object that has no content yet.
851 // The flag's default value is false.
852 // The management is done by the application.
853 // Neither assign operator nor cloning copies the flag!
854 // The flag is persistent.
855 bool bEmptyPresObj
: 1; // empty presentation object (Draw)
856 // if true, object is invisible as object of the MasterPage
857 bool bNotVisibleAsMaster
: 1;
858 // if true, the object is closed, i.e. no line, arc...
863 bool bNotMasterCachable
: 1;
865 bool mbLineIsOutsideGeometry
: 1;
867 bool mbSupportTextIndentingOnLineWidthChange
: 1;
869 virtual ~SdrObject() override
;
871 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties();
873 virtual sdr::contact::ViewContact
* CreateObjectSpecificViewContact();
875 tools::Rectangle
ImpDragCalcRect(const SdrDragStat
& rDrag
) const;
877 // for GetDragComment
878 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID
, OUString
& rStr
) const;
880 void ImpForcePlusData();
882 OUString
GetAngleStr(long nAngle
) const;
883 OUString
GetMetrStr(long nVal
) const;
885 /// A derived class must override these 3 methods if it has own geometric
886 /// data that must be saved for Undo.
887 /// NewGeoData() creates an empty instance of a class derived from
889 virtual SdrObjGeoData
* NewGeoData() const;
890 virtual void SaveGeoData(SdrObjGeoData
& rGeo
) const;
891 virtual void RestGeoData(const SdrObjGeoData
& rGeo
);
894 const SfxItemSet
& GetObjectItemSet() const;
895 void SetObjectItem(const SfxPoolItem
& rItem
);
896 void SetObjectItemSet(const SfxItemSet
& rSet
);
897 const SfxPoolItem
& GetObjectItem(const sal_uInt16 nWhich
) const;
899 // get MapUnit the object is using
900 MapUnit
GetObjectMapUnit() const;
902 /// Sets a new UNO shape
904 /// The default implementation of this function sets the new UNO
905 /// shape. Derived classes should override the function to handle
906 /// any other actions that are needed when the shape is being
909 /// The implementation _must_ call the same method of its parent
910 /// class (preferably as the first step)!
911 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& _rxUnoShape
);
913 // helper function for reimplementing Clone().
914 template< typename T
> T
* CloneHelper() const;
918 std::unique_ptr
<Impl
> mpImpl
;
919 Point aGridOffset
; // hack (Calc)
920 SdrObjList
* pObjList
; // list that includes this object
921 sal_uInt32 nOrdNum
; // order number of the object in the list
922 SfxGrabBagItem
* pGrabBagItem
; // holds the GrabBagItem property
923 // Position in the navigation order. SAL_MAX_UINT32 when not used.
924 sal_uInt32 mnNavigationPosition
;
925 SdrLayerID mnLayerID
;
926 bool bInserted
: 1; // only if set to true, there are RepaintBroadcast & SetModify
927 bool bNoPrint
: 1; // if true, the object is not printed.
928 bool mbVisible
: 1; // if false, the object is not visible on screen (but maybe on printer, depending on bNoprint
929 bool bMarkProt
: 1; // marking forbidden, persistent
930 // on import of OLE object from MS documents the BLIP size might be retrieved,
931 // in this case the following member is initialized as nonempty rectangle
932 tools::Rectangle maBLIPSizeRectangle
;
933 sdr::properties::BaseProperties
* mpProperties
;
934 sdr::contact::ViewContact
* mpViewContact
;
935 bool mbDelayBroadcastObjectChange
: 1;
936 mutable bool mbBroadcastObjectChangePending
: 1;
938 // global static ItemPool for not-yet-inserted items
939 static SdrItemPool
* mpGlobalItemPool
;
941 // do not use directly, always use getSvxShape() if you have to!
942 SvxShape
* mpSvxShape
;
943 css::uno::WeakReference
< css::uno::XInterface
>
945 // HACK: Do not automatically insert newly created object into a page.
946 // The user needs to do it manually later.
947 bool mbDoNotInsertIntoPageAutomatically
;
949 // only for internal use!
950 SvxShape
* getSvxShape();
952 SdrObject( const SdrObject
& ) = delete;
955 /** Suppress BroadcastObjectChange() until destruction of the (last) instance.
956 Prevents multiple broadcasts for a sequence of calls that would trigger a
957 broadcast each. Instances may be nested in levels, the outer instance will
958 trigger the final broadcast.
960 class SVX_DLLPUBLIC SdrDelayBroadcastObjectChange
963 bool mbOldDelayBroadcastObjectChange
;
965 SdrDelayBroadcastObjectChange( SdrObject
& rObj
);
966 ~SdrDelayBroadcastObjectChange();
969 struct SdrObjCreatorParams
971 SdrInventor nInventor
;
972 sal_uInt16 nObjIdentifier
;
974 struct SdrObjUserDataCreatorParams
976 SdrInventor nInventor
;
977 sal_uInt16 nObjIdentifier
;
982 * Whoever creates his own objects must set a link in the SdrObjFactory class.
983 * The handler must have the following signature:
984 * void Hdl(SdrObjFactory*)
985 * He must take a look at the referenced instance's nInventor and nIdentifier values,
986 * and must create a new drawing object instance accordingly.
987 * He must also make the pNewObj pointer reference to this instance.
989 class SVX_DLLPUBLIC SdrObjFactory
992 static SdrObject
* MakeNewObject(SdrInventor nInventor
, sal_uInt16 nObjIdentifier
, SdrPage
* pPage
, SdrModel
* pModel
=nullptr);
993 static SdrObject
* MakeNewObject(SdrInventor nInventor
, sal_uInt16 nObjIdentifier
, const tools::Rectangle
& rSnapRect
, SdrPage
* pPage
);
994 static void InsertMakeObjectHdl(Link
<SdrObjCreatorParams
, SdrObject
*> const & rLink
);
995 static void RemoveMakeObjectHdl(Link
<SdrObjCreatorParams
, SdrObject
*> const & rLink
);
996 static void InsertMakeUserDataHdl(Link
<SdrObjUserDataCreatorParams
, SdrObjUserData
*> const & rLink
);
997 static void RemoveMakeUserDataHdl(Link
<SdrObjUserDataCreatorParams
, SdrObjUserData
*> const & rLink
);
1000 static SVX_DLLPRIVATE SdrObject
* CreateObjectFromFactory(
1001 SdrInventor nInventor
, sal_uInt16 nIdentifier
, SdrPage
* pPage
, SdrModel
* pModel
);
1003 SdrObjFactory() = delete;
1006 typedef tools::WeakReference
< SdrObject
> SdrObjectWeakRef
;
1008 template< typename T
> T
* SdrObject::CloneHelper() const
1010 OSL_ASSERT( typeid( T
) == typeid( *this ));
1011 T
* pObj
= dynamic_cast< T
* >( SdrObjFactory::MakeNewObject(GetObjInventor(),GetObjIdentifier(),nullptr));
1013 *pObj
=*static_cast< const T
* >( this );
1017 #endif // INCLUDED_SVX_SVDOBJ_HXX
1019 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */