Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / svdobj.hxx
blobd7f71d5a9c13c4ca6abe0d261148dbb3245cf9dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_SVDOBJ_HXX
21 #define INCLUDED_SVX_SVDOBJ_HXX
23 #include <typeinfo>
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>
39 class SfxBroadcaster;
40 class Pointer;
41 class AutoTimer;
42 class OutlinerParaObject;
43 class SdrOutliner;
44 class SdrDragStat;
45 class SdrHdl;
46 class SdrHdlList;
47 class SdrItemPool;
48 class SdrModel;
49 class SdrObjList;
50 class SdrObject;
51 class SdrPage;
52 class SdrPageView;
53 class SdrView;
54 class SfxItemSet;
55 class SfxGrabBagItem;
56 class SfxSetItem;
57 class SfxStyleSheet;
58 class SfxUndoAction;
59 class XFillAttrSetItem;
60 class XLineAttrSetItem;
61 class SfxItemPool;
62 namespace tools { class PolyPolygon; }
63 class SfxPoolItem;
64 class SdrVirtObj;
65 class SdrDragView;
66 class SdrObjUserDataList;
67 class SdrObjPlusData;
68 class SdrGluePoint;
69 class SdrGluePointList;
70 class SetOfByte;
71 class OutputDevice;
72 class Fraction;
74 namespace basegfx {
76 class B2DPolyPolygon;
77 class B2DHomMatrix;
81 namespace sdr
83 namespace properties
85 class BaseProperties;
88 class ObjectUser;
91 // #110094#
92 namespace sdr
94 namespace contact
96 class ViewContact;
97 } // end of namespace contact
100 namespace svx
102 class PropertyChangeNotifier;
105 enum SdrObjKind {
106 OBJ_NONE = 0, /// abstract object (SdrObject)
107 OBJ_GRUP = 1, /// object group
108 OBJ_LINE = 2, /// line
109 OBJ_RECT = 3, /// rectangle (round corners optional)
110 OBJ_CIRC = 4, /// circle, ellipse
111 OBJ_SECT = 5, /// circle section
112 OBJ_CARC = 6, /// circle arc
113 OBJ_CCUT = 7, /// circle cut
114 OBJ_POLY = 8, /// polygon, PolyPolygon
115 OBJ_PLIN = 9, /// PolyLine
116 OBJ_PATHLINE =10, /// open Bezier-curve
117 OBJ_PATHFILL =11, /// closed Bezier-curve
118 OBJ_FREELINE =12, /// open free-hand line
119 OBJ_FREEFILL =13, /// closed free-hand line
120 OBJ_SPLNLINE =14, /// natural cubic Spline (ni)
121 OBJ_SPLNFILL =15, /// periodic cubic Spline (ni)
122 OBJ_TEXT =16, /// text object
123 OBJ_TEXTEXT =17, /// text extension frame (ni)
124 OBJ_wegFITTEXT, /// FitToSize-Text (all lines equal)
125 OBJ_wegFITALLTEXT, /// FitToSize-Text (by line) (ni)
126 OBJ_TITLETEXT =20, /// TitleText, special text object for StarDraw
127 OBJ_OUTLINETEXT=21, /// OutlineText, special text object for StarDraw
128 OBJ_GRAF =22, /// foreign graphic (StarView Graphic)
129 OBJ_OLE2 =23, /// OLE object
130 OBJ_EDGE =24, /// connector object
131 OBJ_CAPTION =25, /// caption object
132 OBJ_PATHPOLY =26, /// Polygon/PolyPolygon represented by SdrPathObj
133 OBJ_PATHPLIN =27, /// Polyline represented by SdrPathObj
134 OBJ_PAGE =28, /// object that represents a SdrPage
135 OBJ_MEASURE =29, /// measurement object
136 OBJ_DUMMY =30, /// dummy object for saving holes (to recover surrogates later)
137 OBJ_FRAME =31, /// continuously activated OLE (PlugIn-Frame or similar)
138 OBJ_UNO =32, /// Universal Network Object packed into SvDraw object
139 OBJ_CUSTOMSHAPE=33, /// custom shape
140 OBJ_MEDIA =34, /// media shape
141 OBJ_TABLE =35, /// table
142 OBJ_OPENGL =36, /// opengl graphic
143 OBJ_MAXI
146 enum SdrUserCallType {SDRUSERCALL_MOVEONLY, // only moved, size unchanged
147 SDRUSERCALL_RESIZE, // size and maybe position changed
148 SDRUSERCALL_CHGATTR, // attribute changed. Eventually new size, because of line width
149 SDRUSERCALL_DELETE, // object is going to be deleted soon, no attributes anymore
150 SDRUSERCALL_COPY, // assign operator called, everything can be changed
151 SDRUSERCALL_INSERTED, // inserted into an object list (e.g. Page)
152 SDRUSERCALL_REMOVED, // removed from an object list
153 SDRUSERCALL_CHILD_MOVEONLY, // a child within a group has changed
154 SDRUSERCALL_CHILD_RESIZE, // a child within a group has changed
155 SDRUSERCALL_CHILD_CHGATTR, // a child within a group has changed
156 SDRUSERCALL_CHILD_DELETE, // a child within a group has changed
157 SDRUSERCALL_CHILD_COPY, // a child within a group has changed
158 SDRUSERCALL_CHILD_INSERTED, // a child within a group has changed
159 SDRUSERCALL_CHILD_REMOVED}; // a child within a group has changed
161 class SVX_DLLPUBLIC SdrObjUserCall
163 public:
164 TYPEINFO();
165 virtual ~SdrObjUserCall();
166 virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& rOldBoundRect);
169 class SVX_DLLPUBLIC SdrObjMacroHitRec
171 public:
172 Point aPos;
173 Point aDownPos;
174 VclPtr<OutputDevice> pOut;
175 const SetOfByte* pVisiLayer;
176 const SdrPageView* pPageView;
177 sal_uInt16 nTol;
178 bool bDown;
180 SdrObjMacroHitRec();
183 // User data of a drawing object, e.g. application specific data.
184 // Every drawing object can have arbitrarily many such records (SV list).
185 // Whoever wants to save data here, must inherit from this and set a corresponding link in the factory.
186 class SVX_DLLPUBLIC SdrObjUserData
188 protected:
189 sal_uInt32 nInventor;
190 sal_uInt16 nIdentifier;
191 sal_uInt16 nVersion;
193 private:
194 void operator=(const SdrObjUserData& rData) SAL_DELETED_FUNCTION;
195 bool operator==(const SdrObjUserData& rData) const SAL_DELETED_FUNCTION;
196 bool operator!=(const SdrObjUserData& rData) const SAL_DELETED_FUNCTION;
198 public:
199 TYPEINFO();
201 SdrObjUserData(sal_uInt32 nInv, sal_uInt16 nId, sal_uInt16 nVer);
202 SdrObjUserData(const SdrObjUserData& rData);
203 virtual ~SdrObjUserData();
205 virtual SdrObjUserData* Clone(SdrObject* pObj1) const = 0; // #i71039# NULL -> 0
206 sal_uInt32 GetInventor() const { return nInventor;}
207 sal_uInt16 GetId() const { return nIdentifier;}
210 // all geometrical data of an arbitrary object for use in undo/redo
211 class SVX_DLLPUBLIC SdrObjGeoData
213 public:
214 Rectangle aBoundRect;
215 Point aAnchor;
216 SdrGluePointList* pGPL;
217 bool bMovProt;
218 bool bSizProt;
219 bool bNoPrint;
220 bool bClosedObj;
221 bool mbVisible;
222 SdrLayerID mnLayerID;
224 public:
225 SdrObjGeoData();
226 virtual ~SdrObjGeoData();
229 // provides information about various ZObject properties
230 class SVX_DLLPUBLIC SdrObjTransformInfoRec
232 public:
233 bool bSelectAllowed : 1; // if false, object cannot be selected
234 bool bMoveAllowed : 1; // if false, object cannot be moved
235 bool bResizeFreeAllowed : 1; // if false, object cannot be resized freely
236 bool bResizePropAllowed : 1; // if false, object cannot even be resized proportionally
237 bool bRotateFreeAllowed : 1; // if false, object cannot be rotated freely
238 bool bRotate90Allowed : 1; // if false, object cannot even be rotated in 90 degree steps
239 bool bMirrorFreeAllowed : 1; // if false, object cannot be mirrored freely
240 bool bMirror45Allowed : 1; // if false, object cannot even be mirrored over axes in a 45 degree raster
241 bool bMirror90Allowed : 1; // if false, object cannot even be mirrored over axes in a 90 degree raster
242 bool bTransparenceAllowed : 1; // if false, object does not have an interactive transparence control
243 bool bGradientAllowed : 1; // if false, object dooes not have an interactive gradient control
244 bool bShearAllowed : 1; // if false, object cannot be sheared
245 bool bEdgeRadiusAllowed : 1;
246 bool bNoOrthoDesired : 1; // is true for Rect; is false for BMP, MTF
247 bool bNoContortion : 1; // if false, Kein verzerren (bei Crook) moeglich (nur true bei PathObj und Gruppierten PathObjs)
248 bool bCanConvToPath : 1; // if false, no conversion into PathObj possible
249 bool bCanConvToPoly : 1; // if false, no conversion into PolyObj possible
250 bool bCanConvToContour : 1; // if false, no conversion down to whole contour possible
251 bool bCanConvToPathLineToArea : 1; // if false, no conversion into PathObj with transformation from LineToArea possible
252 bool bCanConvToPolyLineToArea : 1; // if false, no conversion into PolyObj with transformation from LineToArea possible
254 SdrObjTransformInfoRec();
257 // Abstract DrawObject
259 class SvxShape;
260 class SVX_DLLPUBLIC SdrObject: public SfxListener, public tools::WeakBase< SdrObject >
262 private:
263 struct Impl;
264 Impl* mpImpl;
266 SdrObject( const SdrObject& ) SAL_DELETED_FUNCTION;
268 public:
269 void AddObjectUser(sdr::ObjectUser& rNewUser);
270 void RemoveObjectUser(sdr::ObjectUser& rOldUser);
272 // BaseProperties section
273 private:
274 sdr::properties::BaseProperties* mpProperties;
275 protected:
276 virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
277 public:
278 virtual sdr::properties::BaseProperties& GetProperties() const;
280 // #110094# DrawContact section
281 private:
282 sdr::contact::ViewContact* mpViewContact;
283 protected:
284 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
285 public:
286 sdr::contact::ViewContact& GetViewContact() const;
288 // DrawContact support: Methods for handling Object changes
289 void ActionChanged() const;
291 private:
292 friend class SdrObjListIter;
293 friend class SdrVirtObj;
294 friend class SdrRectObj;
296 protected:
297 Rectangle aOutRect; // surrounding rectangle for Paint (incl. LineWdt, ...)
298 Point aAnchor; // anchor position (Writer)
299 Point aGridOffset; // hack (Calc)
300 SdrObjList* pObjList; // list that includes this object
301 SdrPage* pPage;
302 SdrModel* pModel;
303 SdrObjUserCall* pUserCall;
304 SdrObjPlusData* pPlusData; // Broadcaster, UserData, connektors, ... (this is the Bitsack)
306 sal_uInt32 nOrdNum; // order number of the object in the list
308 SfxGrabBagItem* pGrabBagItem; // holds the GrabBagItem property
311 // Position in the navigation order. SAL_MAX_UINT32 when not used.
312 sal_uInt32 mnNavigationPosition;
313 SdrLayerID mnLayerID;
315 // object is only pointing to another one
316 bool bVirtObj : 1;
317 bool bSnapRectDirty : 1;
318 bool bNetLock : 1; // ni
319 bool bInserted : 1; // only if set to true, there are RepaintBroadcast & SetModify
320 bool bGrouped : 1; // member of a group object?
322 // the following flags will be streamed
323 bool bMovProt : 1; // if true, the position is protected
324 bool bSizProt : 1; // if true, the size is protected
325 bool bNoPrint : 1; // if true, the object is not printed.
326 bool mbVisible : 1; // if false, the object is not visible on screen (but maybe on printer, depending on bNoprint
327 // If bEmptyPresObj is true, it is a presentation object that has no content yet.
328 // The flag's default value is false.
329 // The management is done by the application.
330 // Neither assign operator nor cloning copies the flag!
331 // The flag is persistent.
332 bool bEmptyPresObj : 1; // empty presentation object (Draw)
334 // if true, object is invisible as object of the MasterPage
335 bool bNotVisibleAsMaster : 1;
337 // if true, the object is closed, i.e. no line, arc...
338 bool bClosedObj : 1;
340 bool bIsEdge : 1;
341 bool bIs3DObj : 1;
342 bool bMarkProt : 1; // marking forbidden, persistent
343 bool bIsUnoObj : 1;
344 bool bNotMasterCachable : 1;
346 // #i25616#
347 bool mbLineIsOutsideGeometry : 1;
349 // #i25616#
350 bool mbSupportTextIndentingOnLineWidthChange : 1;
352 // on import of OLE object from MS documents the BLIP size might be retrieved,
353 // in this case the following member is initialized as nonempty rectangle
354 Rectangle maBLIPSizeRectangle;
356 // global static ItemPool for not-yet-inserted items
357 private:
358 static SdrItemPool* mpGlobalItemPool;
360 public:
361 static SdrItemPool& GetGlobalDrawObjectItemPool();
362 void SetRelativeWidth( double nValue );
363 void SetRelativeWidthRelation( sal_Int16 eValue );
364 void SetRelativeHeight( double nValue );
365 void SetRelativeHeightRelation( sal_Int16 eValue );
366 const double* GetRelativeWidth() const;
367 sal_Int16 GetRelativeWidthRelation() const;
368 const double* GetRelativeHeight() const;
369 sal_Int16 GetRelativeHeightRelation() const;
370 // evil calc grid/shape drawlayer syncing
371 Point GetGridOffset() const { return aGridOffset; }
372 void SetGridOffset( const Point& rGridOffset ){ aGridOffset = rGridOffset; }
373 protected:
374 void ImpDeleteUserData();
375 Rectangle ImpDragCalcRect(const SdrDragStat& rDrag) const;
377 // for GetDragComment
378 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, sal_uInt16 nVal=0) const;
380 void ImpForcePlusData();
382 OUString GetAngleStr(long nAngle, bool bNoDegChar = false) const;
383 OUString GetMetrStr(long nVal, MapUnit eWantMap=MAP_MM, bool bNoUnitChars = false) const;
385 // bNotMyself=true means: set only ObjList to dirty, don't mark this object as dirty.
386 // This is needed for instance for NbcMove, because usually one moves SnapRect and aOutRect
387 // at the same time to avoid recomputation.
388 public:
389 virtual void SetRectsDirty(bool bNotMyself = false);
390 protected:
392 // override if the class inherits from SdrObjPlusData:
393 static SdrObjPlusData* NewPlusData();
395 protected:
396 /// A derived class must override these 3 methods if it has own geometric
397 /// data that must be saved for Undo.
398 /// NewGeoData() creates an empty instance of a class derived from
399 /// SdrObjGeoData.
400 virtual SdrObjGeoData* NewGeoData() const;
401 virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
402 virtual void RestGeoData(const SdrObjGeoData& rGeo);
404 protected:
405 virtual ~SdrObject();
407 public:
408 TYPEINFO_OVERRIDE();
409 SdrObject();
411 // frees the SdrObject pointed to by the argument
412 // In case the object has an SvxShape, which has the ownership of the object, it
413 // is actually *not* deleted.
414 static void Free( SdrObject*& _rpObject );
416 // this method is only for access from Property objects
417 virtual void SetBoundRectDirty();
419 virtual void SetObjList(SdrObjList* pNewObjList);
420 SdrObjList* GetObjList() const { return pObjList;}
422 virtual void SetPage(SdrPage* pNewPage);
423 SdrPage* GetPage() const { return pPage;}
425 virtual void SetModel(SdrModel* pNewModel);
426 SdrModel* GetModel() const { return pModel;}
427 SfxItemPool & GetObjectItemPool() const;
429 void AddListener(SfxListener& rListener);
430 void RemoveListener(SfxListener& rListener);
431 const SfxBroadcaster* GetBroadcaster() const;
433 void AddReference(SdrVirtObj& rVrtObj);
434 void DelReference(SdrVirtObj& rVrtObj);
435 virtual sal_uInt32 GetObjInventor() const;
436 virtual sal_uInt16 GetObjIdentifier() const;
437 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
439 // Layer interface
440 virtual SdrLayerID GetLayer() const;
441 virtual void NbcSetLayer(SdrLayerID nLayer);
442 virtual void SetLayer(SdrLayerID nLayer);
443 // renaming GetLayerSet -> getMergedHierarchyLayerSet to make clear what happens here. rSet needs to be empty.
444 void getMergedHierarchyLayerSet(SetOfByte& rSet) const;
446 // UserCall interface
447 void SetUserCall(SdrObjUserCall* pUser);
448 SdrObjUserCall* GetUserCall() const { return pUserCall;}
449 void SendUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundRect) const;
451 // Such a reference point is for instance:
452 // - a symbol's point that should snap to the raster when inserting the symbol
453 // - or an image's fix point within an animation object
454 virtual bool HasRefPoint() const;
455 virtual Point GetRefPoint() const;
456 virtual void SetRefPoint(const Point& rPnt);
458 // #i68101#
459 // An object may have a user-set Name (Get/SetName()), e.g SdrGrafObj, SdrObjGroup
460 // or SdrOle2Obj.
461 // It may also have a Title and a Description for accessibility purposes.
462 void SetName(const OUString& rStr);
463 OUString GetName() const;
464 void SetTitle(const OUString& rStr);
465 OUString GetTitle() const;
466 void SetDescription(const OUString& rStr);
467 OUString GetDescription() const;
469 // for group objects
470 bool IsGroupObject() const;
471 virtual SdrObjList* GetSubList() const;
472 SdrObject* GetUpGroup() const;
474 /// The order number (aka ZOrder, aka z-index) determines whether a
475 /// SdrObject is located above or below another. Objects are painted from
476 /// lowest to highest order number. If the order of SdrObjects in the
477 /// SdrObjList is changed, the bObjOrdNumsDirty flag is set on the SdrPage
478 /// and the next GetOrdNum() call recalculates the order number of all
479 /// SdrObjects in the SdrObjList.
480 sal_uInt32 GetOrdNum() const;
482 // Warning: this method should only be used if you really know what you're doing
483 sal_uInt32 GetOrdNumDirect() const { return nOrdNum;}
485 // setting the order number should only happen from the model or from the page
486 void SetOrdNum(sal_uInt32 nNum);
488 // GrabBagItem for interim interop purposes
489 void GetGrabBagItem(com::sun::star::uno::Any& rVal) const;
491 void SetGrabBagItem(const com::sun::star::uno::Any& rVal);
493 // Return the position in the navigation order for the called object.
494 // Note that this method may update the navigation position of the
495 // called and of other SdrObjects. Therefore this method can not be
496 // const.
497 // @return
498 // If no navigation position has been explicitly defined then the
499 // result of GetOrdNum() is returned.
500 sal_uInt32 GetNavigationPosition();
502 // Set the position in the navigation position to the given value.
503 // This method is typically used only by the model after a change to
504 // the navigation order.
505 // This method does not change the navigation position of other
506 // objects.
507 // Use SdrObjList::SetObjectNavigationPosition() instead.
508 void SetNavigationPosition (const sal_uInt32 nPosition);
510 // #111111#
511 // To make clearer that this method may trigger RecalcBoundRect and thus may be
512 // expensive and sometimes problematic (inside a bigger object change You will get
513 // non-useful BoundRects sometimes) i rename that method from GetBoundRect() to
514 // GetCurrentBoundRect().
515 virtual const Rectangle& GetCurrentBoundRect() const;
517 // #111111#
518 // To have a possibility to get the last calculated BoundRect e.g for producing
519 // the first rectangle for repaints (old and new need to be used) without forcing
520 // a RecalcBoundRect (which may be problematical and expensive sometimes) i add here
521 // a new method for accessing the last BoundRect.
522 virtual const Rectangle& GetLastBoundRect() const;
524 virtual void RecalcBoundRect();
526 void BroadcastObjectChange() const;
528 // set modified-flag in the model
529 virtual void SetChanged();
531 // Tooling for painting a single object to a OutputDevice. This will be needed as long
532 // as not all painting is changed to use DrawContact objects.
533 bool SingleObjectPainter(OutputDevice& rOut) const;
534 bool LineGeometryUsageIsNecessary() const;
536 // Returns a copy of the object. Every inherited class must reimplement this (in class Foo
537 // it should be sufficient to do "virtual Foo* Clone() const { return CloneHelper< Foo >(); }".
538 // Note that this function uses operator= internally.
539 virtual SdrObject* Clone() const;
541 virtual SdrObject* CloneWithShellIDs( const OUString& rSrcShellID, const OUString& rDestShellID ) const;
543 // implemented mainly for the purposes of Clone()
544 SdrObject& operator=(const SdrObject& rObj);
546 // TakeObjName...() is for the display in the UI, e.g. "3 frames selected"
547 virtual OUString TakeObjNameSingul() const;
548 virtual OUString TakeObjNamePlural() const;
550 /// The Xor-Polygon is required by the View to drag the object.
551 /// All polygons within the PolyPolygon are interpreted as PolyLine.
552 /// To get a closed Polygon, close it explicitly.
553 virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
555 /// contour for TextToContour
556 virtual basegfx::B2DPolyPolygon TakeContour() const;
558 /// Via GetHdlCount the number of Handles can be retrieved.
559 /// Normally 8, if it's a line 2.
560 /// For Polygon objects (Polygon/Spline/Bezier) the number may be much
561 /// larger. Polygon objects are also allowed to select a point of a
562 /// selected object. The handle of that point will then be replaced by
563 /// a new set of handles (PlusHdl). For a Polygon this would be a simple
564 /// selection Handle, for a Bezier curve this may be up to 3 Handles
565 /// (including Weights).
566 /// GetHdl() and GetPlusHdl() must create Handle instances with new!
567 /// An object that returns true from HasSpacialDrag() must provide these
568 /// methods (incl. FillHdlList()).
569 virtual sal_uInt32 GetHdlCount() const;
570 virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const;
571 virtual sal_uInt32 GetPlusHdlCount(const SdrHdl& rHdl) const;
572 virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const;
573 virtual void AddToHdlList(SdrHdlList& rHdlList) const;
574 virtual void addCropHandles(SdrHdlList& rTarget) const;
576 /// The standard transformations (Move,Resize,Rotate,Mirror,Shear) are
577 /// taken over by the View (TakeXorPoly(),...).
578 /// Object type specific dragging like corner radius of Rectangle,
579 /// control points of Splines, weights of Bezier curves, pointer of
580 /// Label objects must be handled by the object itself.
581 /// To keep the Model free of state, the state is kept in the View
582 /// and then passed to the object. EndDrag usually returns true for success,
583 /// false may be returned if the dragging did not modify the object,
584 /// where the View already handles the case that the pointer was not
585 /// moved at all.
586 virtual bool hasSpecialDrag() const;
587 virtual bool beginSpecialDrag(SdrDragStat& rDrag) const;
588 virtual bool applySpecialDrag(SdrDragStat& rDrag);
589 virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const;
590 virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const;
592 // FullDrag support. This is for standard interactions and for SdrObjOwn
593 // support. If supportsFullDrag() returns true, getFullDragClone has to
594 // return a cloned SdrObject (who's ownership it loses) at which modifications
595 // like Move(), Scale(), etc or applySpecialDrag() will be executed. That
596 // object will be visualized on overlay for full drag, but should not be
597 // part of the model, thus not changing anything since it's only a temporary
598 // helper object for interaction
599 virtual bool supportsFullDrag() const;
600 virtual SdrObject* getFullDragClone() const;
602 /// Every object must be able to create itself interactively.
603 /// On MouseDown first an object is created, and its BegCreate() method
604 /// is called. On every MouseMove, MovCreate() is called. BrkCreate()
605 /// is called if the user cancels the interactive object creation.
606 /// EndCreate() is called on the MouseUp event. If EndCreate() returns
607 /// true, the creation is finished; the object is inserted into the
608 /// corresponding list. Otherwise it is assumed that further points
609 /// are necessary to create the object (Polygon, ...). The parameter
610 /// eCmd contains the number of mouse clicks (if the application
611 /// provides it).
612 /// BckCreate() will undo the previous EndCreate(), e.g. to delete the
613 /// last point of the Polygon. If BckCreate() returns false, creation
614 /// is cancelled.
615 virtual bool BegCreate(SdrDragStat& rStat);
616 virtual bool MovCreate(SdrDragStat& rStat); // if true, Xor needs to be repainted
617 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
618 virtual bool BckCreate(SdrDragStat& rStat);
619 virtual void BrkCreate(SdrDragStat& rStat);
621 /// get the cursor/pointer that signals creating this object
622 virtual Pointer GetCreatePointer() const;
624 /// Polygon dragged by the user when creating the object
625 virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const;
627 /// The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and
628 /// SetLogicRect call the corresponding Nbc-methods, send a Repaint
629 /// broadcast and set the Modified state on the Model.
630 /// Derived classes should usually only override the Nbc methods.
631 /// Nbc means "no broadcast".
632 virtual void NbcMove (const Size& rSiz);
633 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
634 virtual void NbcCrop (const Point& rRef, const Fraction& xFact, const Fraction& yFact);
635 virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs);
636 virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
637 virtual void NbcShear (const Point& rRef, long nAngle, double tn, bool bVShear);
639 virtual void Move (const Size& rSiz);
640 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true);
641 virtual void Crop (const Point& rRef, const Fraction& xFact, const Fraction& yFact);
642 virtual void Rotate(const Point& rRef, long nAngle, double sn, double cs);
643 virtual void Mirror(const Point& rRef1, const Point& rRef2);
644 virtual void Shear (const Point& rRef, long nAngle, double tn, bool bVShear);
646 /// The relative position of a SdrObject is the distance of the upper
647 /// left corner of the logic bounding rectangle (SnapRect) to the anchor.
648 virtual void NbcSetRelativePos(const Point& rPnt);
649 virtual void SetRelativePos(const Point& rPnt);
650 virtual Point GetRelativePos() const;
651 void ImpSetAnchorPos(const Point& rPnt);
652 virtual void NbcSetAnchorPos(const Point& rPnt);
653 virtual void SetAnchorPos(const Point& rPnt);
654 virtual const Point& GetAnchorPos() const;
656 /// Snap is not done on the BoundRect but if possible on logic coordinates
657 /// (i.e. without considering stroke width, ...)
658 /// SetSnapRect() tries to size the Object so that it fits into the
659 /// passed Rect (without stroke width, ...)
660 virtual void RecalcSnapRect();
661 virtual const Rectangle& GetSnapRect() const;
662 virtual void SetSnapRect(const Rectangle& rRect);
663 virtual void NbcSetSnapRect(const Rectangle& rRect);
665 // Logic Rect: for the Rect for instance without regard to rotation angle, shear, ...
666 virtual const Rectangle& GetLogicRect() const;
667 virtual void SetLogicRect(const Rectangle& rRect);
668 virtual void NbcSetLogicRect(const Rectangle& rRect);
670 // the default is to set the logic rect to the given rectangle rMaxRect. If the shape
671 // has an intrinsic aspect ratio it may set the logic rect so the aspect
672 // ratio is kept but still inside the rectangle rMaxRect.
673 // If bShrinkOnly is set to true, the size of the current logic rect will not
674 // be changed if it is smaller than the given rectangle rMaxRect.
675 virtual void AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly = false );
677 // rotation and shear angle
678 virtual long GetRotateAngle() const;
679 virtual long GetShearAngle(bool bVertical = false) const;
681 /// snap to special points of an Object (polygon points, center of circle)
682 virtual sal_uInt32 GetSnapPointCount() const;
683 virtual Point GetSnapPoint(sal_uInt32 i) const;
685 // For objects, whose points can be moved individually.
686 // (e.g. polygons, polylines, lines)
687 // The points of those objects are selected (if necessary multiselection),
688 // deleted, inserted, or as a multiselection moved or rotated...
689 // Only such objects can have PlusHandles (e.g. the weights of an Bezier curve).
690 virtual bool IsPolyObj() const;
691 virtual sal_uInt32 GetPointCount() const;
692 virtual Point GetPoint(sal_uInt32 i) const;
693 void SetPoint(const Point& rPnt, sal_uInt32 i);
694 virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i);
696 // get all geometrical data for undo/redo
697 virtual SdrObjGeoData* GetGeoData() const;
698 virtual void SetGeoData(const SdrObjGeoData& rGeo);
700 // ItemSet access
701 const SfxItemSet& GetMergedItemSet() const;
702 void SetMergedItem(const SfxPoolItem& rItem);
703 void ClearMergedItem(const sal_uInt16 nWhich = 0);
704 void SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems = false);
705 const SfxPoolItem& GetMergedItem(const sal_uInt16 nWhich) const;
707 // internal versions
708 protected:
709 const SfxItemSet& GetObjectItemSet() const;
710 void SetObjectItem(const SfxPoolItem& rItem);
711 void SetObjectItemSet(const SfxItemSet& rSet);
712 const SfxPoolItem& GetObjectItem(const sal_uInt16 nWhich) const;
714 // get SfxMapUnit the object is using
715 SfxMapUnit GetObjectMapUnit() const;
717 public:
718 // syntactical sugar for ItemSet accesses
719 void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems = false);
721 // NotPersistAttr for Layer, ObjName, geometrical transformations etc.
722 void TakeNotPersistAttr(SfxItemSet& rAttr, bool bMerge) const;
723 void ApplyNotPersistAttr(const SfxItemSet& rAttr);
724 void NbcApplyNotPersistAttr(const SfxItemSet& rAttr);
726 // if bDontRemoveHardAttr is false, set all attributes, which were set in the style sheet, to their default value
727 // if true, all hard attributes keep their values
728 void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr);
729 virtual void NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr);
730 SfxStyleSheet* GetStyleSheet() const;
732 virtual bool HasTextEdit() const;
734 // returns true if TextEditMode started
735 virtual bool BegTextEdit(SdrOutliner& rOutl);
736 virtual void EndTextEdit(SdrOutliner& rOutl);
738 // keep text in outliner's format
739 // SetOutlinerParaObject: transfer ownership of *pTextObject!
740 void SetOutlinerParaObject(OutlinerParaObject* pTextObject);
741 virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject);
742 virtual OutlinerParaObject* GetOutlinerParaObject() const;
743 virtual void NbcReformatText();
744 virtual void ReformatText();
746 void BurnInStyleSheetAttributes();
748 // macro abilities, e.g. a rectangle as PushButton.
749 virtual bool HasMacro() const;
750 virtual SdrObject* CheckMacroHit (const SdrObjMacroHitRec& rRec) const;
751 virtual Pointer GetMacroPointer (const SdrObjMacroHitRec& rRec) const;
752 virtual void PaintMacro (OutputDevice& rOut, const Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const;
753 virtual bool DoMacro (const SdrObjMacroHitRec& rRec);
754 virtual OUString GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const;
755 bool IsMacroHit(const SdrObjMacroHitRec& rRec) const;
757 // Connectors
758 // (see also documentation in SvdoEdge.hxx, SdrEdgeObj,
759 // as well as SvdGlue.hxx and SvdGlEV.hxx)
760 // There are nodes and edges. In theory an edge can also be a node, but this isn't implemented yet.
761 // A node has a number of glue points, onto which edges can glued to
762 // An edge can be either
763 // - without any connection to any node,
764 // - or connected on one end to a node, while the other end is not connected,
765 // - or connected on both ends with exactly one node each.
766 // The edge is listener for its up to two nodes.
767 // Whenever a node is moved or resized, all its connected edges follow.
768 // This is also true for SetGluePoint()... on the node.
769 // On the other hand, moving/resizing an edge breaks the connection.
771 // is object a node?
772 virtual bool IsNode() const;
774 // automatic glue points:
775 // a node object must provide four vertex and corner positions
776 // usually 0: top, 1: right, 2: bottom, 3: left
777 virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const;
779 // usually:
780 // 0: top-left, 1: top-right, 2: bottom-right, 3: bottom-left
781 virtual SdrGluePoint GetCornerGluePoint(sal_uInt16 nNum) const;
783 // list of all glue points, can be NULL
784 virtual const SdrGluePointList* GetGluePointList() const;
785 //virtual SdrGluePointList* GetGluePointList();
787 // after changing the GluePointList, one has to call the object's SendRepaintBroadcast!
788 virtual SdrGluePointList* ForceGluePointList();
790 // to be set temporarily when transforming related object(?)
791 void SetGlueReallyAbsolute(bool bOn);
792 void NbcRotateGluePoints(const Point& rRef, long nAngle, double sn, double cs);
793 void NbcMirrorGluePoints(const Point& rRef1, const Point& rRef2);
794 void NbcShearGluePoints (const Point& rRef, long nAngle, double tn, bool bVShear);
796 // is object an edge?
797 virtual bool IsEdge() const;
799 // if bTail1 is true, line start, otherwise line end
800 // if pObj is null disconnect
801 virtual void ConnectToNode(bool bTail1, SdrObject* pObj);
802 virtual void DisconnectFromNode(bool bTail1);
803 virtual SdrObject* GetConnectedNode(bool bTail1) const;
805 // sets the writing mode of the object's context
806 // Objects which itself do not support different writing modes will ignore this call.
807 // Objects which support different writing modes, but have an own, explicit writing mode set,
808 // will also ignore this call.
809 // Objects which support different writing modes, and whose own mode is set to css.text.WritingMode2.CONTEXT,
810 // will use the given writing mode to calculate their "effective writing mode".
811 // The behaviour of this method is undefined if you pass css.text.WritingMode2.CONTEXT.
812 // @param _nContextWritingMode
813 // the effective writing mode of the context of the object
814 virtual void SetContextWritingMode( const sal_Int16 _nContextWritingMode );
816 // If an object is able to convert itself into a polygon or into a Bezier curve (or into both),
817 // then the following methods should be overridden.
818 // E.g., convert a RectObj with line width 10, SOLID_PEN into a polygon:
819 // In the bLineToArea=false mode a PolyObj with four supporting points,
820 // line width 10 and SOLID_PEN shall be created.
821 // On the contrary in the bLineToArea=true mode the generated object should
822 // still have a line attribute NULL_PEN, and the line (also line pattern)
823 // itself should be emulated by the polygon area, which thereby can be
824 // manipulated by the user afterwards.
825 // The RectObj therefore can only convert correctly if it has an area attribute NULL_BRUSH.
826 // In this case it would have to:
827 // - set SOLID_BRUSH with the color of the given pen,
828 // - set NULL_PEN, and
829 // - generate tools::PolyPolygon with two polygons with four supporting points each.
830 // In each case the return value is a SdrObject*, because it is also
831 // allowed to return group objects (e.g. for SdrTextObj).
832 // In the case of the conversion from TextObj to PathObj,
833 // both modi (bLineToArea=true/false) would be identical.
834 // The methods' default implementations report "I'm unable to do this" (false/null).
835 virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const;
836 SdrObject* ConvertToPolyObj(bool bBezier, bool bLineToArea) const;
838 // convert this path object to contour object; bForceLineDash converts even
839 // when there is no filled new polygon created from line-to-polygon conversion,
840 // specially used for XLINE_DASH and 3D conversion
841 SdrObject* ConvertToContourObj(SdrObject* pRet, bool bForceLineDash = false) const;
842 static SdrObject* ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDash = false);
844 // if true, reference onto an object
845 bool IsVirtualObj() const { return bVirtObj;}
847 // is true, if object can probably be filled
848 // is false, if object has probably line ends
849 // is invalid, if this is a group object
850 bool IsClosedObj() const { return bClosedObj;}
852 bool IsEdgeObj() const { return bIsEdge;}
853 bool Is3DObj() const { return bIs3DObj;}
854 bool IsUnoObj() const { return bIsUnoObj;}
855 void SetMarkProtect(bool bProt);
856 bool IsMarkProtect() const { return bMarkProt;}
857 void SetInserted(bool bIns);
858 bool IsInserted() const { return bInserted;}
859 void SetMoveProtect(bool bProt);
860 bool IsMoveProtect() const { return bMovProt;}
861 void SetResizeProtect(bool bProt);
862 bool IsResizeProtect() const { return bSizProt;}
863 void SetPrintable(bool bPrn);
864 bool IsPrintable() const { return !bNoPrint;}
865 void SetVisible(bool bVisible);
866 bool IsVisible() const { return mbVisible;}
867 void SetEmptyPresObj(bool bEpt);
868 bool IsEmptyPresObj() const { return bEmptyPresObj;}
869 void SetNotVisibleAsMaster(bool bFlg);
870 bool IsNotVisibleAsMaster() const { return bNotVisibleAsMaster;}
872 // #i25616#
873 bool LineIsOutsideGeometry() const { return mbLineIsOutsideGeometry;}
875 // #i25616#
876 bool DoesSupportTextIndentingOnLineWidthChange() const { return mbSupportTextIndentingOnLineWidthChange;}
878 // application specific data
879 sal_uInt16 GetUserDataCount() const;
880 SdrObjUserData* GetUserData(sal_uInt16 nNum) const;
882 void AppendUserData(SdrObjUserData* pData);
884 // removes the record from the list and performs delete (FreeMem+Dtor).
885 void DeleteUserData(sal_uInt16 nNum);
887 // switch ItemPool for this object
888 void MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel = 0L);
890 // access to the UNO representation of the shape
891 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
892 ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > getWeakUnoShape() const { return maWeakUnoShape; }
894 static SdrObject* getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt );
896 // sets a new UNO representation of the shape
897 // This is only a public interface function. The actual work is
898 // done by impl_setUnoShape().
899 // Calling this function is only allowed for the UNO representation
900 // itself!
901 void setUnoShape(
902 const com::sun::star::uno::Reference<
903 com::sun::star::uno::XInterface>& _rxUnoShape);
905 // retrieves the instance responsible for notifying changes in the properties of the shape associated with
906 // the SdrObject
908 // @precond
909 // There already exists an SvxShape instance associated with the SdrObject
910 // @throws ::com::sun::star::uno::RuntimeException
911 // if there does nt yet exists an SvxShape instance associated with the SdrObject.
912 svx::PropertyChangeNotifier&
913 getShapePropertyChangeNotifier();
915 // notifies a change in the given property, to all applicable listeners registered at the associated SvxShape
917 // This method is equivalent to calling getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty ),
918 // exception that it is allowed to be called when there does not yet exist an associated SvxShape - in which
919 // case the method will silently return without doing anything.
920 void notifyShapePropertyChange( const svx::ShapeProperty _eProperty ) const;
922 // transformation interface for StarOfficeAPI. This implements support for
923 // homogen 3x3 matrices containing the transformation of the SdrObject. At the
924 // moment it contains a shearX, rotation and translation, but for setting all linear
925 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
927 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
928 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
929 virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const;
931 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
932 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
933 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
934 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon);
936 // #116168#
937 // give info if object is in destruction
938 bool IsInDestruction() const;
940 // return if fill is != XFILL_NONE
941 bool HasFillStyle() const;
942 bool HasLineStyle() const;
944 // on import of OLE object from MS documents the BLIP size might be retrieved,
945 // the following methods are used to control it;
946 // usually this data makes no sense after the import is finished, since the object
947 // might be resized
948 Rectangle GetBLIPSizeRectangle() const { return maBLIPSizeRectangle;}
949 void SetBLIPSizeRectangle( const Rectangle& aRect );
951 /// @see mbDoNotInsertIntoPageAutomatically
952 void SetDoNotInsertIntoPageAutomatically(bool bSet);
953 /// @see mbDoNotInsertIntoPageAutomatically
954 bool IsDoNotInsertIntoPageAutomatically() const { return mbDoNotInsertIntoPageAutomatically;}
956 // #i121917#
957 virtual bool HasText() const;
959 OString stringify() const;
961 virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
963 protected:
964 // Sets a new UNO shape
966 // The default implementation of this function sets the new UNO
967 // shape. Derived classes should override the function to handle
968 // any other actions that are needed when the shape is being
969 // changed.
971 // The implementation _must_ call the same method of its parent
972 // class (preferably as the first step)!
973 virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape );
975 // helper function for reimplementing Clone().
976 template< typename T > T* CloneHelper() const;
978 private:
979 // only for internal use!
980 SvxShape* getSvxShape();
982 // do not use directly, always use getSvxShape() if you have to!
983 SvxShape* mpSvxShape;
984 ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface >
985 maWeakUnoShape;
986 // HACK: Do not automatically insert newly created object into a page.
987 // The user needs to do it manually later.
988 bool mbDoNotInsertIntoPageAutomatically;
991 // Whoever creates his own objects must set a link in the SdrObjFactory class.
992 // The handler must have the following signature:
993 // void Hdl(SdrObjFactory*)
994 // He must take a look at the referenced instance's nInventor and nIdentifier values,
995 // and must create a new drawing object instance accordingly.
996 // He must also make the pNewObj pointer reference to this instance.
997 class SVX_DLLPUBLIC SdrObjFactory
999 public:
1000 sal_uInt32 nInventor;
1001 sal_uInt16 nIdentifier;
1003 // for MakeNewObj():
1004 SdrPage* pPage;
1005 SdrModel* pModel;
1006 SdrObject* pNewObj;
1008 // for MakeNewObjUserData():
1009 SdrObject* pObj;
1010 SdrObjUserData* pNewData;
1012 private:
1014 static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory(
1015 sal_uInt32 nInventor, sal_uInt16 nIdentifier, SdrPage* pPage, SdrModel* pModel );
1017 SVX_DLLPRIVATE SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel);
1019 public:
1020 static SdrObject* MakeNewObject(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pPage, SdrModel* pModel=NULL);
1021 static SdrObject* MakeNewObject( sal_uInt32 nInventor, sal_uInt16 nIdentifier, const Rectangle& rSnapRect, SdrPage* pPage );
1022 static void InsertMakeObjectHdl(const Link<>& rLink);
1023 static void RemoveMakeObjectHdl(const Link<>& rLink);
1024 static void InsertMakeUserDataHdl(const Link<>& rLink);
1025 static void RemoveMakeUserDataHdl(const Link<>& rLink);
1028 typedef tools::WeakReference< SdrObject > SdrObjectWeakRef;
1030 template< typename T > T* SdrObject::CloneHelper() const
1032 OSL_ASSERT( typeid( T ) == typeid( *this ));
1033 T* pObj = dynamic_cast< T* >( SdrObjFactory::MakeNewObject(GetObjInventor(),GetObjIdentifier(),NULL));
1034 if (pObj!=NULL)
1035 *pObj=*static_cast< const T* >( this );
1036 return pObj;
1039 #endif // INCLUDED_SVX_SVDOBJ_HXX
1041 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */