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 /svx | |
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>
Diffstat (limited to 'svx')
29 files changed, 609 insertions, 632 deletions
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); } |