diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-09 13:42:22 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-10 07:35:41 +0100 |
commit | 09cb778b6eb7d3a5b9029965a1320b49c90e7295 (patch) | |
tree | 63d75bc66ddbe4af5f6a52f4a0d65e9b199dbae7 | |
parent | ccdee8eebaa56619248e35001017226eecfe4e83 (diff) |
clean up SdrObject cloning
using operator= implies that overwriting an SdrObject is a
useful operation, but that is not at all true - they are typically
linked into and referred to by many other things.
So rather use a copy-constructor.
Also clean up a couple of weird "do some stuff after the clone"
code into the main copy constructor.
Change-Id: Iefc1481b527602748b5f3abed06e7cca66c0581c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110633
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
58 files changed, 761 insertions, 811 deletions
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 056006c4305e..e4047abace14 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -74,6 +74,44 @@ DlgEdObj::DlgEdObj(SdrModel& rSdrModel) { } +DlgEdObj::DlgEdObj(SdrModel& rSdrModel, DlgEdObj const & rSource) +: SdrUnoObj(rSdrModel, rSource) + ,bIsListening(false) +{ + // set parent form + pDlgEdForm = rSource.pDlgEdForm; + + // add child to parent form + pDlgEdForm->AddChild( this ); + + Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY ); + if ( xPSet.is() ) + { + // set new name + OUString aOUniqueName( GetUniqueName() ); + Any aUniqueName; + aUniqueName <<= aOUniqueName; + xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName ); + + Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY ); + if ( xCont.is() ) + { + // set tabindex + Sequence< OUString > aNames = xCont->getElementNames(); + xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(aNames.getLength())) ); + + // insert control model in dialog model + Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY ); + xCont->insertByName( aOUniqueName, Any(xCtrl) ); + + pDlgEdForm->UpdateTabOrderAndGroups(); + } + } + + // start listening + StartListening(); +} + DlgEdObj::DlgEdObj( SdrModel& rSdrModel, const OUString& rModelName, @@ -868,62 +906,16 @@ SdrObjKind DlgEdObj::GetObjIdentifier() const } } -void DlgEdObj::clonedFrom(const DlgEdObj* _pSource) -{ - // set parent form - pDlgEdForm = _pSource->pDlgEdForm; - - // add child to parent form - pDlgEdForm->AddChild( this ); - - Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY ); - if ( xPSet.is() ) - { - // set new name - OUString aOUniqueName( GetUniqueName() ); - Any aUniqueName; - aUniqueName <<= aOUniqueName; - xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName ); - - Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY ); - if ( xCont.is() ) - { - // set tabindex - Sequence< OUString > aNames = xCont->getElementNames(); - xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(aNames.getLength())) ); - - // insert control model in dialog model - Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY ); - xCont->insertByName( aOUniqueName, Any(xCtrl) ); - - pDlgEdForm->UpdateTabOrderAndGroups(); - } - } - - // start listening - StartListening(); -} - DlgEdObj* DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const { - DlgEdObj* pDlgEdObj = CloneHelper< DlgEdObj >(rTargetModel); - DBG_ASSERT( pDlgEdObj != nullptr, "DlgEdObj::Clone: invalid clone!" ); - if ( pDlgEdObj ) - pDlgEdObj->clonedFrom( this ); - - return pDlgEdObj; + return new DlgEdObj(rTargetModel, *this); } SdrObjectUniquePtr DlgEdObj::getFullDragClone() const { // no need to really add the clone for dragging, it's a temporary // object - SdrObjectUniquePtr pObj( new SdrUnoObj( - getSdrModelFromSdrObject(), - OUString()) ); - *pObj = *static_cast<const SdrUnoObj*>(this); - - return pObj; + return SdrObjectUniquePtr(new SdrUnoObj(getSdrModelFromSdrObject(), *this)); } void DlgEdObj::NbcMove( const Size& rSize ) diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx index 8ae88ef5c80a..d5e29cf48caf 100644 --- a/basctl/source/inc/dlgedobj.hxx +++ b/basctl/source/inc/dlgedobj.hxx @@ -59,6 +59,8 @@ private: protected: DlgEdObj(SdrModel& rSdrModel); + // copy constructor + DlgEdObj(SdrModel& rSdrModel, DlgEdObj const & rSource); DlgEdObj( SdrModel& rSdrModel, const OUString& rModelName, @@ -91,11 +93,6 @@ protected: sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut ); public: - DlgEdObj(DlgEdObj const &) = delete; // due to SdrUnoObj - DlgEdObj(DlgEdObj &&) = delete; // due to SdrUnoObj - DlgEdObj & operator =(DlgEdObj const &) = default; - DlgEdObj & operator =(DlgEdObj &&) = default; - void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; } DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; } @@ -103,7 +100,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual DlgEdObj* CloneSdrObject(SdrModel& rTargetModel) const override; // not working yet - void clonedFrom(const DlgEdObj* _pSource); // not working yet // FullDrag support virtual SdrObjectUniquePtr getFullDragClone() const override; diff --git a/include/svx/cube3d.hxx b/include/svx/cube3d.hxx index 515e8331c044..9842b26f0e55 100644 --- a/include/svx/cube3d.hxx +++ b/include/svx/cube3d.hxx @@ -65,6 +65,7 @@ public: const E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& aPos, const basegfx::B3DVector& r3DSize); + E3dCubeObj(SdrModel& rSdrModel, E3dCubeObj const &); E3dCubeObj(SdrModel& rSdrModel); virtual SdrObjKind GetObjIdentifier() const override; @@ -72,9 +73,6 @@ public: virtual E3dCubeObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - E3dCubeObj& operator=(const E3dCubeObj& rObj); - // Set local parameters with geometry recreation void SetCubePos(const basegfx::B3DPoint& rNew); const basegfx::B3DPoint& GetCubePos() const { return aCubePos; } diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx index db2c868280ce..4bd2fea31da6 100644 --- a/include/svx/lathe3d.hxx +++ b/include/svx/lathe3d.hxx @@ -56,6 +56,7 @@ public: SdrModel& rSdrModel, const E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon& rPoly2D); + E3dLatheObj(SdrModel& rSdrModel, E3dLatheObj const & rSource); E3dLatheObj(SdrModel& rSdrModel); // HorizontalSegments: @@ -102,9 +103,6 @@ public: virtual E3dLatheObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - E3dLatheObj& operator=(const E3dLatheObj& rObj); - virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override; // TakeObjName...() is for the display in the UI, for example "3 frames selected". diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx index 4455711779af..4f18b4fcf694 100644 --- a/include/svx/obj3d.hxx +++ b/include/svx/obj3d.hxx @@ -83,6 +83,7 @@ protected: // and no instances should be created from anyone, so i move the constructors // to protected area E3dObject(SdrModel& rSdrModel); + E3dObject(SdrModel& rSdrModel, E3dObject const & rSource); // protected destructor virtual ~E3dObject() override; @@ -125,7 +126,6 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; virtual E3dObject* CloneSdrObject(SdrModel& rTargetModel) const override; - E3dObject& operator=( const E3dObject& rObj ); virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override; virtual void SaveGeoData(SdrObjGeoData& rGeo) const override; @@ -170,6 +170,7 @@ protected: virtual ~E3dCompoundObject() override; public: + E3dCompoundObject(SdrModel& rSdrModel, E3dCompoundObject const & rSource); E3dCompoundObject(SdrModel& rSdrModel); virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; @@ -180,9 +181,6 @@ public: virtual void RecalcSnapRect() override; virtual E3dCompoundObject* CloneSdrObject(SdrModel& rTargetModel) const override; - - // implemented mainly for the purposes of Clone() - E3dCompoundObject& operator=(const E3dCompoundObject& rObj); }; #endif // INCLUDED_SVX_OBJ3D_HXX diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx index 680cd0717d84..bd1c31ea13ca 100644 --- a/include/svx/scene3d.hxx +++ b/include/svx/scene3d.hxx @@ -83,6 +83,7 @@ protected: public: E3dScene(SdrModel& rSdrModel); + E3dScene(SdrModel& rSdrModel, E3dScene const &); virtual void StructureChanged() override; @@ -128,7 +129,6 @@ public: void removeAllNonSelectedObjects(); virtual E3dScene* CloneSdrObject(SdrModel& rTargetModel) const override; - E3dScene& operator=(const E3dScene&); virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override; virtual void SaveGeoData(SdrObjGeoData& rGeo) const override; diff --git a/include/svx/sphere3d.hxx b/include/svx/sphere3d.hxx index 0ee9bc0531b3..4de73c1aa87f 100644 --- a/include/svx/sphere3d.hxx +++ b/include/svx/sphere3d.hxx @@ -57,6 +57,7 @@ public: // when a document with a sphere is loaded. This constructor does not call // CreateSphere, or create any spheres. E3dSphereObj(SdrModel& rSdrModel); + E3dSphereObj(SdrModel& rSdrModel, E3dSphereObj const & rSource); // horizontal segments: sal_uInt32 GetHorizontalSegments() const @@ -71,9 +72,6 @@ public: virtual E3dSphereObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - E3dSphereObj& operator=(const E3dSphereObj& rObj); - const basegfx::B3DPoint& Center() const { return aCenter; } const basegfx::B3DVector& Size() const { return aSize; } diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index e73ecf58ac97..8b12de0d2ec2 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -144,6 +144,7 @@ public: double GetExtraTextRotation( const bool bPreRotation = false ) const; SdrObjCustomShape(SdrModel& rSdrModel); + SdrObjCustomShape(SdrModel& rSdrModel, SdrObjCustomShape const & rSource); /* is merging default attributes from type-shape into the SdrCustomShapeGeometryItem. If pType is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem. @@ -211,7 +212,6 @@ public: virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override; virtual SdrObjCustomShape* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrObjCustomShape& operator=(const SdrObjCustomShape& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdoattr.hxx b/include/svx/svdoattr.hxx index 4c5dab883e4f..2505811d2948 100644 --- a/include/svx/svdoattr.hxx +++ b/include/svx/svdoattr.hxx @@ -49,13 +49,11 @@ protected: virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; SdrAttrObj(SdrModel& rSdrModel); + // Copy constructor + SdrAttrObj(SdrModel& rSdrModel, SdrAttrObj const &); virtual ~SdrAttrObj() override; public: - SdrAttrObj(SdrAttrObj const &) = delete; // due to SdrObject - SdrAttrObj(SdrAttrObj &&) = delete; // due to SdrObject - SdrAttrObj & operator =(SdrAttrObj const &) = default; - SdrAttrObj & operator =(SdrAttrObj &&) = default; // Detects if bFilledObj && Fill != FillNone bool HasFill() const; diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index bf70559ebdf4..f38f201621e7 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -291,6 +291,8 @@ private: public: // A SdrObject always needs a SdrModel for lifetime (Pool, ...) SdrObject(SdrModel& rSdrModel); + // Copy constructor + SdrObject(SdrModel& rSdrModel, SdrObject const & rSource); // SdrModel/SdrPage access on SdrObject level SdrPage* getSdrPageFromSdrObject() const; @@ -441,13 +443,12 @@ public: // means no change of the rotation point (only centered) and no shear allowed virtual bool HasLimitedRotation() const; - // Returns a copy of the object. Every inherited class must reimplement this (in class Foo - // it should be sufficient to do "virtual Foo* CloneSdrObject(...) const { return CloneHelper< Foo >(); }". - // Note that this function uses operator= internally. + // Returns a copy of the object. Every inherited class must reimplement this. virtual SdrObject* CloneSdrObject(SdrModel& rTargetModel) const; - // implemented mainly for the purposes of CloneSdrObject() - SdrObject& operator=(const SdrObject& rObj); + // Overwriting this object makes no sense, it is too complicated for that + SdrObject& operator=(const SdrObject& rObj) = delete; + SdrObject& operator=(SdrObject&& rObj) = delete; // TakeObjName...() is for the display in the UI, e.g. "3 frames selected" virtual OUString TakeObjNameSingul() const; @@ -944,9 +945,6 @@ protected: /// class (preferably as the first step)! virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& _rxUnoShape ); - // helper function for reimplementing Clone(). - template< typename T > T* CloneHelper(SdrModel& rTargetModel) const; - const SfxItemSet* getBackgroundFillSet() const; private: @@ -1030,22 +1028,4 @@ private: SdrObjFactory() = delete; }; -template< typename T > T* SdrObject::CloneHelper(SdrModel& rTargetModel) const -{ - OSL_ASSERT( typeid( T ) == typeid( *this )); - T* pObj = dynamic_cast< T* >( - SdrObjFactory::MakeNewObject( - rTargetModel, - GetObjInventor(), - GetObjIdentifier())); - - if(nullptr != pObj) - { - // use ::operator=() - *pObj = *static_cast< const T* >( this ); - } - - return pObj; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx index ee856c32364a..0b2563878384 100644 --- a/include/svx/svdocapt.hxx +++ b/include/svx/svdocapt.hxx @@ -74,6 +74,8 @@ private: public: SdrCaptionObj(SdrModel& rSdrModel); + // Copy constructor + SdrCaptionObj(SdrModel& rSdrModel, SdrCaptionObj const & rSource); SdrCaptionObj( SdrModel& rSdrModel, const tools::Rectangle& rRect, @@ -86,9 +88,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual SdrCaptionObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - SdrCaptionObj& operator=(const SdrCaptionObj& rObj); - // for calc: special shadow only for text box void SetSpecialTextBoxShadow() { mbSpecialTextBoxShadow = true; } bool GetSpecialTextBoxShadow() const { return mbSpecialTextBoxShadow; } diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx index cd573323a94d..81687cc0bfe2 100644 --- a/include/svx/svdocirc.hxx +++ b/include/svx/svdocirc.hxx @@ -77,6 +77,8 @@ public: SdrModel& rSdrModel, SdrCircKind eNewKind, const tools::Rectangle& rRect); + // Copy constructor + SdrCircObj(SdrModel& rSdrModel, SdrCircObj const & rSource); // 0=0.00Deg=3h 9000=90.00Deg=12h 18000=180.00Deg=9h 27000=270.00Deg=6h // The circle is build up from StartAngle to EndWink anti-clockwise. @@ -100,9 +102,6 @@ public: virtual SdrCircObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - SdrCircObj& operator=(const SdrCircObj& rObj); - virtual void RecalcSnapRect() override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx index b19c5514429b..18842c0620e5 100644 --- a/include/svx/svdoedge.hxx +++ b/include/svx/svdoedge.hxx @@ -190,6 +190,8 @@ protected: public: SdrEdgeObj(SdrModel& rSdrModel); + // Copy constructor + SdrEdgeObj(SdrModel& rSdrModel, SdrEdgeObj const & rSource); // react on model/page change virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override; @@ -217,7 +219,6 @@ public: virtual void RecalcSnapRect() override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; virtual SdrEdgeObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrEdgeObj& operator=(const SdrEdgeObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 9a6d06267aa5..88ebc776537b 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -125,6 +125,8 @@ protected: public: SdrGrafObj(SdrModel& rSdrModel); + // Copy constructor + SdrGrafObj(SdrModel& rSdrModel, SdrGrafObj const & rSource); SdrGrafObj( SdrModel& rSdrModel, const Graphic& rGrf); @@ -177,7 +179,6 @@ public: virtual OUString TakeObjNamePlural() const override; virtual SdrGrafObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrGrafObj& operator=(const SdrGrafObj& rObj); virtual sal_uInt32 GetHdlCount() const override; virtual void AddToHdlList(SdrHdlList& rHdlList) const override; diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx index 2083c8839438..3eef83bbd3ac 100644 --- a/include/svx/svdogrp.hxx +++ b/include/svx/svdogrp.hxx @@ -44,6 +44,8 @@ private: public: SdrObjGroup(SdrModel& rSdrModel); + // Copy constructor + SdrObjGroup(SdrModel& rSdrModel, SdrObjGroup const& rSource); // derived from SdrObjList virtual SdrPage* getSdrPageFromSdrObjList() const override; @@ -67,7 +69,6 @@ public: virtual const tools::Rectangle& GetSnapRect() const override; virtual SdrObjGroup* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrObjGroup& operator=(const SdrObjGroup& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index 599104e937b8..b3dc1cd56666 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -77,6 +77,8 @@ protected: public: SdrMeasureObj(SdrModel& rSdrModel); + // Copy constructor + SdrMeasureObj(SdrModel& rSdrModel, SdrMeasureObj const & rSource); SdrMeasureObj( SdrModel& rSdrModel, const Point& rPt1, @@ -87,9 +89,6 @@ public: virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; virtual SdrMeasureObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - SdrMeasureObj& operator=(const SdrMeasureObj& rObj); - virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx index 9eab605e8ef4..bc80acfff76c 100644 --- a/include/svx/svdomedia.hxx +++ b/include/svx/svdomedia.hxx @@ -41,6 +41,8 @@ private: public: SdrMediaObj(SdrModel& rSdrModel); + // Copy constructor + SdrMediaObj(SdrModel& rSdrModel, SdrMediaObj const & rSource); SdrMediaObj( SdrModel& rSdrModel, const tools::Rectangle& rRect); @@ -54,7 +56,6 @@ public: virtual OUString TakeObjNamePlural() const override; virtual SdrMediaObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrMediaObj& operator=(const SdrMediaObj& rObj); virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override; diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx index 8c209ce7f281..5b08652e3e40 100644 --- a/include/svx/svdoole2.hxx +++ b/include/svx/svdoole2.hxx @@ -74,6 +74,8 @@ public: SdrOle2Obj( SdrModel& rSdrModel, bool bFrame_ = false); + // Copy constructor + SdrOle2Obj(SdrModel& rSdrModel, SdrOle2Obj const & rSource); SdrOle2Obj( SdrModel& rSdrModel, const svt::EmbeddedObjectRef& rNewObjRef, @@ -140,9 +142,6 @@ public: virtual SdrOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrOle2Obj& assignFrom(const SdrOle2Obj& rObj); - SdrOle2Obj& operator=(const SdrOle2Obj& rObj); - virtual void NbcMove(const Size& rSize) override; virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx index 601b86d5480c..c5e700ad9acd 100644 --- a/include/svx/svdopage.hxx +++ b/include/svx/svdopage.hxx @@ -46,6 +46,8 @@ public: SdrPageObj( SdrModel& rSdrModel, SdrPage* pNewPage = nullptr); + // Copy constructor + SdrPageObj(SdrModel& rSdrModel, SdrPageObj const & rSource); SdrPageObj( SdrModel& rSdrModel, const tools::Rectangle& rRect, @@ -60,7 +62,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual SdrPageObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrPageObj& operator=(const SdrPageObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx index f8360d178f71..b825f1413630 100644 --- a/include/svx/svdopath.hxx +++ b/include/svx/svdopath.hxx @@ -67,6 +67,8 @@ public: SdrPathObj( SdrModel& rSdrModel, SdrObjKind eNewKind); + // Copy constructor + SdrPathObj(SdrModel& rSdrModel, SdrPathObj const & rSource); SdrPathObj( SdrModel& rSdrModel, SdrObjKind eNewKind, @@ -76,7 +78,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; virtual SdrPathObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrPathObj& operator=(const SdrPathObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx index 930fb01ff626..65671216da41 100644 --- a/include/svx/svdorect.hxx +++ b/include/svx/svdorect.hxx @@ -74,8 +74,6 @@ public: SdrModel& rSdrModel, const tools::Rectangle& rRect); - SdrRectObj& operator=(const SdrRectObj& rCopy); - // Constructor of a text frame SdrRectObj( SdrModel& rSdrModel, @@ -85,6 +83,9 @@ public: SdrObjKind eNewTextKind, const tools::Rectangle& rRect); + // Copy constructor + SdrRectObj(SdrModel& rSdrModel, SdrRectObj const & rSource); + virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual SdrObjKind GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index 2f0b284d4394..ef52185b8116 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -101,6 +101,8 @@ class SVXCORE_DLLPUBLIC SdrTableObj final : public ::SdrTextObj public: SdrTableObj(SdrModel& rSdrModel); + // Copy constructor + SdrTableObj(SdrModel& rSdrModel, SdrTableObj const & rSource); SdrTableObj( SdrModel& rSdrModel, const ::tools::Rectangle& rNewRect, @@ -204,7 +206,6 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; virtual SdrTableObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrTableObj& operator=(const SdrTableObj& rObj); virtual void RecalcSnapRect() override; virtual const tools::Rectangle& GetSnapRect() const override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index ed9cd61ad1f8..72ebffcbc5e3 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -315,6 +315,9 @@ protected: SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect); + // copy constructor + SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource); + // protected destructor virtual ~SdrTextObj() override; @@ -447,7 +450,6 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; virtual SdrTextObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrTextObj& operator=(const SdrTextObj& rObj); virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; virtual basegfx::B2DPolyPolygon TakeContour() const override; virtual void RecalcSnapRect() override; diff --git a/include/svx/svdouno.hxx b/include/svx/svdouno.hxx index 3796b086c8b9..c416439ecb5d 100644 --- a/include/svx/svdouno.hxx +++ b/include/svx/svdouno.hxx @@ -67,6 +67,8 @@ public: explicit SdrUnoObj( SdrModel& rSdrModel, const OUString& rModelName); + // Copy constructor + SdrUnoObj(SdrModel& rSdrModel, SdrUnoObj const & rSource); SdrUnoObj( SdrModel& rSdrModel, const OUString& rModelName, @@ -76,7 +78,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual SdrUnoObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrUnoObj& operator= (const SdrUnoObj& rObj); virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; virtual void NbcSetLayer(SdrLayerID nLayer) override; @@ -122,6 +123,7 @@ public: ) const; const OUString& GetUnoControlTypeName() const { return aUnoControlTypeName; } + const OUString& getUnoControlModelTypeName() const { return aUnoControlModelTypeName; } virtual void SetUnoControlModel( const css::uno::Reference< css::awt::XControlModel >& xModel ); diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx index eade82c13c42..420fb6caed26 100644 --- a/include/svx/svdovirt.hxx +++ b/include/svx/svdovirt.hxx @@ -52,6 +52,8 @@ protected: public: SdrVirtObj(SdrModel& rSdrModel, SdrObject& rNewObj); + // Copy constructor + SdrVirtObj(SdrModel& rSdrModel, SdrVirtObj const& rSource); SdrObject& ReferencedObj(); const SdrObject& GetReferencedObj() const; @@ -66,7 +68,6 @@ public: virtual const tools::Rectangle& GetLastBoundRect() const override; virtual void RecalcBoundRect() override; virtual SdrVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SdrVirtObj& operator=(const SdrVirtObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx index fa2c7c3890ed..fe8b49d08738 100644 --- a/reportdesign/inc/RptObject.hxx +++ b/reportdesign/inc/RptObject.hxx @@ -190,8 +190,6 @@ public: virtual OOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override; virtual void initializeOle() override; - OOle2Obj& operator=(const OOle2Obj& rObj); - void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel); private: @@ -203,6 +201,8 @@ private: SdrModel& rSdrModel, const OUString& _sComponentName, SdrObjKind _nType); + // copy constructor + OOle2Obj(SdrModel& rSdrModel, const OOle2Obj& rSource); virtual void NbcMove( const Size& rSize ) override; virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; @@ -241,6 +241,8 @@ protected: const css::uno::Reference< css::report::XReportComponent>& _xComponent, const OUString& rModelName, SdrObjKind _nObjectType); + // copy constructor + OUnoObject(SdrModel& rSdrModel, OUnoObject const & rSource); // protected destructor virtual ~OUnoObject() override; @@ -270,8 +272,6 @@ public: virtual SdrInventor GetObjInventor() const override; virtual OUnoObject* CloneSdrObject(SdrModel& rTargetModel) const override; - OUnoObject& operator=(const OUnoObject& rObj); - private: virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override; void impl_initializeModel_nothrow(); diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index b83f742676c6..21395b7c5da7 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -586,6 +586,22 @@ OUnoObject::OUnoObject( } OUnoObject::OUnoObject( + SdrModel& rSdrModel, OUnoObject const & rSource) +: SdrUnoObj(rSdrModel, rSource.getUnoControlModelTypeName()) + ,OObjectBase(rSource.getServiceName()) + ,m_nObjectType(rSource.m_nObjectType) + // tdf#119067 + ,m_bSetDefaultLabel(rSource.m_bSetDefaultLabel) +{ + if ( !rSource.getUnoControlModelTypeName().isEmpty() ) + impl_initializeModel_nothrow(); + Reference<XPropertySet> xSource(const_cast<OUnoObject&>(rSource).getUnoShape(), uno::UNO_QUERY); + Reference<XPropertySet> xDest(getUnoShape(), uno::UNO_QUERY); + if ( xSource.is() && xDest.is() ) + comphelper::copyProperties(xSource.get(), xDest.get()); +} + +OUnoObject::OUnoObject( SdrModel& rSdrModel, const uno::Reference< report::XReportComponent>& _xComponent, const OUString& rModelName, @@ -886,21 +902,7 @@ void OUnoObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUn OUnoObject* OUnoObject::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< OUnoObject >(rTargetModel); -} - -OUnoObject& OUnoObject::operator=(const OUnoObject& rObj) -{ - if( this == &rObj ) - return *this; - SdrUnoObj::operator=(rObj); - - Reference<XPropertySet> xSource(const_cast<OUnoObject&>(rObj).getUnoShape(), uno::UNO_QUERY); - Reference<XPropertySet> xDest(getUnoShape(), uno::UNO_QUERY); - if ( xSource.is() && xDest.is() ) - comphelper::copyProperties(xSource.get(), xDest.get()); - - return *this; + return new OUnoObject(rTargetModel, *this); } // OOle2Obj @@ -929,6 +931,28 @@ OOle2Obj::OOle2Obj( m_bIsListening = true; } +static uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const uno::Reference < embed::XEmbeddedObject >& _xObj); + +OOle2Obj::OOle2Obj(SdrModel& rSdrModel, OOle2Obj const & rSource) +: SdrOle2Obj(rSdrModel, rSource) + ,OObjectBase(rSource.getServiceName()) + ,m_nType(rSource.m_nType) + ,m_bOnlyOnce(rSource.m_bOnlyOnce) +{ + m_bIsListening = true; + + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + svt::EmbeddedObjectRef::TryRunningState( GetObjRef() ); + impl_createDataProvider_nothrow(rRptModel.getReportDefinition().get()); + + uno::Reference< chart2::data::XDatabaseDataProvider > xSource( lcl_getDataProvider(rSource.GetObjRef()) ); + uno::Reference< chart2::data::XDatabaseDataProvider > xDest( lcl_getDataProvider(GetObjRef()) ); + if ( xSource.is() && xDest.is() ) + comphelper::copyProperties(xSource.get(),xDest.get()); + + initializeChart(rRptModel.getReportDefinition().get()); +} + OOle2Obj::~OOle2Obj() { } @@ -1092,27 +1116,7 @@ static uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider // Clone() should make a complete copy of the object. OOle2Obj* OOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< OOle2Obj >(rTargetModel); -} - -OOle2Obj& OOle2Obj::operator=(const OOle2Obj& rObj) -{ - if( this == &rObj ) - return *this; - SdrOle2Obj::operator=(rObj); - - OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); - svt::EmbeddedObjectRef::TryRunningState( GetObjRef() ); - impl_createDataProvider_nothrow(rRptModel.getReportDefinition().get()); - - uno::Reference< chart2::data::XDatabaseDataProvider > xSource( lcl_getDataProvider(rObj.GetObjRef()) ); - uno::Reference< chart2::data::XDatabaseDataProvider > xDest( lcl_getDataProvider(GetObjRef()) ); - if ( xSource.is() && xDest.is() ) - comphelper::copyProperties(xSource.get(),xDest.get()); - - initializeChart(rRptModel.getReportDefinition().get()); - - return *this; + return new OOle2Obj(rTargetModel, *this); } void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XModel>& _xModel) diff --git a/svx/inc/extrud3d.hxx b/svx/inc/extrud3d.hxx index 6836359a6ab5..1b0e5a248171 100644 --- a/svx/inc/extrud3d.hxx +++ b/svx/inc/extrud3d.hxx @@ -58,6 +58,7 @@ public: const E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth); + E3dExtrudeObj(SdrModel& rSdrModel, E3dExtrudeObj const & rSource); E3dExtrudeObj(SdrModel& rSdrModel); // PercentDiagonal: 0..100, before 0.0..0.5 @@ -96,9 +97,6 @@ public: virtual E3dExtrudeObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - E3dExtrudeObj& operator=(const E3dExtrudeObj& rObj); - // TakeObjName...() is for the display in the UI (for example "3 frames selected") virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/svx/inc/polygn3d.hxx b/svx/inc/polygn3d.hxx index 2665efdffcb8..5a4a234eb191 100644 --- a/svx/inc/polygn3d.hxx +++ b/svx/inc/polygn3d.hxx @@ -46,6 +46,7 @@ public: E3dPolygonObj(SdrModel& rSdrModel, const basegfx::B3DPolyPolygon& rPolyPoly3D); E3dPolygonObj(SdrModel& rSdrModel); + E3dPolygonObj(SdrModel& rSdrModel, E3dPolygonObj const& rSource); const basegfx::B3DPolyPolygon& GetPolyPolygon3D() const { return aPolyPoly3D; } const basegfx::B3DPolyPolygon& GetPolyNormals3D() const { return aPolyNormals3D; } @@ -56,9 +57,6 @@ public: virtual E3dPolygonObj* CloneSdrObject(SdrModel& rTargetModel) const override; - // implemented mainly for the purposes of Clone() - E3dPolygonObj& operator=(const E3dPolygonObj& rObj); - // LineOnly? bool GetLineOnly() const { return bLineOnly; } void SetLineOnly(bool bNew); diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx index 9ee267afb061..39542232f33f 100644 --- a/svx/source/engine3d/cube3d.cxx +++ b/svx/source/engine3d/cube3d.cxx @@ -60,6 +60,19 @@ E3dCubeObj::E3dCubeObj(SdrModel& rSdrModel) SetDefaultAttributes(aDefault); } +E3dCubeObj::E3dCubeObj(SdrModel& rSdrModel, E3dCubeObj const & rSource) +: E3dCompoundObject(rSdrModel, rSource) +{ + // Set Defaults + const E3dDefaultAttributes aDefault; + + SetDefaultAttributes(aDefault); + + aCubePos = rSource.aCubePos; + aCubeSize = rSource.aCubeSize; + bPosIsCenter = rSource.bPosIsCenter; +} + E3dCubeObj::~E3dCubeObj() { } @@ -85,20 +98,7 @@ SdrObjectUniquePtr E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddT E3dCubeObj* E3dCubeObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< E3dCubeObj >(rTargetModel); -} - -E3dCubeObj& E3dCubeObj::operator=(const E3dCubeObj& rObj) -{ - if( this == &rObj ) - return *this; - E3dCompoundObject::operator=(rObj); - - aCubePos = rObj.aCubePos; - aCubeSize = rObj.aCubeSize; - bPosIsCenter = rObj.bPosIsCenter; - - return *this; + return new E3dCubeObj(rTargetModel, *this); } // Set local parameters with geometry re-creating diff --git a/svx/source/engine3d/extrud3d.cxx b/svx/source/engine3d/extrud3d.cxx index 4a6d73419a6f..605851d90476 100644 --- a/svx/source/engine3d/extrud3d.cxx +++ b/svx/source/engine3d/extrud3d.cxx @@ -79,6 +79,17 @@ E3dExtrudeObj::E3dExtrudeObj(SdrModel& rSdrModel) SetDefaultAttributes(aDefault); } +E3dExtrudeObj::E3dExtrudeObj(SdrModel& rSdrModel, E3dExtrudeObj const & rSource) +: E3dCompoundObject(rSdrModel, rSource) +{ + // Set Defaults + const E3dDefaultAttributes aDefault; + + SetDefaultAttributes(aDefault); + + maExtrudePolygon = rSource.maExtrudePolygon; +} + E3dExtrudeObj::~E3dExtrudeObj() { } @@ -103,18 +114,7 @@ SdrObjKind E3dExtrudeObj::GetObjIdentifier() const E3dExtrudeObj* E3dExtrudeObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< E3dExtrudeObj >(rTargetModel); -} - -E3dExtrudeObj& E3dExtrudeObj::operator=(const E3dExtrudeObj& rObj) -{ - if( this == &rObj ) - return *this; - E3dCompoundObject::operator=(rObj); - - maExtrudePolygon = rObj.maExtrudePolygon; - - return *this; + return new E3dExtrudeObj(rTargetModel, *this); } // Set local parameters with geometry re-creating diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx index ebb04d5aaef5..ef80d9379202 100644 --- a/svx/source/engine3d/lathe3d.cxx +++ b/svx/source/engine3d/lathe3d.cxx @@ -88,6 +88,17 @@ E3dLatheObj::E3dLatheObj(SdrModel& rSdrModel) SetDefaultAttributes(aDefault); } +E3dLatheObj::E3dLatheObj(SdrModel& rSdrModel, E3dLatheObj const & rSource) +: E3dCompoundObject(rSdrModel, rSource) +{ + // Set Defaults + const E3dDefaultAttributes aDefault; + + SetDefaultAttributes(aDefault); + + maPolyPoly2D = rSource.maPolyPoly2D; +} + E3dLatheObj::~E3dLatheObj() { } @@ -108,18 +119,7 @@ SdrObjKind E3dLatheObj::GetObjIdentifier() const E3dLatheObj* E3dLatheObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< E3dLatheObj >(rTargetModel); -} - -E3dLatheObj& E3dLatheObj::operator=(const E3dLatheObj& rObj) -{ - if( this == &rObj ) - return *this; - E3dCompoundObject::operator=(rObj); - - maPolyPoly2D = rObj.maPolyPoly2D; - - return *this; + return new E3dLatheObj(rTargetModel, *this); } // Convert the object to group object consisting of n polygons diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index b5e679ab09fc..0cc2ac83df20 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -60,6 +60,29 @@ E3dObject::E3dObject(SdrModel& rSdrModel) bClosedObj = true; } +E3dObject::E3dObject(SdrModel& rSdrModel, E3dObject const & rSource) +: SdrAttrObj(rSdrModel, rSource), + maLocalBoundVol(), + maTransformation(), + maFullTransform(), + mbTfHasChanged(true), + mbIsSelected(false) +{ + bIs3DObj = true; + bClosedObj = true; + + // BoundVol can be copied since also the children are copied + maLocalBoundVol = rSource.maLocalBoundVol; + maTransformation = rSource.maTransformation; + + // Because the parent may have changed, definitely redefine the total + // transformation next time + SetTransformChanged(); + + // Copy selection status + mbIsSelected = rSource.mbIsSelected; +} + E3dObject::~E3dObject() { } @@ -382,29 +405,7 @@ OUString E3dObject::TakeObjNamePlural() const E3dObject* E3dObject::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< E3dObject >(rTargetModel); -} - -E3dObject& E3dObject::operator=(const E3dObject& rSource) -{ - if(this != &rSource) - { - // call parent - SdrAttrObj::operator=(rSource); - - // BoundVol can be copied since also the children are copied - maLocalBoundVol = rSource.maLocalBoundVol; - maTransformation = rSource.maTransformation; - - // Because the parent may have changed, definitely redefine the total - // transformation next time - SetTransformChanged(); - - // Copy selection status - mbIsSelected = rSource.mbIsSelected; - } - - return *this; + return new E3dObject(rTargetModel, *this); } std::unique_ptr<SdrObjGeoData> E3dObject::NewGeoData() const @@ -461,6 +462,11 @@ E3dCompoundObject::E3dCompoundObject(SdrModel& rSdrModel) { } +E3dCompoundObject::E3dCompoundObject(SdrModel& rSdrModel, E3dCompoundObject const & rSource) +: E3dObject(rSdrModel, rSource) +{ +} + E3dCompoundObject::~E3dCompoundObject () { } @@ -592,15 +598,7 @@ void E3dCompoundObject::RecalcSnapRect() E3dCompoundObject* E3dCompoundObject::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< E3dCompoundObject >(rTargetModel); -} - -E3dCompoundObject& E3dCompoundObject::operator=(const E3dCompoundObject& rObj) -{ - if( this == &rObj ) - return *this; - E3dObject::operator=(rObj); - return *this; + return new E3dCompoundObject(rTargetModel, *this); } // convert given basegfx::B3DPolyPolygon to screen coor diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx index 2a14e7efdd2f..22aecb44105a 100644 --- a/svx/source/engine3d/polygn3d.cxx +++ b/svx/source/engine3d/polygn3d.cxx @@ -51,6 +51,18 @@ E3dPolygonObj::E3dPolygonObj(SdrModel& rSdrModel) // Create no geometry } +E3dPolygonObj::E3dPolygonObj(SdrModel& rSdrModel, E3dPolygonObj const& rSource) + : E3dCompoundObject(rSdrModel, rSource) + , bLineOnly(false) +{ + // Create no geometry + + aPolyPoly3D = rSource.aPolyPoly3D; + aPolyNormals3D = rSource.aPolyNormals3D; + aPolyTexture2D = rSource.aPolyTexture2D; + bLineOnly = rSource.bLineOnly; +} + void E3dPolygonObj::CreateDefaultNormals() { basegfx::B3DPolyPolygon aPolyNormals; @@ -212,21 +224,7 @@ SdrObjectUniquePtr E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bA E3dPolygonObj* E3dPolygonObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper<E3dPolygonObj>(rTargetModel); -} - -E3dPolygonObj& E3dPolygonObj::operator=(const E3dPolygonObj& rObj) -{ - if (this == &rObj) - return *this; - E3dCompoundObject::operator=(rObj); - - aPolyPoly3D = rObj.aPolyPoly3D; - aPolyNormals3D = rObj.aPolyNormals3D; - aPolyTexture2D = rObj.aPolyTexture2D; - bLineOnly = rObj.bLineOnly; - - return *this; + return new E3dPolygonObj(rTargetModel, *this); } void E3dPolygonObj::SetLineOnly(bool bNew) diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx index a71f74f0784f..799157460817 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -178,6 +178,37 @@ E3dScene::E3dScene(SdrModel& rSdrModel) SetDefaultAttributes(); } +E3dScene::E3dScene(SdrModel& rSdrModel, E3dScene const & rSource) +: E3dObject(rSdrModel, rSource), + SdrObjList(), + aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()), + bDrawOnlySelected(false), + mbSkipSettingDirty(false) +{ + // Set defaults + SetDefaultAttributes(); + + // copy child SdrObjects + if (rSource.GetSubList()) + { + CopyObjects(*rSource.GetSubList()); + + // tdf#116979: needed here, we need bSnapRectDirty to be true + // which it is after using SdrObject::operator= (see above), + // but set to false again using CopyObjects + SetRectsDirty(); + } + + // copy local data + aCamera = rSource.aCamera; + aCameraSet = rSource.aCameraSet; + static_cast<sdr::properties::E3dSceneProperties&>(GetProperties()).SetSceneItemsFromCamera(); + InvalidateBoundVolume(); + RebuildLists(); + ImpCleanup3DDepthMapper(); + GetViewContact().ActionChanged(); +} + void E3dScene::SetDefaultAttributes() { // For WIN95/NT turn off the FP-Exceptions @@ -415,38 +446,7 @@ void E3dScene::removeAllNonSelectedObjects() E3dScene* E3dScene::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< E3dScene >(rTargetModel); -} - -E3dScene& E3dScene::operator=(const E3dScene& rSource) -{ - if(this != &rSource) - { - // call parent - E3dObject::operator=(rSource); - - // copy child SdrObjects - if (rSource.GetSubList()) - { - CopyObjects(*rSource.GetSubList()); - - // tdf#116979: needed here, we need bSnapRectDirty to be true - // which it is after using SdrObject::operator= (see above), - // but set to false again using CopyObjects - SetRectsDirty(); - } - - // copy local data - aCamera = rSource.aCamera; - aCameraSet = rSource.aCameraSet; - static_cast<sdr::properties::E3dSceneProperties&>(GetProperties()).SetSceneItemsFromCamera(); - InvalidateBoundVolume(); - RebuildLists(); - ImpCleanup3DDepthMapper(); - GetViewContact().ActionChanged(); - } - - return *this; + return new E3dScene(rTargetModel, *this); } void E3dScene::SuspendReportingDirtyRects() diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx index 5749be7696e6..b36e5248faa1 100644 --- a/svx/source/engine3d/sphere3d.cxx +++ b/svx/source/engine3d/sphere3d.cxx @@ -66,6 +66,17 @@ E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel) SetDefaultAttributes(aDefault); } +E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel, E3dSphereObj const & rSource) +: E3dCompoundObject(rSdrModel, rSource) +{ + // Set defaults + const E3dDefaultAttributes aDefault; + SetDefaultAttributes(aDefault); + + aCenter = rSource.aCenter; + aSize = rSource.aSize; +} + E3dSphereObj::~E3dSphereObj() { } @@ -91,19 +102,7 @@ SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAd E3dSphereObj* E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< E3dSphereObj >(rTargetModel); -} - -E3dSphereObj& E3dSphereObj::operator=(const E3dSphereObj& rObj) -{ - if( this == &rObj ) - return *this; - E3dCompoundObject::operator=(rObj); - - aCenter = rObj.aCenter; - aSize = rObj.aSize; - - return *this; + return new E3dSphereObj(rTargetModel, *this); } // Set local parameters with geometry re-creating diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index 1d7a70623f95..620599a25f0d 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -71,6 +71,44 @@ FmFormObj::FmFormObj(SdrModel& rSdrModel) impl_checkRefDevice_nothrow(); } +FmFormObj::FmFormObj(SdrModel& rSdrModel, FmFormObj const & rSource) +: SdrUnoObj(rSdrModel, rSource) + ,m_nPos(-1) + ,m_pLastKnownRefDevice(nullptr) +{ + // Stuff that old SetModel also did: + impl_checkRefDevice_nothrow(); + + // If UnoControlModel is part of an event environment, + // events may assigned to it. + Reference< XFormComponent > xContent(rSource.xUnoControlModel, UNO_QUERY); + if (xContent.is()) + { + Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY); + Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY); + if (xManagerAsIndex.is()) + { + sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent ); + if ( nPos >= 0 ) + aEvts = xManager->getScriptEvents( nPos ); + } + } + else + aEvts = rSource.aEvts; + + Reference< XChild > xSourceAsChild(rSource.GetUnoControlModel(), UNO_QUERY); + if (!xSourceAsChild.is()) + return; + + Reference< XInterface > xSourceContainer = xSourceAsChild->getParent(); + + m_xEnvironmentHistory = css::form::Forms::create( comphelper::getProcessComponentContext() ); + + ensureModelEnv(xSourceContainer, m_xEnvironmentHistory); + m_aEventsHistory = aEvts; + // if we were clone there was a call to operator=, so aEvts are exactly the events we need here... +} + FmFormObj::~FmFormObj() { @@ -322,66 +360,11 @@ SdrObjKind FmFormObj::GetObjIdentifier() const return OBJ_UNO; } -void FmFormObj::clonedFrom(const FmFormObj* _pSource) -{ - DBG_ASSERT(_pSource != nullptr, "FmFormObj::clonedFrom : invalid source !"); - if (m_xEnvironmentHistory.is()) - m_xEnvironmentHistory->dispose(); - - m_xEnvironmentHistory = nullptr; - m_aEventsHistory.realloc(0); - - Reference< XChild > xSourceAsChild(_pSource->GetUnoControlModel(), UNO_QUERY); - if (!xSourceAsChild.is()) - return; - - Reference< XInterface > xSourceContainer = xSourceAsChild->getParent(); - - m_xEnvironmentHistory = css::form::Forms::create( comphelper::getProcessComponentContext() ); - - ensureModelEnv(xSourceContainer, m_xEnvironmentHistory); - m_aEventsHistory = aEvts; - // if we were clone there was a call to operator=, so aEvts are exactly the events we need here... -} - - FmFormObj* FmFormObj::CloneSdrObject(SdrModel& rTargetModel) const { - FmFormObj* pFormObject = CloneHelper< FmFormObj >(rTargetModel); - DBG_ASSERT(pFormObject != nullptr, "FmFormObj::Clone : invalid clone !"); - if (pFormObject) - pFormObject->clonedFrom(this); - - return pFormObject; + return new FmFormObj(rTargetModel, *this); } - -FmFormObj& FmFormObj::operator= (const FmFormObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrUnoObj::operator= (rObj); - - // If UnoControlModel is part of an event environment, - // events may assigned to it. - Reference< XFormComponent > xContent(rObj.xUnoControlModel, UNO_QUERY); - if (xContent.is()) - { - Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY); - Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY); - if (xManagerAsIndex.is()) - { - sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent ); - if ( nPos >= 0 ) - aEvts = xManager->getScriptEvents( nPos ); - } - } - else - aEvts = rObj.aEvts; - return *this; -} - - void FmFormObj::NbcReformatText() { impl_checkRefDevice_nothrow(); diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx index d53ec819a808..6e6b2d0edb4f 100644 --- a/svx/source/inc/fmobj.hxx +++ b/svx/source/inc/fmobj.hxx @@ -56,6 +56,8 @@ public: SdrModel& rSdrModel, const OUString& rModelName); FmFormObj(SdrModel& rSdrModel); + // Copy constructor + FmFormObj(SdrModel& rSdrModel, FmFormObj const & rSource); SAL_DLLPRIVATE const css::uno::Reference< css::container::XIndexContainer>& GetOriginalParent() const { return m_xParent; } @@ -79,9 +81,6 @@ public: SAL_DLLPRIVATE virtual void NbcReformatText() override; SAL_DLLPRIVATE virtual FmFormObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SAL_DLLPRIVATE FmFormObj& operator= (const FmFormObj& rObj); - - SAL_DLLPRIVATE void clonedFrom(const FmFormObj* _pSource); SAL_DLLPRIVATE static css::uno::Reference< css::uno::XInterface> ensureModelEnv( const css::uno::Reference< css::uno::XInterface>& _rSourceContainer, diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 2ddd696749af..01be2eae9798 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -795,6 +795,21 @@ SdrObjCustomShape::SdrObjCustomShape(SdrModel& rSdrModel) bTextFrame = true; } +SdrObjCustomShape::SdrObjCustomShape(SdrModel& rSdrModel, SdrObjCustomShape const & rSource) +: SdrTextObj(rSdrModel, rSource) + , fObjectRotation(0.0) + , mbAdjustingTextFrameWidthAndHeight(false) + , mpLastShadowGeometry(nullptr) +{ + bClosedObj = true; // custom shapes may be filled + bTextFrame = true; + + fObjectRotation = rSource.fObjectRotation; + mbAdjustingTextFrameWidthAndHeight = rSource.mbAdjustingTextFrameWidthAndHeight; + assert(!mbAdjustingTextFrameWidthAndHeight); + InvalidateRenderGeometry(); +} + SdrObjCustomShape::~SdrObjCustomShape() { // delete buffered display geometry @@ -2761,22 +2776,9 @@ void SdrObjCustomShape::NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObj SdrObjCustomShape* SdrObjCustomShape::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrObjCustomShape >(rTargetModel); -} - -SdrObjCustomShape& SdrObjCustomShape::operator=(const SdrObjCustomShape& rObj) -{ - if( this == &rObj ) - return *this; - SdrTextObj::operator=( rObj ); - fObjectRotation = rObj.fObjectRotation; - mbAdjustingTextFrameWidthAndHeight = rObj.mbAdjustingTextFrameWidthAndHeight; - assert(!mbAdjustingTextFrameWidthAndHeight); - InvalidateRenderGeometry(); - return *this; + return new SdrObjCustomShape(rTargetModel, *this); } - OUString SdrObjCustomShape::TakeObjNameSingul() const { OUStringBuffer sName(SvxResId(STR_ObjNameSingulCUSTOMSHAPE)); diff --git a/svx/source/svdraw/svdoattr.cxx b/svx/source/svdraw/svdoattr.cxx index 3fc45abff2f4..91c3c8de8324 100644 --- a/svx/source/svdraw/svdoattr.cxx +++ b/svx/source/svdraw/svdoattr.cxx @@ -39,6 +39,11 @@ SdrAttrObj::SdrAttrObj(SdrModel& rSdrModel) { } +SdrAttrObj::SdrAttrObj(SdrModel& rSdrModel, SdrAttrObj const& rSource) + : SdrObject(rSdrModel, rSource) +{ +} + SdrAttrObj::~SdrAttrObj() {} const tools::Rectangle& SdrAttrObj::GetSnapRect() const diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 9bfdee8d4866..986b390301ce 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -366,6 +366,77 @@ SdrObject::SdrObject(SdrModel& rSdrModel) #endif } +SdrObject::SdrObject(SdrModel& rSdrModel, SdrObject const & rSource) +: mpFillGeometryDefiningShape(nullptr) + ,mrSdrModelFromSdrObject(rSdrModel) + ,pUserCall(nullptr) + ,mpImpl(new Impl) + ,mpParentOfSdrObject(nullptr) + ,nOrdNum(0) + ,mnNavigationPosition(SAL_MAX_UINT32) + ,mnLayerID(0) + ,mpSvxShape( nullptr ) + ,maWeakUnoShape() + ,mbDoNotInsertIntoPageAutomatically(false) +{ + bVirtObj =false; + bSnapRectDirty =true; + bMovProt =false; + bSizProt =false; + bNoPrint =false; + bEmptyPresObj =false; + bNotVisibleAsMaster=false; + bClosedObj =false; + mbVisible = true; + + // #i25616# + mbLineIsOutsideGeometry = false; + + // #i25616# + mbSupportTextIndentingOnLineWidthChange = false; + + bIsEdge=false; + bIs3DObj=false; + bMarkProt=false; + bIsUnoObj=false; +#ifdef DBG_UTIL + // SdrObjectLifetimeWatchDog: + impAddIncarnatedSdrObjectToSdrModel(*this, getSdrModelFromSdrObject()); +#endif + + mpProperties.reset(); + mpViewContact.reset(); + + // The CloneSdrObject() method uses the local copy constructor from the individual + // sdr::properties::BaseProperties class. Since the target class maybe for another + // draw object, an SdrObject needs to be provided, as in the normal constructor. + mpProperties = rSource.GetProperties().Clone(*this); + + aOutRect=rSource.aOutRect; + mnLayerID = rSource.mnLayerID; + aAnchor =rSource.aAnchor; + bVirtObj=rSource.bVirtObj; + bSizProt=rSource.bSizProt; + bMovProt=rSource.bMovProt; + bNoPrint=rSource.bNoPrint; + mbVisible=rSource.mbVisible; + bMarkProt=rSource.bMarkProt; + bEmptyPresObj =rSource.bEmptyPresObj; + bNotVisibleAsMaster=rSource.bNotVisibleAsMaster; + bSnapRectDirty=true; + pPlusData.reset(); + if (rSource.pPlusData!=nullptr) { + pPlusData.reset(rSource.pPlusData->Clone(this)); + } + if (pPlusData!=nullptr && pPlusData->pBroadcast!=nullptr) { + pPlusData->pBroadcast.reset(); // broadcaster isn't copied + } + + pGrabBagItem.reset(); + if (rSource.pGrabBagItem!=nullptr) + pGrabBagItem.reset(rSource.pGrabBagItem->Clone()); +} + SdrObject::~SdrObject() { // Tell all the registered ObjectUsers that the page is in destruction. @@ -976,46 +1047,7 @@ bool SdrObject::HasLimitedRotation() const SdrObject* SdrObject::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrObject >(rTargetModel); -} - -SdrObject& SdrObject::operator=(const SdrObject& rObj) -{ - if( this == &rObj ) - return *this; - - mpProperties.reset(); - mpViewContact.reset(); - - // The CloneSdrObject() method uses the local copy constructor from the individual - // sdr::properties::BaseProperties class. Since the target class maybe for another - // draw object, an SdrObject needs to be provided, as in the normal constructor. - mpProperties = rObj.GetProperties().Clone(*this); - - aOutRect=rObj.aOutRect; - mnLayerID = rObj.mnLayerID; - aAnchor =rObj.aAnchor; - bVirtObj=rObj.bVirtObj; - bSizProt=rObj.bSizProt; - bMovProt=rObj.bMovProt; - bNoPrint=rObj.bNoPrint; - mbVisible=rObj.mbVisible; - bMarkProt=rObj.bMarkProt; - bEmptyPresObj =rObj.bEmptyPresObj; - bNotVisibleAsMaster=rObj.bNotVisibleAsMaster; - bSnapRectDirty=true; - pPlusData.reset(); - if (rObj.pPlusData!=nullptr) { - pPlusData.reset(rObj.pPlusData->Clone(this)); - } - if (pPlusData!=nullptr && pPlusData->pBroadcast!=nullptr) { - pPlusData->pBroadcast.reset(); // broadcaster isn't copied - } - - pGrabBagItem.reset(); - if (rObj.pGrabBagItem!=nullptr) - pGrabBagItem.reset(rObj.pGrabBagItem->Clone()); - return *this; + return new SdrObject(rTargetModel, *this); } OUString SdrObject::TakeObjNameSingul() const diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index 0b9fb91a8627..3d8ee8a8088f 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -190,6 +190,16 @@ SdrCaptionObj::SdrCaptionObj(SdrModel& rSdrModel) { } +SdrCaptionObj::SdrCaptionObj(SdrModel& rSdrModel, SdrCaptionObj const & rSource) +: SdrRectObj(rSdrModel, rSource), + mbSuppressGetBitmap(false) +{ + aTailPoly = rSource.aTailPoly; + mbSpecialTextBoxShadow = rSource.mbSpecialTextBoxShadow; + mbFixedTail = rSource.mbFixedTail; + maFixedTailPos = rSource.maFixedTailPos; +} + SdrCaptionObj::SdrCaptionObj( SdrModel& rSdrModel, const tools::Rectangle& rRect, @@ -232,21 +242,7 @@ SdrObjKind SdrCaptionObj::GetObjIdentifier() const SdrCaptionObj* SdrCaptionObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrCaptionObj >(rTargetModel); -} - -SdrCaptionObj& SdrCaptionObj::operator=(const SdrCaptionObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrRectObj::operator=(rObj); - - aTailPoly = rObj.aTailPoly; - mbSpecialTextBoxShadow = rObj.mbSpecialTextBoxShadow; - mbFixedTail = rObj.mbFixedTail; - maFixedTailPos = rObj.maFixedTailPos; - - return *this; + return new SdrCaptionObj(rTargetModel, *this); } OUString SdrCaptionObj::TakeObjNameSingul() const diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 4edd86c22a49..58d61d05ce9a 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -125,6 +125,15 @@ SdrCircObj::SdrCircObj( bClosedObj=eNewKind!=SdrCircKind::Arc; } +SdrCircObj::SdrCircObj(SdrModel& rSdrModel, SdrCircObj const & rSource) +: SdrRectObj(rSdrModel, rSource) +{ + meCircleKind = rSource.meCircleKind; + nStartAngle = rSource.nStartAngle; + nEndAngle = rSource.nEndAngle; + bClosedObj = rSource.bClosedObj; +} + SdrCircObj::SdrCircObj( SdrModel& rSdrModel, SdrCircKind eNewKind, @@ -368,20 +377,7 @@ OUString SdrCircObj::TakeObjNamePlural() const SdrCircObj* SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrCircObj >(rTargetModel); -} - -SdrCircObj& SdrCircObj::operator=(const SdrCircObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrRectObj::operator=(rObj); - - meCircleKind = rObj.meCircleKind; - nStartAngle = rObj.nStartAngle; - nEndAngle = rObj.nEndAngle; - - return *this; + return new SdrCircObj(rTargetModel, *this); } basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index 093b384ce4c1..ca319d65487e 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -167,6 +167,27 @@ SdrEdgeObj::SdrEdgeObj(SdrModel& rSdrModel) pEdgeTrack.reset(new XPolygon); } +SdrEdgeObj::SdrEdgeObj(SdrModel& rSdrModel, SdrEdgeObj const & rSource) +: SdrTextObj(rSdrModel, rSource), + nNotifyingCount(0), + bEdgeTrackDirty(false), + bEdgeTrackUserDefined(false), + // Default is to allow default connects + mbSuppressDefaultConnect(false), + mbBoundRectCalculationRunning(false), + mbSuppressed(false) +{ + bClosedObj = false; + bIsEdge = true; + *pEdgeTrack =*rSource.pEdgeTrack; + bEdgeTrackDirty=rSource.bEdgeTrackDirty; + aCon1 =rSource.aCon1; + aCon2 =rSource.aCon2; + aCon1.pObj=nullptr; + aCon2.pObj=nullptr; + aEdgeInfo=rSource.aEdgeInfo; +} + SdrEdgeObj::~SdrEdgeObj() { SdrEdgeObj::DisconnectFromNode(true); @@ -1643,22 +1664,7 @@ void SdrEdgeObj::Reformat() SdrEdgeObj* SdrEdgeObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrEdgeObj >(rTargetModel); -} - -SdrEdgeObj& SdrEdgeObj::operator=(const SdrEdgeObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrTextObj::operator=(rObj); - *pEdgeTrack =*rObj.pEdgeTrack; - bEdgeTrackDirty=rObj.bEdgeTrackDirty; - aCon1 =rObj.aCon1; - aCon2 =rObj.aCon2; - aCon1.pObj=nullptr; - aCon2.pObj=nullptr; - aEdgeInfo=rObj.aEdgeInfo; - return *this; + return new SdrEdgeObj(rTargetModel, *this); } OUString SdrEdgeObj::TakeObjNameSingul() const diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index cb80f67e8035..b11aea46a41a 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -204,6 +204,60 @@ SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel) mbSupportTextIndentingOnLineWidthChange = false; } +SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel, SdrGrafObj const & rSource) +: SdrRectObj(rSdrModel, rSource) + ,mpGraphicObject(new GraphicObject) + ,pGraphicLink(nullptr) +{ + onGraphicChanged(); + + // #i118485# Shear allowed and possible now + bNoShear = false; + + mbGrafAnimationAllowed = true; + + // #i25616# + mbLineIsOutsideGeometry = true; + + // #i25616# + mbSupportTextIndentingOnLineWidthChange = false; + + aFileName = rSource.aFileName; + bMirrored = rSource.bMirrored; + + mbIsSignatureLine = rSource.mbIsSignatureLine; + maSignatureLineId = rSource.maSignatureLineId; + maSignatureLineSuggestedSignerName = rSource.maSignatureLineSuggestedSignerName; + maSignatureLineSuggestedSignerTitle = rSource.maSignatureLineSuggestedSignerTitle; + maSignatureLineSuggestedSignerEmail = rSource.maSignatureLineSuggestedSignerEmail; + maSignatureLineSigningInstructions = rSource.maSignatureLineSigningInstructions; + mbIsSignatureLineShowSignDate = rSource.mbIsSignatureLineShowSignDate; + mbIsSignatureLineCanAddComment = rSource.mbIsSignatureLineCanAddComment; + mbSignatureLineIsSigned = false; + mpSignatureLineUnsignedGraphic = rSource.mpSignatureLineUnsignedGraphic; + + if(rSource.mpQrCode) + { + mpQrCode = std::make_unique<css::drawing::QRCode>(*rSource.mpQrCode); + } + else + { + mpQrCode.reset(); + } + + if (mbIsSignatureLine && rSource.mpSignatureLineUnsignedGraphic) + mpGraphicObject->SetGraphic(rSource.mpSignatureLineUnsignedGraphic); + else + mpGraphicObject->SetGraphic( rSource.GetGraphic() ); + + if( rSource.IsLinkedGraphic() ) + { + SetGraphicLink( aFileName ); + } + + ImpSetAttrToGrafInfo(); +} + SdrGrafObj::SdrGrafObj( SdrModel& rSdrModel, const Graphic& rGraphic, @@ -714,50 +768,7 @@ SdrObjectUniquePtr SdrGrafObj::getFullDragClone() const SdrGrafObj* SdrGrafObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrGrafObj >(rTargetModel); -} - -SdrGrafObj& SdrGrafObj::operator=( const SdrGrafObj& rObj ) -{ - if( this == &rObj ) - return *this; - SdrRectObj::operator=( rObj ); - - aFileName = rObj.aFileName; - bMirrored = rObj.bMirrored; - - mbIsSignatureLine = rObj.mbIsSignatureLine; - maSignatureLineId = rObj.maSignatureLineId; - maSignatureLineSuggestedSignerName = rObj.maSignatureLineSuggestedSignerName; - maSignatureLineSuggestedSignerTitle = rObj.maSignatureLineSuggestedSignerTitle; - maSignatureLineSuggestedSignerEmail = rObj.maSignatureLineSuggestedSignerEmail; - maSignatureLineSigningInstructions = rObj.maSignatureLineSigningInstructions; - mbIsSignatureLineShowSignDate = rObj.mbIsSignatureLineShowSignDate; - mbIsSignatureLineCanAddComment = rObj.mbIsSignatureLineCanAddComment; - mbSignatureLineIsSigned = false; - mpSignatureLineUnsignedGraphic = rObj.mpSignatureLineUnsignedGraphic; - - if(rObj.mpQrCode) - { - mpQrCode = std::make_unique<css::drawing::QRCode>(*rObj.mpQrCode); - } - else - { - mpQrCode.reset(); - } - - if (mbIsSignatureLine && rObj.mpSignatureLineUnsignedGraphic) - mpGraphicObject->SetGraphic(rObj.mpSignatureLineUnsignedGraphic); - else - mpGraphicObject->SetGraphic( rObj.GetGraphic() ); - - if( rObj.IsLinkedGraphic() ) - { - SetGraphicLink( aFileName ); - } - - ImpSetAttrToGrafInfo(); - return *this; + return new SdrGrafObj(rTargetModel, *this); } sal_uInt32 SdrGrafObj::GetHdlCount() const diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index 34ae1c55fe8a..1242ec6a5cf4 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -55,6 +55,30 @@ SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel) bClosedObj=false; } +SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel, SdrObjGroup const & rSource) +: SdrObject(rSdrModel, rSource), + SdrObjList() +{ + bClosedObj=false; + + // copy child SdrObjects + if(nullptr != rSource.GetSubList()) + { + // #i36404# Copy SubList, init model and page first + const SdrObjList& rSourceSubList(*rSource.GetSubList()); + + CopyObjects(rSourceSubList); + + // tdf#116979: needed here, we need bSnapRectDirty to be true + // which it is after using SdrObject::operator= (see above), + // but set to false again using CopyObjects + SetRectsDirty(); + } + + // copy local parameters + aRefPoint = rSource.aRefPoint; +} + SdrObjGroup::~SdrObjGroup() { } @@ -196,37 +220,9 @@ const tools::Rectangle& SdrObjGroup::GetSnapRect() const SdrObjGroup* SdrObjGroup::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrObjGroup >(rTargetModel); + return new SdrObjGroup(rTargetModel, *this); } -SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj) -{ - if( this == &rObj ) - return *this; - - // copy SdrObject stuff - SdrObject::operator=(rObj); - - // copy child SdrObjects - if(nullptr != rObj.GetSubList()) - { - // #i36404# Copy SubList, init model and page first - const SdrObjList& rSourceSubList(*rObj.GetSubList()); - - CopyObjects(rSourceSubList); - - // tdf#116979: needed here, we need bSnapRectDirty to be true - // which it is after using SdrObject::operator= (see above), - // but set to false again using CopyObjects - SetRectsDirty(); - } - - // copy local parameters - aRefPoint = rObj.aRefPoint; - return *this; -} - - OUString SdrObjGroup::TakeObjNameSingul() const { OUStringBuffer sName; diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 3f98c71eae20..a83fe8ad38b5 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -204,6 +204,18 @@ SdrMeasureObj::SdrMeasureObj(SdrModel& rSdrModel) mbSupportTextIndentingOnLineWidthChange = false; } +SdrMeasureObj::SdrMeasureObj(SdrModel& rSdrModel, SdrMeasureObj const & rSource) +: SdrTextObj(rSdrModel, rSource), + bTextDirty(false) +{ + // #i25616# + mbSupportTextIndentingOnLineWidthChange = false; + + aPt1 = rSource.aPt1; + aPt2 = rSource.aPt2; + bTextDirty = rSource.bTextDirty; +} + SdrMeasureObj::SdrMeasureObj( SdrModel& rSdrModel, const Point& rPt1, @@ -697,20 +709,7 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const SdrMeasureObj* SdrMeasureObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrMeasureObj >(rTargetModel); -} - -SdrMeasureObj& SdrMeasureObj::operator=(const SdrMeasureObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrTextObj::operator=(rObj); - - aPt1 = rObj.aPt1; - aPt2 = rObj.aPt2; - bTextDirty = rObj.bTextDirty; - - return *this; + return new SdrMeasureObj(rTargetModel, *this); } OUString SdrMeasureObj::TakeObjNameSingul() const diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index 923be7d451ba..5826d3e72bed 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -58,6 +58,15 @@ SdrMediaObj::SdrMediaObj(SdrModel& rSdrModel) { } +SdrMediaObj::SdrMediaObj(SdrModel& rSdrModel, SdrMediaObj const & rSource) +: SdrRectObj(rSdrModel, rSource) + ,m_xImpl( new Impl ) +{ + m_xImpl->m_pTempFile = rSource.m_xImpl->m_pTempFile; // before props + setMediaProperties( rSource.getMediaProperties() ); + m_xImpl->m_xCachedSnapshot = rSource.m_xImpl->m_xCachedSnapshot; +} + SdrMediaObj::SdrMediaObj( SdrModel& rSdrModel, const tools::Rectangle& rRect) @@ -131,19 +140,7 @@ OUString SdrMediaObj::TakeObjNamePlural() const SdrMediaObj* SdrMediaObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrMediaObj >(rTargetModel); -} - -SdrMediaObj& SdrMediaObj::operator=(const SdrMediaObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrRectObj::operator=( rObj ); - - m_xImpl->m_pTempFile = rObj.m_xImpl->m_pTempFile; // before props - setMediaProperties( rObj.getMediaProperties() ); - m_xImpl->m_xCachedSnapshot = rObj.m_xImpl->m_xCachedSnapshot; - return *this; + return new SdrMediaObj(rTargetModel, *this); } uno::Reference< graphic::XGraphic > const & SdrMediaObj::getSnapshot() const diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 089d3aea9dca..78bb0c1ce250 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -708,6 +708,48 @@ SdrOle2Obj::SdrOle2Obj( Init(); } +SdrOle2Obj::SdrOle2Obj(SdrModel& rSdrModel, SdrOle2Obj const & rSource) +: SdrRectObj(rSdrModel, rSource), + mpImpl(new SdrOle2ObjImpl(/*bFrame*/false)) +{ + Init(); + + // Manually copying bClosedObj attribute + SetClosedObj( rSource.IsClosedObj() ); + + mpImpl->aPersistName = rSource.mpImpl->aPersistName; + mpImpl->maProgName = rSource.mpImpl->maProgName; + mpImpl->mbFrame = rSource.mpImpl->mbFrame; + + if (rSource.mpImpl->mxGraphic) + { + mpImpl->mxGraphic.reset(new Graphic(*rSource.mpImpl->mxGraphic)); + } + + if( !IsEmptyPresObj() ) + { + ::comphelper::IEmbeddedHelper* pDestPers(getSdrModelFromSdrObject().GetPersist()); + ::comphelper::IEmbeddedHelper* pSrcPers(rSource.getSdrModelFromSdrObject().GetPersist()); + if( pDestPers && pSrcPers ) + { + DBG_ASSERT( !mpImpl->mxObjRef.is(), "Object already existing!" ); + comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer(); + uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName ); + if ( xObj.is() ) + { + OUString aTmp; + mpImpl->mxObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject( + rContainer, xObj, aTmp, pSrcPers->getDocumentBaseURL(), pDestPers->getDocumentBaseURL()), rSource.GetAspect()); + mpImpl->mbTypeAsked = false; + mpImpl->aPersistName = aTmp; + CheckFileLink_Impl(); + } + + Connect(); + } + } +} + SdrOle2Obj::SdrOle2Obj( SdrModel& rSdrModel, const svt::EmbeddedObjectRef& rNewObjRef, @@ -1371,66 +1413,7 @@ OUString SdrOle2Obj::TakeObjNamePlural() const SdrOle2Obj* SdrOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrOle2Obj >(rTargetModel); -} - -SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj) -{ - return assignFrom(rObj); -} - -SdrOle2Obj& SdrOle2Obj::assignFrom(const SdrOle2Obj& rObj) -{ - //TODO/LATER: who takes over control of my old object?! - if( &rObj == this ) - { - return *this; - } - - // ImpAssign( rObj ); - const SdrOle2Obj& rOle2Obj = rObj; - - if( mpImpl->mbConnected ) - Disconnect(); - - SdrRectObj::operator=( rObj ); - - // Manually copying bClosedObj attribute - SetClosedObj( rObj.IsClosedObj() ); - - mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName; - mpImpl->maProgName = rOle2Obj.mpImpl->maProgName; - mpImpl->mbFrame = rOle2Obj.mpImpl->mbFrame; - - if (rOle2Obj.mpImpl->mxGraphic) - { - mpImpl->mxGraphic.reset(new Graphic(*rOle2Obj.mpImpl->mxGraphic)); - } - - if( !IsEmptyPresObj() ) - { - ::comphelper::IEmbeddedHelper* pDestPers(getSdrModelFromSdrObject().GetPersist()); - ::comphelper::IEmbeddedHelper* pSrcPers(rObj.getSdrModelFromSdrObject().GetPersist()); - if( pDestPers && pSrcPers ) - { - DBG_ASSERT( !mpImpl->mxObjRef.is(), "Object already existing!" ); - comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer(); - uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName ); - if ( xObj.is() ) - { - OUString aTmp; - mpImpl->mxObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject( - rContainer, xObj, aTmp, pSrcPers->getDocumentBaseURL(), pDestPers->getDocumentBaseURL()), rOle2Obj.GetAspect()); - mpImpl->mbTypeAsked = false; - mpImpl->aPersistName = aTmp; - CheckFileLink_Impl(); - } - - Connect(); - } - } - - return *this; + return new SdrOle2Obj(rTargetModel, *this); } void SdrOle2Obj::ImpSetVisAreaSize() diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx index f57dd7dd5e4d..2f47da5b4a1f 100644 --- a/svx/source/svdraw/svdopage.cxx +++ b/svx/source/svdraw/svdopage.cxx @@ -71,6 +71,13 @@ SdrPageObj::SdrPageObj( } } +SdrPageObj::SdrPageObj(SdrModel& rSdrModel, SdrPageObj const & rSource) +: SdrObject(rSdrModel, rSource), + mpShownPage(nullptr) +{ + SetReferencedPage( rSource.GetReferencedPage()); +} + SdrPageObj::SdrPageObj( SdrModel& rSdrModel, const tools::Rectangle& rRect, @@ -147,16 +154,7 @@ void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const SdrPageObj* SdrPageObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrPageObj >(rTargetModel); -} - -SdrPageObj& SdrPageObj::operator=(const SdrPageObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrObject::operator=(rObj); - SetReferencedPage( rObj.GetReferencedPage()); - return *this; + return new SdrPageObj(rTargetModel, *this); } OUString SdrPageObj::TakeObjNameSingul() const diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index e42ebceb872a..58c389142754 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -1625,6 +1625,14 @@ SdrPathObj::SdrPathObj( bClosedObj = IsClosed(); } +SdrPathObj::SdrPathObj(SdrModel& rSdrModel, SdrPathObj const & rSource) +: SdrTextObj(rSdrModel, rSource), + meKind(rSource.meKind) +{ + bClosedObj = IsClosed(); + maPathPolygon = rSource.GetPathPoly(); +} + SdrPathObj::SdrPathObj( SdrModel& rSdrModel, SdrObjKind eNewKind, @@ -1817,16 +1825,7 @@ SdrObjKind SdrPathObj::GetObjIdentifier() const SdrPathObj* SdrPathObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrPathObj >(rTargetModel); -} - -SdrPathObj& SdrPathObj::operator=(const SdrPathObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrTextObj::operator=(rObj); - maPathPolygon=rObj.GetPathPoly(); - return *this; + return new SdrPathObj(rTargetModel, *this); } OUString SdrPathObj::TakeObjNameSingul() const diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 111dd2b35086..c6185e54624b 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -56,6 +56,16 @@ SdrRectObj::SdrRectObj(SdrModel& rSdrModel) bClosedObj=true; } +SdrRectObj::SdrRectObj(SdrModel& rSdrModel, SdrRectObj const & rSource) +: SdrTextObj(rSdrModel, rSource) +{ + bClosedObj=true; + if ( rSource.mpXPoly ) + mpXPoly.reset( new XPolygon( *rSource.mpXPoly ) ); + else + mpXPoly.reset(); +} + SdrRectObj::SdrRectObj( SdrModel& rSdrModel, const tools::Rectangle& rRect) @@ -245,22 +255,7 @@ OUString SdrRectObj::TakeObjNamePlural() const SdrRectObj* SdrRectObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrRectObj >(rTargetModel); -} - -SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy) -{ - if ( this == &rCopy ) - return *this; - - SdrTextObj::operator=( rCopy ); - - if ( rCopy.mpXPoly ) - mpXPoly.reset( new XPolygon( *rCopy.mpXPoly ) ); - else - mpXPoly.reset(); - - return *this; + return new SdrRectObj(rTargetModel, *this); } basegfx::B2DPolyPolygon SdrRectObj::TakeXorPoly() const diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 2d4627cc43ac..4ba4996ae6dd 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -85,6 +85,55 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel) mbInDownScale = false; } +SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource) +: SdrAttrObj(rSdrModel, rSource), + pEdtOutl(nullptr) +{ + mbInEditMode = false; + mbTextAnimationAllowed = true; + maTextEditOffset = Point(0, 0); + + // #i25616# + mbSupportTextIndentingOnLineWidthChange = true; + mbInDownScale = false; + + maRect = rSource.maRect; + aGeo =rSource.aGeo; + eTextKind =rSource.eTextKind; + bTextFrame=rSource.bTextFrame; + aTextSize=rSource.aTextSize; + bTextSizeDirty=rSource.bTextSizeDirty; + + // Not all of the necessary parameters were copied yet. + bNoShear = rSource.bNoShear; + bDisableAutoWidthOnDragging = rSource.bDisableAutoWidthOnDragging; + SdrText* pText = getActiveText(); + + if( pText && rSource.HasText() ) + { + // before pNewOutlinerParaObject was created the same, but + // set at mpText (outside this scope), but mpText might be + // empty (this operator== seems not prepared for MultiText + // objects). In the current form it makes only sense to + // create locally and use locally on a known existing SdrText + const Outliner* pEO=rSource.pEdtOutl; + std::unique_ptr<OutlinerParaObject> pNewOutlinerParaObject; + + if (pEO!=nullptr) + { + pNewOutlinerParaObject = pEO->CreateParaObject(); + } + else if (nullptr != rSource.getActiveText()->GetOutlinerParaObject()) + { + pNewOutlinerParaObject.reset( new OutlinerParaObject(*rSource.getActiveText()->GetOutlinerParaObject()) ); + } + + pText->SetOutlinerParaObject( std::move(pNewOutlinerParaObject) ); + } + + ImpSetTextStyleSheetListeners(); +} + SdrTextObj::SdrTextObj( SdrModel& rSdrModel, const tools::Rectangle& rNewRect) @@ -1001,53 +1050,7 @@ OUString SdrTextObj::TakeObjNamePlural() const SdrTextObj* SdrTextObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrTextObj >(rTargetModel); -} - -SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj) -{ - if( this == &rObj ) - return *this; - - // call parent. tdf#116979: use the correct parent class - SdrAttrObj::operator=(rObj); - - maRect = rObj.maRect; - aGeo =rObj.aGeo; - eTextKind =rObj.eTextKind; - bTextFrame=rObj.bTextFrame; - aTextSize=rObj.aTextSize; - bTextSizeDirty=rObj.bTextSizeDirty; - - // Not all of the necessary parameters were copied yet. - bNoShear = rObj.bNoShear; - bDisableAutoWidthOnDragging = rObj.bDisableAutoWidthOnDragging; - SdrText* pText = getActiveText(); - - if( pText && rObj.HasText() ) - { - // before pNewOutlinerParaObject was created the same, but - // set at mpText (outside this scope), but mpText might be - // empty (this operator== seems not prepared for MultiText - // objects). In the current form it makes only sense to - // create locally and use locally on a known existing SdrText - const Outliner* pEO=rObj.pEdtOutl; - std::unique_ptr<OutlinerParaObject> pNewOutlinerParaObject; - - if (pEO!=nullptr) - { - pNewOutlinerParaObject = pEO->CreateParaObject(); - } - else if (nullptr != rObj.getActiveText()->GetOutlinerParaObject()) - { - pNewOutlinerParaObject.reset( new OutlinerParaObject(*rObj.getActiveText()->GetOutlinerParaObject()) ); - } - - pText->SetOutlinerParaObject( std::move(pNewOutlinerParaObject) ); - } - - ImpSetTextStyleSheetListeners(); - return *this; + return new SdrTextObj(rTargetModel, *this); } basegfx::B2DPolyPolygon SdrTextObj::TakeXorPoly() const diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index d6800e2e5b83..e82ff0ae75a0 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -149,6 +149,48 @@ SdrUnoObj::SdrUnoObj( CreateUnoControlModel(rModelName); } +SdrUnoObj::SdrUnoObj( SdrModel& rSdrModel, SdrUnoObj const & rSource) +: SdrRectObj(rSdrModel, rSource), + m_pImpl( new SdrUnoObjDataHolder ) +{ + bIsUnoObj = true; + + m_pImpl->pEventListener = new SdrControlEventListenerImpl(this); + + aUnoControlModelTypeName = rSource.aUnoControlModelTypeName; + aUnoControlTypeName = rSource.aUnoControlTypeName; + + // copy the uno control model + const uno::Reference< awt::XControlModel > xSourceControlModel = rSource.GetUnoControlModel(); + if ( xSourceControlModel.is() ) + { + try + { + uno::Reference< util::XCloneable > xClone( xSourceControlModel, uno::UNO_QUERY_THROW ); + xUnoControlModel.set( xClone->createClone(), uno::UNO_QUERY_THROW ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); + } + } + + // get service name of the control from the control model + uno::Reference< beans::XPropertySet > xSet(xUnoControlModel, uno::UNO_QUERY); + if (xSet.is()) + { + uno::Any aValue( xSet->getPropertyValue("DefaultControl") ); + OUString aStr; + + if( aValue >>= aStr ) + aUnoControlTypeName = aStr; + } + + uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY); + if (xComp.is()) + m_pImpl->pEventListener->StartListening(xComp); +} + SdrUnoObj::SdrUnoObj( SdrModel& rSdrModel, const OUString& rModelName, @@ -246,51 +288,7 @@ OUString SdrUnoObj::TakeObjNamePlural() const SdrUnoObj* SdrUnoObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrUnoObj >(rTargetModel); -} - -SdrUnoObj& SdrUnoObj::operator= (const SdrUnoObj& rObj) -{ - if( this == &rObj ) - return *this; - SdrRectObj::operator= (rObj); - - // release the reference to the current control model - SetUnoControlModel( nullptr ); - - aUnoControlModelTypeName = rObj.aUnoControlModelTypeName; - aUnoControlTypeName = rObj.aUnoControlTypeName; - - // copy the uno control model - const uno::Reference< awt::XControlModel > xSourceControlModel = rObj.GetUnoControlModel(); - if ( xSourceControlModel.is() ) - { - try - { - uno::Reference< util::XCloneable > xClone( xSourceControlModel, uno::UNO_QUERY_THROW ); - xUnoControlModel.set( xClone->createClone(), uno::UNO_QUERY_THROW ); - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("svx"); - } - } - - // get service name of the control from the control model - uno::Reference< beans::XPropertySet > xSet(xUnoControlModel, uno::UNO_QUERY); - if (xSet.is()) - { - uno::Any aValue( xSet->getPropertyValue("DefaultControl") ); - OUString aStr; - - if( aValue >>= aStr ) - aUnoControlTypeName = aStr; - } - - uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY); - if (xComp.is()) - m_pImpl->pEventListener->StartListening(xComp); - return *this; + return new SdrUnoObj(rTargetModel, *this); } void SdrUnoObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index 06fa3c884f2e..42d78aa69a97 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -49,6 +49,20 @@ SdrVirtObj::SdrVirtObj( bClosedObj=rRefObj.IsClosedObj(); } +SdrVirtObj::SdrVirtObj( + SdrModel& rSdrModel, SdrVirtObj const & rSource) +: SdrObject(rSdrModel, rSource), + rRefObj(rSource.rRefObj) +{ + bVirtObj=true; // this is only a virtual object + bClosedObj=rRefObj.IsClosedObj(); + + rRefObj.AddReference(*this); + + aSnapRect = rSource.aSnapRect; + aAnchor = rSource.aAnchor; +} + SdrVirtObj::~SdrVirtObj() { rRefObj.DelReference(*this); @@ -120,7 +134,7 @@ void SdrVirtObj::RecalcBoundRect() SdrVirtObj* SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrVirtObj >(rTargetModel); + return new SdrVirtObj(rTargetModel, *this); // TTTT not sure if the above works - how could SdrObjFactory::MakeNewObject // create an object with correct rRefObj (?) OTOH VirtObj probably needs not // to be cloned ever - only used in Writer for multiple instances e.g. Header/Footer @@ -129,21 +143,6 @@ SdrVirtObj* SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const // rRefObj); // only a further reference } -SdrVirtObj& SdrVirtObj::operator=(const SdrVirtObj& rObj) -{ - SdrObject::operator=(rObj); - - // reference different object?? TTTT -> yes! - rRefObj.DelReference(*this); - rRefObj = rObj.rRefObj; - rRefObj.AddReference(*this); - - aSnapRect = rObj.aSnapRect; - aAnchor = rObj.aAnchor; - - return *this; -} - OUString SdrVirtObj::TakeObjNameSingul() const { OUStringBuffer sName(rRefObj.TakeObjNameSingul()); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 9357d7b32202..2f73ac60d7cd 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -864,6 +864,28 @@ SdrTableObj::SdrTableObj(SdrModel& rSdrModel) init( 1, 1 ); } +SdrTableObj::SdrTableObj(SdrModel& rSdrModel, SdrTableObj const & rSource) +: SdrTextObj(rSdrModel, rSource) +{ + init( 1, 1 ); + + TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr ); + + maLogicRect = rSource.maLogicRect; + maRect = rSource.maRect; + aGeo = rSource.aGeo; + eTextKind = rSource.eTextKind; + bTextFrame = rSource.bTextFrame; + aTextSize = rSource.aTextSize; + bTextSizeDirty = rSource.bTextSizeDirty; + bNoShear = rSource.bNoShear; + bDisableAutoWidthOnDragging = rSource.bDisableAutoWidthOnDragging; + + // use SdrTableObjImpl::operator= now to + // copy model data and other stuff (see there) + *mpImpl = *rSource.mpImpl; +} + SdrTableObj::SdrTableObj( SdrModel& rSdrModel, const ::tools::Rectangle& rNewRect, @@ -1757,40 +1779,7 @@ OUString SdrTableObj::TakeObjNamePlural() const SdrTableObj* SdrTableObj::CloneSdrObject(SdrModel& rTargetModel) const { - return CloneHelper< SdrTableObj >(rTargetModel); -} - -SdrTableObj& SdrTableObj::operator=(const SdrTableObj& rObj) -{ - if( this == &rObj ) - { - return *this; - } - - // call parent - // before SdrObject::operator= was called which is wrong from - // the derivation hierarchy and may leave quite some entries - // uninitialized. Changed to SdrTextObj::operator=, but had to adapt - // usage of pNewOutlinerParaObject/mpText there due to nullptr access - SdrTextObj::operator=(rObj); - - TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr ); - - maLogicRect = rObj.maLogicRect; - maRect = rObj.maRect; - aGeo = rObj.aGeo; - eTextKind = rObj.eTextKind; - bTextFrame = rObj.bTextFrame; - aTextSize = rObj.aTextSize; - bTextSizeDirty = rObj.bTextSizeDirty; - bNoShear = rObj.bNoShear; - bDisableAutoWidthOnDragging = rObj.bDisableAutoWidthOnDragging; - - // use SdrTableObjImpl::operator= now to - // copy model data and other stuff (see there) - *mpImpl = *rObj.mpImpl; - - return *this; + return new SdrTableObj(rTargetModel, *this); } diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index 07114eedf59d..539819ec1e14 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -233,12 +233,13 @@ class SwDrawVirtObj final : public SdrVirtObj SdrModel& rSdrModel, SdrObject& _rNewObj, SwDrawContact& _rDrawContact); + // copy constructor + SwDrawVirtObj(SdrModel& rSdrModel, SwDrawVirtObj const & rSource); /// access to offset virtual Point GetOffset() const override; virtual SwDrawVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override; - SwDrawVirtObj& operator= (const SwDrawVirtObj& rObj); /// connection to writer layout const SwAnchoredObject& GetAnchoredObj() const { return maAnchoredDrawObj; } diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 3d7fdc18120d..d1250d5305de 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -2205,29 +2205,30 @@ SwDrawVirtObj::SwDrawVirtObj( NbcMove( Size( -16000, -16000 ) ); } -SwDrawVirtObj::~SwDrawVirtObj() +SwDrawVirtObj::SwDrawVirtObj( + SdrModel& rSdrModel, + SwDrawVirtObj const & rSource) +: SdrVirtObj(rSdrModel, rSource), + maAnchoredDrawObj(), + mrDrawContact(rSource.mrDrawContact) { -} + // #i26791# + maAnchoredDrawObj.SetDrawObj( *this ); + + // #i35635# - set initial position out of sight + NbcMove( Size( -16000, -16000 ) ); -SwDrawVirtObj& SwDrawVirtObj::operator=( const SwDrawVirtObj& rObj ) -{ - SdrVirtObj::operator=(rObj); // Note: Members <maAnchoredDrawObj> and <mrDrawContact> // haven't to be considered. - return *this; } -SwDrawVirtObj* SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const +SwDrawVirtObj::~SwDrawVirtObj() { - SwDrawVirtObj* pObj = new SwDrawVirtObj( - rTargetModel, - rRefObj, - mrDrawContact); - - pObj->operator=( *this ); - // Note: Member <maAnchoredDrawObj> hasn't to be considered. +} - return pObj; +SwDrawVirtObj* SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const +{ + return new SwDrawVirtObj(rTargetModel, *this); } const SwFrame* SwDrawVirtObj::GetAnchorFrame() const |