diff options
Diffstat (limited to 'include/svx/svdobj.hxx')
-rw-r--r-- | include/svx/svdobj.hxx | 109 |
1 files changed, 84 insertions, 25 deletions
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 3f01cbb82ff6..7d033605933a 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -74,10 +74,11 @@ class SdrLayerIDSet; class OutputDevice; class Fraction; -namespace basegfx { -class B2DPoint; -class B2DPolyPolygon; -class B2DHomMatrix; +namespace basegfx +{ + class B2DPoint; + class B2DPolyPolygon; + class B2DHomMatrix; } namespace sdr @@ -103,6 +104,8 @@ namespace svx class PropertyChangeNotifier; } +class SvxShape; + enum SdrObjKind { OBJ_NONE = 0, /// abstract object (SdrObject) OBJ_GRUP = 1, /// object group @@ -265,9 +268,45 @@ public: SdrObjTransformInfoRec(); }; -/// Abstract DrawObject +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// SdrObject +// SdrAttrObj +// E3dObject +// E3dCompoundObject +// E3dCubeObj +// E3dExtrudeObj +// E3dLatheObj +// E3dPolygonObj +// E3dSphereObj +// E3dScene +// SdrTextObj +// SdrObjCustomShape +// OCustomShape +// SdrEdgeObj +// SdrMeasureObj +// SdrPathObj +// SdrRectObj +// SdrCaptionObj +// SdrCircObj +// SdrGrafObj +// SdrMediaObj +// SdrOle2Obj +// OOle2Obj +// SdrUnoObj +// DlgEdObj +// DlgEdForm +// OUnoObject +// FmFormObj +// SdrTableObj +// SdrObjGroup +// SdrPageObj +// SdrVirtObj +// SwDrawVirtObj +// SwVirtFlyDrawObj +// SwFlyDrawObj -class SvxShape; +/// Abstract DrawObject class SVX_DLLPUBLIC SdrObject: public SfxListener, public virtual tools::WeakBase { private: @@ -296,8 +335,16 @@ private: public: const SdrObject* getFillGeometryDefiningShape() const { return mpFillGeometryDefiningShape; } +private: + // the SdrModel this objects was created with, unchanged during SdrObject lifetime + SdrModel& mrSdrModelFromSdrObject; + public: - SdrObject(); + // A SdrObject always needs a SdrModel for lifetime (Pool, ...) + SdrObject(SdrModel& rSdrModel); + + // SdrModel access on SdrObject level + SdrModel& getSdrModelFromSdrObject() const { return mrSdrModelFromSdrObject; } void AddObjectUser(sdr::ObjectUser& rNewUser); void RemoveObjectUser(sdr::ObjectUser& rOldUser); @@ -341,9 +388,6 @@ public: virtual void SetPage(SdrPage* pNewPage); SdrPage* GetPage() const { return pPage;} - - virtual void SetModel(SdrModel* pNewModel); - SdrModel* GetModel() const { return pModel;} SfxItemPool & GetObjectItemPool() const; void AddListener(SfxListener& rListener); @@ -438,7 +482,7 @@ public: // Returns a copy of the object. Every inherited class must reimplement this (in class Foo // it should be sufficient to do "virtual Foo* Clone() const { return CloneHelper< Foo >(); }". // Note that this function uses operator= internally. - virtual SdrObject* Clone() const; + virtual SdrObject* Clone(SdrModel* pTargetModel = nullptr) const; // implemented mainly for the purposes of Clone() SdrObject& operator=(const SdrObject& rObj); @@ -724,7 +768,9 @@ public: // when there is no filled new polygon created from line-to-polygon conversion, // specially used for XLINE_DASH and 3D conversion SdrObject* ConvertToContourObj(SdrObject* pRet, bool bForceLineDash = false) const; - static SdrObject* ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDash); +private: + SdrObject* ImpConvertToContourObj(bool bForceLineDash); +public: // if true, reference onto an object bool IsVirtualObj() const { return bVirtObj;} @@ -762,9 +808,6 @@ public: // removes the record from the list and performs delete (FreeMem+Dtor). void DeleteUserData(sal_uInt16 nNum); - // switch ItemPool for this object - void MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel); - // access to the UNO representation of the shape virtual css::uno::Reference< css::uno::XInterface > getUnoShape(); @@ -867,7 +910,6 @@ protected: tools::Rectangle aOutRect; // surrounding rectangle for Paint (incl. LineWdt, ...) Point aAnchor; // anchor position (Writer) SdrPage* pPage; - SdrModel* pModel; SdrObjUserCall* pUserCall; std::unique_ptr<SdrObjPlusData> pPlusData; // Broadcaster, UserData, connectors, ... (this is the Bitsack) @@ -909,7 +951,6 @@ protected: void ImpForcePlusData(); - OUString GetAngleStr(long nAngle) const; OUString GetMetrStr(long nVal) const; /// A derived class must override these 3 methods if it has own geometric @@ -945,7 +986,7 @@ protected: virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& _rxUnoShape ); // helper function for reimplementing Clone(). - template< typename T > T* CloneHelper() const; + template< typename T > T* CloneHelper(SdrModel* pTargetModel) const; private: struct Impl; @@ -1006,6 +1047,7 @@ struct SdrObjCreatorParams { SdrInventor nInventor; sal_uInt16 nObjIdentifier; + SdrModel& rSdrModel; }; /** @@ -1019,23 +1061,40 @@ struct SdrObjCreatorParams class SVX_DLLPUBLIC SdrObjFactory { public: - static SdrObject* MakeNewObject(SdrInventor nInventor, sal_uInt16 nObjIdentifier, SdrPage* pPage, SdrModel* pModel=nullptr); - static SdrObject* MakeNewObject(SdrInventor nInventor, sal_uInt16 nObjIdentifier, const tools::Rectangle& rSnapRect, SdrPage* pPage); + static SdrObject* MakeNewObject( + SdrModel& rSdrModel, + SdrInventor nInventor, + sal_uInt16 nObjIdentifier, + SdrPage* pPage = nullptr, + const tools::Rectangle* pSnapRect = nullptr); + static void InsertMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink); static void RemoveMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink); private: - static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory( SdrInventor nInventor, sal_uInt16 nIdentifier ); + static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory( + SdrModel& rSdrModel, + SdrInventor nInventor, + sal_uInt16 nIdentifier); SdrObjFactory() = delete; }; -template< typename T > T* SdrObject::CloneHelper() const +template< typename T > T* SdrObject::CloneHelper(SdrModel* pTargetModel) const { OSL_ASSERT( typeid( T ) == typeid( *this )); - T* pObj = dynamic_cast< T* >( SdrObjFactory::MakeNewObject(GetObjInventor(),GetObjIdentifier(),nullptr)); - if (pObj!=nullptr) - *pObj=*static_cast< const T* >( this ); + T* pObj = dynamic_cast< T* >( + SdrObjFactory::MakeNewObject( + nullptr == pTargetModel ? getSdrModelFromSdrObject() : *pTargetModel, + GetObjInventor(), + GetObjIdentifier())); + + if(nullptr != pObj) + { + // use ::operator=() + *pObj = *static_cast< const T* >( this ); + } + return pObj; } |