summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-05-07 11:44:26 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-05-08 01:53:46 +0200
commit91b0d2122bdee361bf5412a42d48ff051159cbf2 (patch)
tree003ef60b93668847803a812486534ebc805e6546
parentbdccb7e9991d83029eb2f2f11327b54534a00db8 (diff)
tdf#116977 secured ::Clone methods
Renamed SdrPage::Clone -> SdrPage::CloneSdrPage Renamed SdrObject::Clone -> SdrObject::CloneSdrObject Giving SdrModel is no longer an option, but a must (as reference). This makes future changes more safe by force usage to think about it. Also equals the constructors which already require a target SdrModel. Done the same for ::CloneSdrPage. Change-Id: I06f0129e15140bd8693db27a445037d7e2f7f652 Reviewed-on: https://gerrit.libreoffice.org/53933 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
-rw-r--r--basctl/source/dlged/dlgedobj.cxx4
-rw-r--r--basctl/source/dlged/dlgedpage.cxx4
-rw-r--r--basctl/source/inc/dlgedobj.hxx12
-rw-r--r--basctl/source/inc/dlgedpage.hxx2
-rw-r--r--chart2/source/controller/drawinglayer/ViewElementListProvider.cxx4
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx2
-rw-r--r--cui/source/tabpages/tpline.cxx21
-rw-r--r--include/svx/cube3d.hxx6
-rw-r--r--include/svx/extrud3d.hxx6
-rw-r--r--include/svx/fmpage.hxx2
-rw-r--r--include/svx/lathe3d.hxx6
-rw-r--r--include/svx/obj3d.hxx14
-rw-r--r--include/svx/polygn3d.hxx7
-rw-r--r--include/svx/scene3d.hxx7
-rw-r--r--include/svx/sphere3d.hxx6
-rw-r--r--include/svx/svdoashp.hxx6
-rw-r--r--include/svx/svdobj.hxx24
-rw-r--r--include/svx/svdocapt.hxx9
-rw-r--r--include/svx/svdocirc.hxx8
-rw-r--r--include/svx/svdoedge.hxx6
-rw-r--r--include/svx/svdograf.hxx12
-rw-r--r--include/svx/svdogrp.hxx7
-rw-r--r--include/svx/svdomeas.hxx6
-rw-r--r--include/svx/svdomedia.hxx13
-rw-r--r--include/svx/svdoole2.hxx7
-rw-r--r--include/svx/svdopage.hxx7
-rw-r--r--include/svx/svdopath.hxx8
-rw-r--r--include/svx/svdorect.hxx7
-rw-r--r--include/svx/svdotable.hxx8
-rw-r--r--include/svx/svdotext.hxx3
-rw-r--r--include/svx/svdouno.hxx8
-rw-r--r--include/svx/svdovirt.hxx6
-rw-r--r--include/svx/svdpage.hxx8
-rw-r--r--reportdesign/inc/RptObject.hxx19
-rw-r--r--reportdesign/inc/RptPage.hxx2
-rw-r--r--reportdesign/source/core/api/Shape.cxx2
-rw-r--r--reportdesign/source/core/sdr/RptObject.cxx8
-rw-r--r--reportdesign/source/core/sdr/RptPage.cxx4
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx11
-rw-r--r--reportdesign/source/ui/report/ReportSection.cxx4
-rw-r--r--sc/inc/drawpage.hxx2
-rw-r--r--sc/source/core/data/documen9.cxx2
-rw-r--r--sc/source/core/data/drawpage.cxx4
-rw-r--r--sc/source/core/data/drwlayer.cxx6
-rw-r--r--sc/source/filter/excel/xiescher.cxx4
-rw-r--r--sc/source/filter/inc/xcl97rec.hxx3
-rw-r--r--sc/source/filter/inc/xiescher.hxx6
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx2
-rw-r--r--sc/source/ui/drawfunc/graphsh.cxx4
-rw-r--r--sc/source/ui/view/drawview.cxx2
-rw-r--r--sc/source/ui/view/viewfun7.cxx2
-rw-r--r--sd/inc/sdpage.hxx2
-rw-r--r--sd/source/core/drawdoc2.cxx4
-rw-r--r--sd/source/core/drawdoc3.cxx4
-rw-r--r--sd/source/core/sdpage2.cxx4
-rw-r--r--sd/source/filter/ppt/pptin.cxx2
-rw-r--r--sd/source/ui/animations/motionpathtag.cxx6
-rw-r--r--sd/source/ui/dlg/animobjs.cxx22
-rw-r--r--sd/source/ui/func/fumorph.cxx12
-rw-r--r--sd/source/ui/func/fuvect.cxx2
-rw-r--r--sd/source/ui/sidebar/DocumentHelper.cxx4
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx4
-rw-r--r--sd/source/ui/unoidl/unoobj.cxx5
-rw-r--r--sd/source/ui/view/GraphicObjectBar.cxx2
-rw-r--r--sd/source/ui/view/drviews6.cxx3
-rw-r--r--sd/source/ui/view/drviews9.cxx2
-rw-r--r--sd/source/ui/view/sdview3.cxx6
-rw-r--r--sd/source/ui/view/sdview4.cxx4
-rw-r--r--svx/source/core/extedit.cxx2
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx4
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.cxx13
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx9
-rw-r--r--svx/source/dialog/compressgraphicdialog.cxx2
-rw-r--r--svx/source/dialog/connctrl.cxx25
-rw-r--r--svx/source/dialog/dlgctl3d.cxx9
-rw-r--r--svx/source/dialog/imapwnd.cxx10
-rw-r--r--svx/source/dialog/measctrl.cxx5
-rw-r--r--svx/source/engine3d/cube3d.cxx8
-rw-r--r--svx/source/engine3d/extrud3d.cxx8
-rw-r--r--svx/source/engine3d/lathe3d.cxx8
-rw-r--r--svx/source/engine3d/obj3d.cxx8
-rw-r--r--svx/source/engine3d/polygn3d.cxx4
-rw-r--r--svx/source/engine3d/scene3d.cxx4
-rw-r--r--svx/source/engine3d/sphere3d.cxx8
-rw-r--r--svx/source/engine3d/view3d.cxx6
-rw-r--r--svx/source/form/fmobj.cxx4
-rw-r--r--svx/source/form/fmpage.cxx4
-rw-r--r--svx/source/form/fmvwimp.cxx4
-rw-r--r--svx/source/inc/fmobj.hxx8
-rw-r--r--svx/source/sdr/contact/viewcontactofgraphic.cxx14
-rw-r--r--svx/source/svdraw/svdcrtv.cxx2
-rw-r--r--svx/source/svdraw/svddrgmt.cxx3
-rw-r--r--svx/source/svdraw/svdedtv.cxx3
-rw-r--r--svx/source/svdraw/svdedtv2.cxx2
-rw-r--r--svx/source/svdraw/svdfmtf.cxx2
-rw-r--r--svx/source/svdraw/svdmodel.cxx6
-rw-r--r--svx/source/svdraw/svdoashp.cxx8
-rw-r--r--svx/source/svdraw/svdobj.cxx17
-rw-r--r--svx/source/svdraw/svdocapt.cxx4
-rw-r--r--svx/source/svdraw/svdocirc.cxx4
-rw-r--r--svx/source/svdraw/svdoedge.cxx6
-rw-r--r--svx/source/svdraw/svdograf.cxx8
-rw-r--r--svx/source/svdraw/svdogrp.cxx4
-rw-r--r--svx/source/svdraw/svdomeas.cxx4
-rw-r--r--svx/source/svdraw/svdomedia.cxx4
-rw-r--r--svx/source/svdraw/svdoole2.cxx4
-rw-r--r--svx/source/svdraw/svdopage.cxx4
-rw-r--r--svx/source/svdraw/svdopath.cxx6
-rw-r--r--svx/source/svdraw/svdorect.cxx4
-rw-r--r--svx/source/svdraw/svdotext.cxx6
-rw-r--r--svx/source/svdraw/svdotxtr.cxx9
-rw-r--r--svx/source/svdraw/svdouno.cxx4
-rw-r--r--svx/source/svdraw/svdovirt.cxx6
-rw-r--r--svx/source/svdraw/svdpage.cxx24
-rw-r--r--svx/source/svdraw/svdxcgv.cxx4
-rw-r--r--svx/source/table/svdotable.cxx4
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx2
-rw-r--r--svx/source/unodraw/unopage.cxx2
-rw-r--r--svx/source/unogallery/unogaltheme.cxx2
-rw-r--r--sw/inc/dcontact.hxx15
-rw-r--r--sw/inc/dpage.hxx2
-rw-r--r--sw/source/core/doc/doclay.cxx2
-rw-r--r--sw/source/core/draw/dcontact.cxx24
-rw-r--r--sw/source/core/draw/dpage.cxx4
-rw-r--r--sw/source/core/frmedt/fecopy.cxx4
-rw-r--r--sw/source/core/inc/dflyobj.hxx9
-rw-r--r--sw/source/core/layout/atrfrm.cxx2
-rw-r--r--sw/source/core/layout/fly.cxx10
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx4
-rw-r--r--sw/source/uibase/shells/drawsh.cxx2
130 files changed, 510 insertions, 324 deletions
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 44d7b7a10d55..008260b0bd21 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -886,9 +886,9 @@ void DlgEdObj::clonedFrom(const DlgEdObj* _pSource)
StartListening();
}
-DlgEdObj* DlgEdObj::Clone(SdrModel* pTargetModel) const
+DlgEdObj* DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- DlgEdObj* pDlgEdObj = CloneHelper< DlgEdObj >(pTargetModel);
+ DlgEdObj* pDlgEdObj = CloneHelper< DlgEdObj >(rTargetModel);
DBG_ASSERT( pDlgEdObj != nullptr, "DlgEdObj::Clone: invalid clone!" );
if ( pDlgEdObj )
pDlgEdObj->clonedFrom( this );
diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx
index 73241128d447..d422f757868c 100644
--- a/basctl/source/dlged/dlgedpage.cxx
+++ b/basctl/source/dlged/dlgedpage.cxx
@@ -38,9 +38,9 @@ DlgEdPage::~DlgEdPage()
ClearSdrObjList();
}
-SdrPage* DlgEdPage::Clone(SdrModel* const pNewModel) const
+SdrPage* DlgEdPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- DlgEdModel& rDlgEdModel(static_cast< DlgEdModel& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+ DlgEdModel& rDlgEdModel(static_cast< DlgEdModel& >(rTargetModel));
DlgEdPage* pClonedDlgEdPage(
new DlgEdPage(
rDlgEdModel,
diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx
index 4660c29d2682..0e6898636806 100644
--- a/basctl/source/inc/dlgedobj.hxx
+++ b/basctl/source/inc/dlgedobj.hxx
@@ -63,6 +63,9 @@ protected:
const OUString& rModelName,
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac);
+ // protected destructor
+ virtual ~DlgEdObj() override;
+
virtual void NbcMove( const Size& rSize ) override;
virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
@@ -87,16 +90,13 @@ protected:
sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
public:
-
- virtual ~DlgEdObj() override;
-
void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
virtual SdrInventor GetObjInventor() const override;
virtual sal_uInt16 GetObjIdentifier() const override;
- virtual DlgEdObj* Clone(SdrModel* pTargetModel = nullptr) const override; // not working yet
+ virtual DlgEdObj* CloneSdrObject(SdrModel& rTargetModel) const override; // not working yet
void clonedFrom(const DlgEdObj* _pSource); // not working yet
// FullDrag support
@@ -163,10 +163,10 @@ protected:
virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
-public:
-
+ // protected destructor
virtual ~DlgEdForm() override;
+public:
DlgEditor& GetDlgEditor () const { return rDlgEditor; }
void AddChild( DlgEdObj* pDlgEdObj );
diff --git a/basctl/source/inc/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx
index 164f725f85ee..e589a894ddf4 100644
--- a/basctl/source/inc/dlgedpage.hxx
+++ b/basctl/source/inc/dlgedpage.hxx
@@ -44,7 +44,7 @@ public:
explicit DlgEdPage( DlgEdModel& rModel, bool bMasterPage = false );
virtual ~DlgEdPage() override;
- virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override;
+ virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const override;
void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
index 500488aaa39c..8ddfd08f3578 100644
--- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
+++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
@@ -165,7 +165,9 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co
pView->hideMarkHandles();
SdrPageView* pPageView = pView->ShowSdrPage(pPage);
- pObj=pObj->Clone();
+ // directly clone to target SdrModel
+ pObj = pObj->CloneSdrObject(*pModel);
+
pPage->NbcInsertObject(pObj);
pView->MarkObj(pObj,pPageView);
if( pSymbolShapeProperties )
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 3c361e923333..8c19e816dad4 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -398,7 +398,7 @@ void ChartController::impl_PasteShapes( SdrModel* pModel )
{
SdrObject* pObj(aIter.Next());
// Clone to new SdrModel
- SdrObject* pNewObj(pObj ? pObj->Clone(&pDrawModelWrapper->getSdrModel()) : nullptr);
+ SdrObject* pNewObj(pObj ? pObj->CloneSdrObject(pDrawModelWrapper->getSdrModel()) : nullptr);
if ( pNewObj )
{
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index e29acf095eac..c855a9c13437 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -358,7 +358,10 @@ void SvxLineTabPage::InitSymbols(MenuButton const * pButton)
// Generate invisible square to give all symbols a
// bitmap size, which is independent from specific glyph
SdrObject *pInvisibleSquare=m_pSymbolList->GetObj(0);
- pInvisibleSquare=pInvisibleSquare->Clone();
+
+ // directly clone to target SdrModel
+ pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel);
+
pPage->NbcInsertObject(pInvisibleSquare);
pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100));
pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100));
@@ -368,7 +371,10 @@ void SvxLineTabPage::InitSymbols(MenuButton const * pButton)
SdrObject *pObj=m_pSymbolList->GetObj(i);
if(pObj==nullptr)
break;
- pObj=pObj->Clone();
+
+ // directly clone to target SdrModel
+ pObj = pObj->CloneSdrObject(*pModel);
+
m_aGrfNames.emplace_back("");
pPage->NbcInsertObject(pObj);
if(m_pSymbolAttr)
@@ -1132,7 +1138,9 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
pObj=m_pSymbolList->GetObj(nSymTmp);
if(pObj)
{
- pObj=pObj->Clone();
+ // directly clone to target SdrModel
+ pObj = pObj->CloneSdrObject(*pModel);
+
if(m_pSymbolAttr)
{
pObj->SetMergedItemSet(*m_pSymbolAttr);
@@ -1146,8 +1154,11 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
// Generate invisible square to give all symbol types a
// bitmap size, which is independent from specific glyph
- SdrObject *pInvisibleSquare=m_pSymbolList->GetObj(0);
- pInvisibleSquare=pInvisibleSquare->Clone();
+ SdrObject* pInvisibleSquare(m_pSymbolList->GetObj(0));
+
+ // directly clone to target SdrModel
+ pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel);
+
pPage->NbcInsertObject(pInvisibleSquare);
pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100));
pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100));
diff --git a/include/svx/cube3d.hxx b/include/svx/cube3d.hxx
index 95acaab386cd..570805f8a908 100644
--- a/include/svx/cube3d.hxx
+++ b/include/svx/cube3d.hxx
@@ -57,6 +57,10 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC E3dCubeObj final : public E3dCompoundObject
void SetDefaultAttributes(const E3dDefaultAttributes& rDefault);
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
+private:
+ // protected destructor - due to final, make private
+ virtual ~E3dCubeObj() override;
+
public:
E3dCubeObj(SdrModel& rSdrModel,
const E3dDefaultAttributes& rDefault,
@@ -67,7 +71,7 @@ public:
virtual sal_uInt16 GetObjIdentifier() const override;
virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
- virtual E3dCubeObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dCubeObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
E3dCubeObj& operator=(const E3dCubeObj& rObj);
diff --git a/include/svx/extrud3d.hxx b/include/svx/extrud3d.hxx
index 5c121343af4d..656a1114a3ee 100644
--- a/include/svx/extrud3d.hxx
+++ b/include/svx/extrud3d.hxx
@@ -42,6 +42,10 @@ private:
virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
void SetDefaultAttributes(const E3dDefaultAttributes& rDefault);
+private:
+ // protected destructor - due to final, make private
+ virtual ~E3dExtrudeObj() override;
+
public:
E3dExtrudeObj(
SdrModel& rSdrModel,
@@ -84,7 +88,7 @@ public:
virtual sal_uInt16 GetObjIdentifier() const override;
- virtual E3dExtrudeObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dExtrudeObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
E3dExtrudeObj& operator=(const E3dExtrudeObj& rObj);
diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx
index f91893aa3bd0..478c2a2ce1a3 100644
--- a/include/svx/fmpage.hxx
+++ b/include/svx/fmpage.hxx
@@ -52,7 +52,7 @@ public:
explicit FmFormPage(FmFormModel& rModel, bool bMasterPage=false);
virtual ~FmFormPage() override;
- virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override;
+ virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const override;
virtual void InsertObject(SdrObject* pObj, size_t nPos = SAL_MAX_SIZE) override;
diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx
index 89df10369045..073bf5787e3c 100644
--- a/include/svx/lathe3d.hxx
+++ b/include/svx/lathe3d.hxx
@@ -41,6 +41,10 @@ class SVX_DLLPUBLIC E3dLatheObj final : public E3dCompoundObject
virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
void SetDefaultAttributes(const E3dDefaultAttributes& rDefault);
+private:
+ // protected destructor - due to final, make private
+ virtual ~E3dLatheObj() override;
+
public:
E3dLatheObj(
SdrModel& rSdrModel,
@@ -90,7 +94,7 @@ public:
virtual sal_uInt16 GetObjIdentifier() const override;
- virtual E3dLatheObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dLatheObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
E3dLatheObj& operator=(const E3dLatheObj& rObj);
diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx
index 099c4b3aad63..a14279523de1 100644
--- a/include/svx/obj3d.hxx
+++ b/include/svx/obj3d.hxx
@@ -103,12 +103,13 @@ protected:
// to protected area
E3dObject(SdrModel& rSdrModel);
+ // protected destructor
+ virtual ~E3dObject() override;
+
public:
virtual void SetTransformChanged();
virtual void RecalcSnapRect() override;
- virtual ~E3dObject() override;
-
virtual SdrInventor GetObjInventor() const override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
@@ -139,7 +140,7 @@ public:
// TakeObjName...() is for the display in the UI, for example "3 frames selected".
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual E3dObject* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dObject* CloneSdrObject(SdrModel& rTargetModel) const override;
E3dObject& operator=( const E3dObject& rObj );
virtual SdrObjGeoData *NewGeoData() const override;
@@ -186,10 +187,11 @@ protected:
// convert given basegfx::B3DPolyPolygon to screen coor
basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate);
-public:
+ // protected destructor
+ virtual ~E3dCompoundObject() override;
+public:
E3dCompoundObject(SdrModel& rSdrModel);
- virtual ~E3dCompoundObject() override;
virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
virtual sal_uInt32 GetHdlCount() const override;
@@ -198,7 +200,7 @@ public:
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void RecalcSnapRect() override;
- virtual E3dCompoundObject* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dCompoundObject* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
E3dCompoundObject& operator=(const E3dCompoundObject& rObj);
diff --git a/include/svx/polygn3d.hxx b/include/svx/polygn3d.hxx
index 9f5acca38ce2..da2225c74360 100644
--- a/include/svx/polygn3d.hxx
+++ b/include/svx/polygn3d.hxx
@@ -38,6 +38,9 @@ private:
protected:
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
+ // protected destructor
+ virtual ~E3dPolygonObj() override;
+
public:
void SetPolyPolygon3D(const basegfx::B3DPolyPolygon& rNewPolyPoly3D);
void SetPolyNormals3D(const basegfx::B3DPolyPolygon& rNewPolyPoly3D);
@@ -48,8 +51,6 @@ public:
const basegfx::B3DPolyPolygon& rPolyPoly3D);
E3dPolygonObj(SdrModel& rSdrModel);
- virtual ~E3dPolygonObj() override;
-
const basegfx::B3DPolyPolygon& GetPolyPolygon3D() const { return aPolyPoly3D; }
const basegfx::B3DPolyPolygon& GetPolyNormals3D() const { return aPolyNormals3D; }
const basegfx::B2DPolyPolygon& GetPolyTexture2D() const { return aPolyTexture2D; }
@@ -57,7 +58,7 @@ public:
virtual sal_uInt16 GetObjIdentifier() const override;
virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
- virtual E3dPolygonObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dPolygonObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
E3dPolygonObj& operator=(const E3dPolygonObj& rObj);
diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx
index 57c79e7e1bec..044b27d5368f 100644
--- a/include/svx/scene3d.hxx
+++ b/include/svx/scene3d.hxx
@@ -87,12 +87,13 @@ protected:
protected:
void SetDefaultAttributes();
-
void ImpCleanup3DDepthMapper();
+ // protected destructor
+ virtual ~E3dScene() override;
+
public:
E3dScene(SdrModel& rSdrModel);
- virtual ~E3dScene() override;
virtual void SetBoundRectDirty() override;
@@ -131,7 +132,7 @@ public:
const Camera3D& GetCamera() const { return aCamera; }
void removeAllNonSelectedObjects();
- virtual E3dScene* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dScene* CloneSdrObject(SdrModel& rTargetModel) const override;
E3dScene& operator=(const E3dScene&);
virtual SdrObjGeoData *NewGeoData() const override;
diff --git a/include/svx/sphere3d.hxx b/include/svx/sphere3d.hxx
index e5534e528fa9..ca1d9ec644ef 100644
--- a/include/svx/sphere3d.hxx
+++ b/include/svx/sphere3d.hxx
@@ -37,6 +37,10 @@ private:
virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
void SetDefaultAttributes(const E3dDefaultAttributes& rDefault);
+private:
+ // protected destructor - due to final, make private
+ virtual ~E3dSphereObj() override;
+
public:
E3dSphereObj(
SdrModel& rSdrModel,
@@ -60,7 +64,7 @@ public:
virtual sal_uInt16 GetObjIdentifier() const override;
virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
- virtual E3dSphereObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual E3dSphereObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
E3dSphereObj& operator=(const E3dSphereObj& rObj);
diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index 3ce7833ca8c8..364b8ce7795a 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -129,6 +129,9 @@ protected:
Size m_aSuggestedTextFrameSize;
+ // protected destructor
+ virtual ~SdrObjCustomShape() override;
+
public:
bool UseNoFillStyle() const;
@@ -141,7 +144,6 @@ public:
double GetExtraTextRotation( const bool bPreRotation = false ) const;
SdrObjCustomShape(SdrModel& rSdrModel);
- virtual ~SdrObjCustomShape() override;
/* 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.
@@ -207,7 +209,7 @@ public:
virtual void TakeTextAnchorRect( tools::Rectangle& rAnchorRect ) const override;
virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText,
tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override;
- virtual SdrObjCustomShape* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrObjCustomShape* CloneSdrObject(SdrModel& rTargetModel) const override;
SdrObjCustomShape& operator=(const SdrObjCustomShape& rObj);
virtual OUString TakeObjNameSingul() const override;
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index c901dfa1416d..0972849dd74a 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -306,7 +306,7 @@ public:
// SwFlyDrawObj
/// Abstract DrawObject
-class SVX_DLLPUBLIC SdrObject: public SfxListener, public virtual tools::WeakBase
+class SVX_DLLPUBLIC SdrObject : public SfxListener, public virtual tools::WeakBase
{
private:
friend class SdrObjListIter;
@@ -479,11 +479,11 @@ public:
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* Clone() const { return CloneHelper< Foo >(); }".
+ // it should be sufficient to do "virtual Foo* CloneSdrObject(...) const { return CloneHelper< Foo >(); }".
// Note that this function uses operator= internally.
- virtual SdrObject* Clone(SdrModel* pTargetModel = nullptr) const;
+ virtual SdrObject* CloneSdrObject(SdrModel& rTargetModel) const;
- // implemented mainly for the purposes of Clone()
+ // implemented mainly for the purposes of CloneSdrObject()
SdrObject& operator=(const SdrObject& rObj);
// TakeObjName...() is for the display in the UI, e.g. "3 frames selected"
@@ -982,7 +982,7 @@ protected:
virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& _rxUnoShape );
// helper function for reimplementing Clone().
- template< typename T > T* CloneHelper(SdrModel* pTargetModel) const;
+ template< typename T > T* CloneHelper(SdrModel& rTargetModel) const;
private:
struct Impl;
@@ -1025,6 +1025,16 @@ private:
SdrObject( const SdrObject& ) = delete;
};
+// helper for constructing std::unique_ptr for SdrObjects where a
+// deleter is needed - here, SdrObject::Free needs to be used.
+struct SVX_DLLPUBLIC SdrObjectFreeOp
+{
+ void operator()(SdrObject* obj)
+ {
+ SdrObject::Free(obj);
+ }
+};
+
/** Suppress BroadcastObjectChange() until destruction of the (last) instance.
Prevents multiple broadcasts for a sequence of calls that would trigger a
broadcast each. Instances may be nested in levels, the outer instance will
@@ -1076,12 +1086,12 @@ private:
SdrObjFactory() = delete;
};
-template< typename T > T* SdrObject::CloneHelper(SdrModel* pTargetModel) const
+template< typename T > T* SdrObject::CloneHelper(SdrModel& rTargetModel) const
{
OSL_ASSERT( typeid( T ) == typeid( *this ));
T* pObj = dynamic_cast< T* >(
SdrObjFactory::MakeNewObject(
- nullptr == pTargetModel ? getSdrModelFromSdrObject() : *pTargetModel,
+ rTargetModel,
GetObjInventor(),
GetObjIdentifier()));
diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx
index baa0e0390bd6..0539861eb969 100644
--- a/include/svx/svdocapt.hxx
+++ b/include/svx/svdocapt.hxx
@@ -56,7 +56,6 @@ private:
bool mbFixedTail; // for calc note box fixed tail, default FALSE
Point maFixedTailPos; // for calc note box fixed tail position.
-private:
SVX_DLLPRIVATE void ImpGetCaptParams(ImpCaptParams& rPara) const;
SVX_DLLPRIVATE static void ImpCalcTail1(const ImpCaptParams& rPara, tools::Polygon& rPoly, tools::Rectangle const & rRect);
SVX_DLLPRIVATE static void ImpCalcTail2(const ImpCaptParams& rPara, tools::Polygon& rPoly, tools::Rectangle const & rRect);
@@ -64,6 +63,10 @@ private:
SVX_DLLPRIVATE static void ImpCalcTail (const ImpCaptParams& rPara, tools::Polygon& rPoly, tools::Rectangle const & rRect);
SVX_DLLPRIVATE void ImpRecalcTail();
+protected:
+ // protected destructor
+ virtual ~SdrCaptionObj() override;
+
public:
SdrCaptionObj(SdrModel& rSdrModel);
SdrCaptionObj(
@@ -71,11 +74,9 @@ public:
const tools::Rectangle& rRect,
const Point& rTail);
- virtual ~SdrCaptionObj() override;
-
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;
- virtual SdrCaptionObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrCaptionObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
SdrCaptionObj& operator=(const SdrCaptionObj& rObj);
diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx
index fc3045585aa6..0ec5ff01afae 100644
--- a/include/svx/svdocirc.hxx
+++ b/include/svx/svdocirc.hxx
@@ -65,6 +65,10 @@ private:
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
+private:
+ // protected destructor - due to final, make private
+ virtual ~SdrCircObj() override;
+
public:
SdrCircObj(
SdrModel& rSdrModel,
@@ -85,8 +89,6 @@ public:
long nNewStartAngle,
long nNewEndWink);
- virtual ~SdrCircObj() override;
-
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
@@ -94,7 +96,7 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrCircObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrCircObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
SdrCircObj& operator=(const SdrCircObj& rObj);
diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx
index ae28ad7103be..e142a4a809e5 100644
--- a/include/svx/svdoedge.hxx
+++ b/include/svx/svdoedge.hxx
@@ -186,9 +186,11 @@ protected:
void ImpSetAttrToEdgeInfo(); // copying values from the pool to aEdgeInfo
void ImpSetEdgeInfoToAttr(); // copying values from the aEdgeInfo to the pool
+ // protected destructor
+ virtual ~SdrEdgeObj() override;
+
public:
SdrEdgeObj(SdrModel& rSdrModel);
- virtual ~SdrEdgeObj() override;
SdrObjConnection& GetConnection(bool bTail1) { return *(bTail1 ? &aCon1 : &aCon2); }
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
@@ -213,7 +215,7 @@ public:
virtual void RecalcSnapRect() override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
- virtual SdrEdgeObj* Clone(SdrModel* pTargetModel = nullptr) 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 9b1a4631b376..e07864d3423b 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -84,7 +84,6 @@ private:
friend class SdrExchangeView; // Only for a ForceSwapIn() call.
friend class SdrGraphicLink;
-private:
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
@@ -115,8 +114,6 @@ private:
bool mbIsSignatureLineCanAddComment;
css::uno::Reference<css::graphic::XGraphic> mpSignatureLineUnsignedGraphic;
-private:
-
void ImpRegisterLink();
void ImpDeregisterLink();
bool ImpUpdateGraphicLink( bool bAsynchron = true ) const;
@@ -126,8 +123,11 @@ private:
void onGraphicChanged();
GDIMetaFile GetMetaFile(GraphicType &rGraphicType) const;
-public:
+protected:
+ // protected destructor
+ virtual ~SdrGrafObj() override;
+public:
SdrGrafObj(SdrModel& rSdrModel);
SdrGrafObj(
SdrModel& rSdrModel,
@@ -137,8 +137,6 @@ public:
const Graphic& rGrf,
const tools::Rectangle& rRect);
- virtual ~SdrGrafObj() override;
-
void SetGraphicObject( const GraphicObject& rGrfObj );
const GraphicObject& GetGraphicObject(bool bForceSwapIn = false) const;
const GraphicObject* GetReplacementGraphicObject() const;
@@ -185,7 +183,7 @@ public:
// #i25616#
virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
- virtual SdrGrafObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrGrafObj* CloneSdrObject(SdrModel& rTargetModel) const override;
SdrGrafObj& operator=(const SdrGrafObj& rObj);
virtual sal_uInt32 GetHdlCount() const override;
diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx
index 118f91a0a9eb..2901ee82f7d5 100644
--- a/include/svx/svdogrp.hxx
+++ b/include/svx/svdogrp.hxx
@@ -38,9 +38,12 @@ private:
SdrObjList maSdrObjList; // sub list (children)
Point aRefPoint; // Reference point inside the object group
+private:
+ // protected destructor - due to final, make private
+ virtual ~SdrObjGroup() override;
+
public:
SdrObjGroup(SdrModel& rSdrModel);
- virtual ~SdrObjGroup() override;
virtual void SetBoundRectDirty() override;
virtual sal_uInt16 GetObjIdentifier() const override;
@@ -54,7 +57,7 @@ public:
virtual const tools::Rectangle& GetCurrentBoundRect() const override;
virtual const tools::Rectangle& GetSnapRect() const override;
- virtual SdrObjGroup* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrObjGroup* CloneSdrObject(SdrModel& rTargetModel) const override;
SdrObjGroup& operator=(const SdrObjGroup& rObj);
virtual OUString TakeObjNameSingul() const override;
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index ffde6d09468c..8b1a79797b30 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -72,18 +72,20 @@ protected:
virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
+ // protected destructor
+ virtual ~SdrMeasureObj() override;
+
public:
SdrMeasureObj(SdrModel& rSdrModel);
SdrMeasureObj(
SdrModel& rSdrModel,
const Point& rPt1,
const Point& rPt2);
- virtual ~SdrMeasureObj() override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
- virtual SdrMeasureObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrMeasureObj* CloneSdrObject(SdrModel& rTargetModel) const override;
// implemented mainly for the purposes of Clone()
SdrMeasureObj& operator=(const SdrMeasureObj& rObj);
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index a45410f76bdf..f99fd2570133 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -34,16 +34,16 @@ class SVX_DLLPUBLIC SdrMediaObj final : public SdrRectObj
{
friend class sdr::contact::ViewContactOfSdrMediaObj;
-public:
-
+private:
+ // protected destructor - due to final, make private
+ virtual ~SdrMediaObj() override;
+public:
SdrMediaObj(SdrModel& rSdrModel);
SdrMediaObj(
SdrModel& rSdrModel,
const tools::Rectangle& rRect);
- virtual ~SdrMediaObj() override;
-
virtual bool HasTextEdit() const override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
@@ -52,13 +52,11 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrMediaObj* Clone(SdrModel* pTargetModel = nullptr) 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;
-public:
-
void setURL( const OUString& rURL, const OUString& rReferer, const OUString& rMimeType = OUString() );
const OUString& getURL() const;
@@ -74,7 +72,6 @@ public:
virtual bool shouldKeepAspectRatio() const override { return true; }
private:
-
void mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState );
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index 6122eef9c5dc..7dc190b33b67 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -65,6 +65,9 @@ protected:
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
+ // protected destructor
+ virtual ~SdrOle2Obj() override;
+
public:
OUString GetStyleString();
@@ -77,8 +80,6 @@ public:
const OUString& rNewObjName,
const tools::Rectangle& rNewRect);
- virtual ~SdrOle2Obj() override;
-
const svt::EmbeddedObjectRef& getEmbeddedObjectRef() const;
sal_Int64 GetAspect() const;
@@ -136,7 +137,7 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrOle2Obj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
SdrOle2Obj& assignFrom(const SdrOle2Obj& rObj);
SdrOle2Obj& operator=(const SdrOle2Obj& rObj);
diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx
index 1f349a9a38ad..a23727e62b72 100644
--- a/include/svx/svdopage.hxx
+++ b/include/svx/svdopage.hxx
@@ -40,6 +40,9 @@ protected:
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
+ // protected destructor
+ virtual ~SdrPageObj() override;
+
public:
SdrPageObj(
SdrModel& rSdrModel,
@@ -49,8 +52,6 @@ public:
const tools::Rectangle& rRect,
SdrPage* pNewPage = nullptr);
- virtual ~SdrPageObj() override;
-
SdrPage* GetReferencedPage() const { return mpShownPage;}
void SetReferencedPage(SdrPage* pNewPage);
@@ -59,7 +60,7 @@ public:
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
- virtual SdrPageObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrPageObj* CloneSdrObject(SdrModel& rTargetModel) const override;
SdrPageObj& operator=(const SdrPageObj& rObj);
virtual OUString TakeObjNameSingul() const override;
diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx
index 6c21fd06571a..d626747f31b6 100644
--- a/include/svx/svdopath.hxx
+++ b/include/svx/svdopath.hxx
@@ -61,6 +61,10 @@ private:
void ImpForceLineAngle();
ImpPathForDragAndCreate& impGetDAC() const;
+private:
+ // protected destructor - due to final, make private
+ virtual ~SdrPathObj() override;
+
public:
SdrPathObj(
SdrModel& rSdrModel,
@@ -70,12 +74,10 @@ public:
SdrObjKind eNewKind,
const basegfx::B2DPolyPolygon& rPathPoly);
- virtual ~SdrPathObj() override;
-
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
- virtual SdrPathObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrPathObj* CloneSdrObject(SdrModel& rTargetModel) const override;
SdrPathObj& operator=(const SdrPathObj& rObj);
virtual OUString TakeObjNameSingul() const override;
diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx
index f9c1c34fd145..125d1d7fb5b3 100644
--- a/include/svx/svdorect.hxx
+++ b/include/svx/svdorect.hxx
@@ -59,6 +59,9 @@ protected:
const XPolygon& GetXPoly() const;
virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
+ // protected destructor
+ virtual ~SdrRectObj() override;
+
public:
/**
* The corner radius parameter is dropped at some point.
@@ -82,8 +85,6 @@ public:
SdrObjKind eNewTextKind,
const tools::Rectangle& rRect);
- virtual ~SdrRectObj() override;
-
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
@@ -91,7 +92,7 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrRectObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrRectObj* CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void RecalcSnapRect() override;
virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index 7c5e30ec4e8d..12e27379f5ff 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -97,6 +97,10 @@ class SVX_DLLPUBLIC SdrTableObj : public ::SdrTextObj
friend class Cell;
friend class SdrTableObjImpl;
+protected:
+ // protected destructor
+ virtual ~SdrTableObj() override;
+
public:
SdrTableObj(SdrModel& rSdrModel);
SdrTableObj(
@@ -105,8 +109,6 @@ public:
sal_Int32 nColumns,
sal_Int32 nRows);
- virtual ~SdrTableObj() override;
-
// Table stuff
SdrTableObj* CloneRange(
const CellPos& rStartPos,
@@ -199,7 +201,7 @@ public:
virtual bool AdjustTextFrameWidthAndHeight() override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrTableObj* Clone(SdrModel* pTargetModel = nullptr) 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;
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 8cae87d87af2..e0b9bbe434ba 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -315,6 +315,7 @@ protected:
SdrObjKind eNewTextKind,
const tools::Rectangle& rNewRect);
+ // protected destructor
virtual ~SdrTextObj() override;
public:
@@ -443,7 +444,7 @@ public:
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrTextObj* Clone(SdrModel* pTargetModel = nullptr) 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;
diff --git a/include/svx/svdouno.hxx b/include/svx/svdouno.hxx
index d9dfb5d6acd2..245069635910 100644
--- a/include/svx/svdouno.hxx
+++ b/include/svx/svdouno.hxx
@@ -59,8 +59,11 @@ private:
SVX_DLLPRIVATE void CreateUnoControlModel(const OUString& rModelName,
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac );
-public:
+protected:
+ // protected destructor
+ virtual ~SdrUnoObj() override;
+public:
explicit SdrUnoObj(
SdrModel& rSdrModel,
const OUString& rModelName);
@@ -68,12 +71,11 @@ public:
SdrModel& rSdrModel,
const OUString& rModelName,
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac);
- virtual ~SdrUnoObj() override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;
- virtual SdrUnoObj* Clone(SdrModel* pTargetModel = nullptr) 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;
diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx
index 9e4e6d9ed179..7376b0506b76 100644
--- a/include/svx/svdovirt.hxx
+++ b/include/svx/svdovirt.hxx
@@ -46,11 +46,13 @@ protected:
virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
+ // protected destructor
+ virtual ~SdrVirtObj() override;
+
public:
SdrVirtObj(
SdrModel& rSdrModel,
SdrObject& rNewObj);
- virtual ~SdrVirtObj() override;
SdrObject& ReferencedObj();
const SdrObject& GetReferencedObj() const;
@@ -64,7 +66,7 @@ public:
virtual const tools::Rectangle& GetCurrentBoundRect() const override;
virtual const tools::Rectangle& GetLastBoundRect() const override;
virtual void RecalcBoundRect() override;
- virtual SdrVirtObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SdrVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override;
SdrVirtObj& operator=(const SdrVirtObj& rObj);
virtual OUString TakeObjNameSingul() const override;
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index fa5364bae022..5d978c09cba1 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -83,7 +83,7 @@ friend class SdrEditView;
protected:
void RecalcRects();
- void copyDataFromSdrObjList(const SdrObjList& rSrcList, SdrModel* pNewModel);
+ void copyDataFromSdrObjList(const SdrObjList& rSrcList);
private:
/// simple ActionChildInserted forwarder to have it on a central place
@@ -99,7 +99,7 @@ public:
SdrObjList(SdrPage* pNewPage = nullptr);
virtual ~SdrObjList();
- void CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModel = nullptr);
+ void CopyObjects(const SdrObjList& rSrcList);
// tdf#116879 clean up everything (without Undo), plus broadcasting
// changes. Split to this call and a private one (impClearSdrObjList)
@@ -449,7 +449,7 @@ protected:
virtual css::uno::Reference< css::uno::XInterface > createUnoPage();
// Copying of pages is split into two parts: construction and copying of page objects,
- // because the copying might need access to fully initialized page. Clone() is responsible
+ // because the copying might need access to fully initialized page. CloneSdrPage() is responsible
// to call lateInit() after copy-construction of a new object. Any initialization in derived
// classes that needs access to the page objects must be deferred to lateInit. And it must
// call lateInit() of its parent class.
@@ -459,7 +459,7 @@ public:
explicit SdrPage(SdrModel& rModel, bool bMasterPage=false);
virtual ~SdrPage() override;
- virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const;
+ virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const;
bool IsMasterPage() const { return mbMaster; }
void SetInserted(bool bNew = true);
bool IsInserted() const { return mbInserted; }
diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx
index 17f433629c56..b078e1f7d143 100644
--- a/reportdesign/inc/RptObject.hxx
+++ b/reportdesign/inc/RptObject.hxx
@@ -124,6 +124,11 @@ class REPORTDESIGN_DLLPUBLIC OCustomShape final : public SdrObjCustomShape , pub
{
friend class OReportPage;
friend class DlgEdFactory;
+
+private:
+ // protected destructor - due to final, make private
+ virtual ~OCustomShape() override;
+
public:
static OCustomShape* Create(
SdrModel& rSdrModel,
@@ -132,8 +137,6 @@ public:
return new OCustomShape(rSdrModel, _xComponent );
}
- virtual ~OCustomShape() override;
-
virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
@@ -165,6 +168,11 @@ class REPORTDESIGN_DLLPUBLIC OOle2Obj final : public SdrOle2Obj , public OObject
{
friend class OReportPage;
friend class DlgEdFactory;
+
+private:
+ // protected destructor - due to final, make private
+ virtual ~OOle2Obj() override;
+
public:
static OOle2Obj* Create(
SdrModel& rSdrModel,
@@ -174,15 +182,13 @@ public:
return new OOle2Obj(rSdrModel, _xComponent, _nType);
}
- virtual ~OOle2Obj() override;
-
virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual SdrInventor GetObjInventor() const override;
// Clone() should make a complete copy of the object.
- virtual OOle2Obj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual OOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void initializeOle() override;
OOle2Obj& operator=(const OOle2Obj& rObj);
@@ -234,6 +240,7 @@ protected:
const OUString& rModelName,
sal_uInt16 _nObjectType);
+ // protected destructor
virtual ~OUnoObject() override;
virtual void NbcMove( const Size& rSize ) override;
@@ -259,7 +266,7 @@ public:
virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual SdrInventor GetObjInventor() const override;
- virtual OUnoObject* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual OUnoObject* CloneSdrObject(SdrModel& rTargetModel) const override;
OUnoObject& operator=(const OUnoObject& rObj);
diff --git a/reportdesign/inc/RptPage.hxx b/reportdesign/inc/RptPage.hxx
index 96fb26a84a67..80d65c6777f6 100644
--- a/reportdesign/inc/RptPage.hxx
+++ b/reportdesign/inc/RptPage.hxx
@@ -55,7 +55,7 @@ public:
OReportPage( OReportModel& rModel
,const css::uno::Reference< css::report::XSection >& _xSection );
- virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override;
+ virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const override;
virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
virtual SdrObject* RemoveObject(size_t nObjNum) override;
diff --git a/reportdesign/source/core/api/Shape.cxx b/reportdesign/source/core/api/Shape.cxx
index 671bccaa2f32..c3c766df4892 100644
--- a/reportdesign/source/core/api/Shape.cxx
+++ b/reportdesign/source/core/api/Shape.cxx
@@ -313,7 +313,7 @@ uno::Reference< util::XCloneable > SAL_CALL OShape::createClone( )
SdrObject* pObject = pShape->GetSdrObject();
if ( pObject )
{
- SdrObject* pClone = pObject->Clone();
+ SdrObject* pClone(pObject->CloneSdrObject(pObject->getSdrModelFromSdrObject()));
if ( pClone )
{
xSet.set(pClone->getUnoShape(),uno::UNO_QUERY_THROW );
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 8d38b5ddf478..85a50a242c58 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -883,9 +883,9 @@ void OUnoObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUn
releaseUnoShape();
}
-OUnoObject* OUnoObject::Clone(SdrModel* pTargetModel) const
+OUnoObject* OUnoObject::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< OUnoObject >(pTargetModel);
+ return CloneHelper< OUnoObject >(rTargetModel);
}
OUnoObject& OUnoObject::operator=(const OUnoObject& rObj)
@@ -1089,9 +1089,9 @@ uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const
}
// Clone() should make a complete copy of the object.
-OOle2Obj* OOle2Obj::Clone(SdrModel* pTargetModel) const
+OOle2Obj* OOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< OOle2Obj >(pTargetModel);
+ return CloneHelper< OOle2Obj >(rTargetModel);
}
OOle2Obj& OOle2Obj::operator=(const OOle2Obj& rObj)
diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx
index b4e09805f04c..e19c1f725a31 100644
--- a/reportdesign/source/core/sdr/RptPage.cxx
+++ b/reportdesign/source/core/sdr/RptPage.cxx
@@ -42,9 +42,9 @@ OReportPage::~OReportPage()
{
}
-SdrPage* OReportPage::Clone(SdrModel* pNewModel) const
+SdrPage* OReportPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- OReportModel& rOReportModel(static_cast< OReportModel& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+ OReportModel& rOReportModel(static_cast< OReportModel& >(rTargetModel));
OReportPage* pClonedOReportPage(
new OReportPage(
rOReportModel,
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 84a8569b430b..b981e1bba458 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -3144,7 +3144,10 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
,nullptr,nullptr,_nObjectId,SdrInventor::ReportDesign,OBJ_DLG_FIXEDTEXT,
nullptr,pSectionWindow->getReportSection().getPage(),m_aReportModel.get(),
pLabel,pControl);
- delete pLabel;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pLabel);
+ SdrObject::Free(pTemp);
pNewControl = pControl;
OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl);
@@ -3576,7 +3579,11 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
else
{
for(SdrUnoObj* i : pControl)
- delete i;
+ {
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(i);
+ SdrObject::Free(pTemp);
+ }
}
}
}
diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx
index 3acc54f2bb4a..62c9275ef15d 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -265,7 +265,7 @@ void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyC
if ( pObject )
{
// Clone to target SdrModel
- SdrObject* pNewObj(pObject->Clone(m_pModel.get()));
+ SdrObject* pNewObj(pObject->CloneSdrObject(*m_pModel.get()));
pNewObj->SetPage( m_pPage );
m_pPage->InsertObject(pNewObj, SAL_MAX_SIZE);
@@ -357,7 +357,7 @@ void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedOb
{
try
{
- SdrObject* pNewObj = pSdrObject->Clone();
+ SdrObject* pNewObj(pSdrObject->CloneSdrObject(pSdrObject->getSdrModelFromSdrObject()));
aCopies.emplace_back(pNewObj->getUnoShape(),uno::UNO_QUERY);
if ( _bEraseAnddNoClone )
{
diff --git a/sc/inc/drawpage.hxx b/sc/inc/drawpage.hxx
index cbbaff987a6c..fa7806a94ccf 100644
--- a/sc/inc/drawpage.hxx
+++ b/sc/inc/drawpage.hxx
@@ -33,7 +33,7 @@ public:
explicit ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage);
virtual ~ScDrawPage() override;
- virtual ScDrawPage* Clone(SdrModel* pNewModel = nullptr) const override;
+ virtual ScDrawPage* CloneSdrPage(SdrModel& rTargetModel) const override;
virtual css::uno::Reference< css::uno::XInterface > createUnoPage() override;
};
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 8b9b4de19e63..d7c0401a9366 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -85,7 +85,7 @@ void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDes
while (pOldObject)
{
// Clone to target SdrModel
- SdrObject* pNewObject = pOldObject->Clone(mpDrawLayer);
+ SdrObject* pNewObject(pOldObject->CloneSdrObject(*mpDrawLayer));
pNewObject->SetPage(pNewPage);
pNewObject->NbcMove(Size(0,0));
pNewPage->InsertObject( pNewObject );
diff --git a/sc/source/core/data/drawpage.cxx b/sc/source/core/data/drawpage.cxx
index 302f0e93ff45..ec1208e669f7 100644
--- a/sc/source/core/data/drawpage.cxx
+++ b/sc/source/core/data/drawpage.cxx
@@ -34,9 +34,9 @@ ScDrawPage::~ScDrawPage()
{
}
-ScDrawPage* ScDrawPage::Clone(SdrModel* const pNewModel) const
+ScDrawPage* ScDrawPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- ScDrawLayer& rScDrawLayer(static_cast< ScDrawLayer& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+ ScDrawLayer& rScDrawLayer(static_cast< ScDrawLayer& >(rTargetModel));
ScDrawPage* pClonedScDrawPage(
new ScDrawPage(
rScDrawLayer,
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index ae507ba88394..3b12893cf618 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -465,7 +465,7 @@ void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
}
// Clone to target SdrModel
- SdrObject* pNewObject = pOldObject->Clone(this);
+ SdrObject* pNewObject(pOldObject->CloneSdrObject(*this));
pNewObject->SetPage(pNewPage);
pNewObject->NbcMove(Size(0,0));
pNewPage->InsertObject( pNewObject );
@@ -1477,7 +1477,7 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec
if (pDestPage)
{
// Clone to target SdrModel
- SdrObject* pNewObject = pOldObject->Clone(pDestModel);
+ SdrObject* pNewObject(pOldObject->CloneSdrObject(*pDestModel));
pNewObject->SetPage(pDestPage);
uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) );
@@ -1652,7 +1652,7 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
&& !IsNoteCaption(pOldObject))
{
// Clone to target SdrModel
- SdrObject* pNewObject = pOldObject->Clone(this);
+ SdrObject* pNewObject(pOldObject->CloneSdrObject(*this));
pNewObject->SetPage(pDestPage);
if ( bMirrorObj )
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index c5fbac78f43f..c516cb209de7 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -1011,7 +1011,7 @@ std::size_t XclImpGroupObj::DoGetProgressSize() const
SdrObjectPtr XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& /*rAnchorRect*/ ) const
{
- std::unique_ptr<SdrObjGroup, SdrObjectFree> xSdrObj(
+ std::unique_ptr<SdrObjGroup, SdrObjectFreeOp> xSdrObj(
new SdrObjGroup(
*GetDoc().GetDrawLayer()));
// child objects in BIFF2-BIFF5 have absolute size, not needed to pass own anchor rectangle
@@ -1442,7 +1442,7 @@ void XclImpTextObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI
SdrObjectPtr XclImpTextObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
- std::unique_ptr<SdrObjCustomShape, SdrObjectFree> xSdrObj(
+ std::unique_ptr<SdrObjCustomShape, SdrObjectFreeOp> xSdrObj(
new SdrObjCustomShape(
*GetDoc().GetDrawLayer()));
xSdrObj->NbcSetSnapRect( rAnchorRect );
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index ddd39fdcc819..d335f68cfc55 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -25,6 +25,7 @@
#include "xcl97esc.hxx"
#include "xlstyle.hxx"
#include <tabprotection.hxx>
+#include <svx/svdobj.hxx>
class XclObj;
class XclExpMsoDrawing;
@@ -157,7 +158,7 @@ public:
class XclObjComment : public XclObj
{
ScAddress maScPos;
- std::unique_ptr< SdrCaptionObj >
+ std::unique_ptr< SdrCaptionObj, SdrObjectFreeOp >
mpCaption;
bool mbVisible;
tools::Rectangle maFrom;
diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx
index 58bdecf82f11..626d94c15bdd 100644
--- a/sc/source/filter/inc/xiescher.hxx
+++ b/sc/source/filter/inc/xiescher.hxx
@@ -48,11 +48,7 @@ class XclImpDrawing;
// Drawing objects ============================================================
-struct SdrObjectFree {
- void operator ()(SdrObject * obj) { SdrObject::Free(obj); }
-};
-typedef std::unique_ptr<SdrObject, SdrObjectFree> SdrObjectPtr;
-
+typedef std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectPtr;
class XclImpDrawObjBase;
typedef std::shared_ptr< XclImpDrawObjBase > XclImpDrawObjRef;
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index a4ecfd8860fe..28d1379771ea 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -497,7 +497,7 @@ void XclObj::SaveTextRecs( XclExpStream& rStrm )
XclObjComment::XclObjComment( XclExpObjectManager& rObjMgr, const tools::Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress, const tools::Rectangle &rFrom, const tools::Rectangle &rTo ) :
XclObj( rObjMgr, EXC_OBJTYPE_NOTE, true )
, maScPos( rAddress )
- , mpCaption( pCaption->Clone() )
+ , mpCaption( pCaption->CloneSdrObject(pCaption->getSdrModelFromSdrObject()) )
, mbVisible( bVisible )
, maFrom ( rFrom )
, maTo ( rTo )
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
index 63475198c329..ddaf1c38139e 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -121,7 +121,7 @@ void ScGraphicShell::ExecuteFilter( const SfxRequest& rReq )
if( pPageView )
{
- SdrGrafObj* pFilteredObj = static_cast<SdrGrafObj*>(pObj->Clone());
+ SdrGrafObj* pFilteredObj(static_cast<SdrGrafObj*>(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject())));
OUString aStr = pView->GetDescriptionOfMarkedObjects() + " " + ScResId(SCSTR_UNDO_GRAFFILTER);
pView->BegUndo( aStr );
pFilteredObj->SetGraphicObject( aFilterObj );
@@ -333,7 +333,7 @@ void ScGraphicShell::ExecuteChangePicture( SAL_UNUSED_PARAMETER SfxRequest& /*rR
ErrCode nError = aDlg.GetGraphic(aGraphic);
if( nError == ERRCODE_NONE )
{
- SdrGrafObj* pNewObject = pGraphicObj->Clone();
+ SdrGrafObj* pNewObject(pGraphicObj->CloneSdrObject(pGraphicObj->getSdrModelFromSdrObject()));
pNewObject->SetGraphic( aGraphic );
SdrPageView* pPageView = pView->GetSdrPageView();
OUString aUndoString = pView->GetDescriptionOfMarkedObjects() + " Change";
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 0a3916ced717..842abcddaf54 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -978,7 +978,7 @@ SdrObject* ScDrawView::ApplyGraphicToObject(
{
if(dynamic_cast< SdrGrafObj* >(&rHitObject))
{
- SdrGrafObj* pNewGrafObj = static_cast<SdrGrafObj*>(rHitObject.Clone());
+ SdrGrafObj* pNewGrafObj(static_cast<SdrGrafObj*>(rHitObject.CloneSdrObject(rHitObject.getSdrModelFromSdrObject())));
pNewGrafObj->SetGraphic(rGraphic);
BegUndo(rBeginUndoText);
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 3b985ac3e4e6..90e823892b1b 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -154,7 +154,7 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
const SdrObject* pObj=pM->GetMarkedSdrObj();
// Directly Clone to target SdrModel
- SdrObject* pNewObj(pObj->Clone(pDrawModel));
+ SdrObject* pNewObj(pObj->CloneSdrObject(*pDrawModel));
if (pNewObj!=nullptr)
{
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 5dedec0d3bb4..3e49c4f78e06 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -155,7 +155,7 @@ public:
SdPage(SdDrawDocument& rNewDoc, bool bMasterPage);
virtual ~SdPage() override;
- virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override;
+ virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const override;
virtual void SetSize(const Size& aSize) override;
virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr) override;
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 13aa8af413c0..1a38fb080e99 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -1383,8 +1383,8 @@ sal_uInt16 SdDrawDocument::DuplicatePage (
}
// Create duplicates of a standard page and the associated notes page
- pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->Clone() );
- pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->Clone() );
+ pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*this) );
+ pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*this) );
return InsertPageSet (
pActualPage,
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index e24a66466115..e598dc35e981 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -1488,8 +1488,8 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
if (pSourceDoc != this)
{
// #i121863# clone masterpages, they are from another model (!)
- SdPage* pNewNotesMaster = dynamic_cast< SdPage* >(pNotesMaster->Clone(this));
- SdPage* pNewMaster = dynamic_cast< SdPage* >(pMaster->Clone(this));
+ SdPage* pNewNotesMaster = dynamic_cast< SdPage* >(pNotesMaster->CloneSdrPage(*this));
+ SdPage* pNewMaster = dynamic_cast< SdPage* >(pMaster->CloneSdrPage(*this));
if(!pNewNotesMaster || !pNewMaster)
{
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index bb46eb4bc148..ee1f75059709 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -410,9 +410,9 @@ void SdPage::lateInit(const SdPage& rSrcPage)
|*
\************************************************************************/
-SdrPage* SdPage::Clone(SdrModel* pNewModel) const
+SdrPage* SdPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- SdDrawDocument& rSdDrawDocument(static_cast< SdDrawDocument& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+ SdDrawDocument& rSdDrawDocument(static_cast< SdDrawDocument& >(rTargetModel));
SdPage* pClonedSdPage(
new SdPage(
rSdDrawDocument,
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 056b2924a6ba..122262da6566 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -735,7 +735,7 @@ bool ImplSdPPTImport::Import()
if ( pPersist->bStarDrawFiller && pPersist->bNotesMaster && ( nCurrentPageNum > 2 ) && ( ( nCurrentPageNum & 1 ) == 0 ) )
{
pSdrModel->DeleteMasterPage( nCurrentPageNum );
- SdrPage* pNotesClone = static_cast<SdPage*>(pSdrModel->GetMasterPage( 2 ))->Clone();
+ SdrPage* pNotesClone = static_cast<SdPage*>(pSdrModel->GetMasterPage( 2 ))->CloneSdrPage(*pSdrModel);
pSdrModel->InsertMasterPage( pNotesClone, nCurrentPageNum );
if ( pNotesClone )
{
diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx
index 6699ade88ff7..b5189251a276 100644
--- a/sd/source/ui/animations/motionpathtag.cxx
+++ b/sd/source/ui/animations/motionpathtag.cxx
@@ -986,10 +986,12 @@ void MotionPathTag::disposing()
if( mpPathObj )
{
- SdrPathObj* pPathObj = mpPathObj;
+ SdrObject* pTemp(mpPathObj);
mpPathObj = nullptr;
mrView.updateHandles();
- delete pPathObj;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject::Free(pTemp);
}
if( mpMark )
diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index 5ca6bab37ebd..8f48e7e13b29 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -789,7 +789,9 @@ void AnimationWindow::AddObj (::sd::View& rView )
++m_nCurrentFrame;
// Clone
- pPage->InsertObject(pSnapShot->Clone(), m_nCurrentFrame);
+ pPage->InsertObject(
+ pSnapShot->CloneSdrObject(pPage->getSdrModelFromSdrPage()),
+ m_nCurrentFrame);
}
bAnimObj = true;
}
@@ -813,7 +815,7 @@ void AnimationWindow::AddObj (::sd::View& rView )
{
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObject = pMark->GetMarkedSdrObj();
- SdrObject* pClone = pObject->Clone();
+ SdrObject* pClone(pObject->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
size_t nIndex = m_nCurrentFrame + 1;
pPage->InsertObject(pClone, nIndex);
}
@@ -837,7 +839,9 @@ void AnimationWindow::AddObj (::sd::View& rView )
// increment => next one inserted after this one
++m_nCurrentFrame;
- pPage->InsertObject(pObject->Clone(), m_nCurrentFrame);
+ pPage->InsertObject(
+ pObject->CloneSdrObject(pPage->getSdrModelFromSdrPage()),
+ m_nCurrentFrame);
}
bAnimObj = true; // that we don't change again
}
@@ -847,7 +851,11 @@ void AnimationWindow::AddObj (::sd::View& rView )
SdrObjList* pObjList = pCloneGroup->GetSubList();
for (size_t nObject= 0; nObject < nMarkCount; ++nObject)
- pObjList->InsertObject(rMarkList.GetMark(nObject)->GetMarkedSdrObj()->Clone());
+ {
+ pObjList->InsertObject(
+ rMarkList.GetMark(nObject)->GetMarkedSdrObj()->CloneSdrObject(
+ pPage->getSdrModelFromSdrPage()));
+ }
size_t nIndex = m_nCurrentFrame + 1;
pPage->InsertObject(pCloneGroup, nIndex);
@@ -1074,7 +1082,7 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
// the clone remains in the animation; we insert a clone of the
// clone into the group
pClone = pPage->GetObj(i);
- SdrObject* pCloneOfClone = pClone->Clone();
+ SdrObject* pCloneOfClone(pClone->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
//SdrObject* pCloneOfClone = pPage->GetObj(i)->Clone();
pObjList->InsertObject(pCloneOfClone);
}
@@ -1093,7 +1101,9 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
// #i42894# if that worked, delete the group again
if(!pGroup->GetSubList()->GetObjCount())
{
- delete pGroup;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGroup);
+ SdrObject::Free(pTemp);
}
}
}
diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx
index 2a2b2355b93f..6fa9494dfb7f 100644
--- a/sd/source/ui/func/fumorph.cxx
+++ b/sd/source/ui/func/fumorph.cxx
@@ -81,8 +81,8 @@ void FuMorph::DoExecute( SfxRequest& )
// create clones
SdrObject* pObj1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
SdrObject* pObj2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
- SdrObject* pCloneObj1 = pObj1->Clone();
- SdrObject* pCloneObj2 = pObj2->Clone();
+ SdrObject* pCloneObj1(pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()));
+ SdrObject* pCloneObj2(pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()));
// delete text at clone, otherwise we do net get a correct PathObj
pCloneObj1->SetOutlinerParaObject(nullptr);
@@ -431,8 +431,12 @@ void FuMorph::ImpInsertPolygons(
if ( nCount )
{
- pObjList->InsertObject( pObj1->Clone(), 0 );
- pObjList->InsertObject( pObj2->Clone() );
+ pObjList->InsertObject(
+ pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()),
+ 0 );
+ pObjList->InsertObject(
+ pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()) );
+
mpView->DeleteMarked();
mpView->InsertObjectAtView( pObjGroup, *pPageView, SdrInsertFlags:: SETDEFLAYER );
}
diff --git a/sd/source/ui/func/fuvect.cxx b/sd/source/ui/func/fuvect.cxx
index 6722e9e379c6..8a547243d6d8 100644
--- a/sd/source/ui/func/fuvect.cxx
+++ b/sd/source/ui/func/fuvect.cxx
@@ -70,7 +70,7 @@ void FuVectorize::DoExecute( SfxRequest& )
if( pPageView && rMtf.GetActionSize() )
{
- SdrGrafObj* pVectObj = static_cast<SdrGrafObj*>( pObj->Clone() );
+ SdrGrafObj* pVectObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) );
OUString aStr( mpView->GetDescriptionOfMarkedObjects() );
aStr += " " + SdResId( STR_UNDO_VECTORIZE );
mpView->BegUndo( aStr );
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx
index b9336124f9e1..7198a19217d8 100644
--- a/sd/source/ui/sidebar/DocumentHelper.cxx
+++ b/sd/source/ui/sidebar/DocumentHelper.cxx
@@ -209,7 +209,7 @@ SdPage* DocumentHelper::AddMasterPage (
try
{
// Duplicate the master page.
- pClonedMasterPage = static_cast<SdPage*>(pMasterPage->Clone());
+ pClonedMasterPage = static_cast<SdPage*>(pMasterPage->CloneSdrPage(rTargetDocument));
// Copy the necessary styles.
SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage()));
@@ -347,7 +347,7 @@ SdPage* DocumentHelper::AddMasterPage (
if (pMasterPage!=nullptr)
{
// Duplicate the master page.
- pClonedMasterPage = static_cast<SdPage*>(pMasterPage->Clone());
+ pClonedMasterPage = static_cast<SdPage*>(pMasterPage->CloneSdrPage(rTargetDocument));
// Copy the precious flag.
pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious());
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 677687e703d0..2c0c60302a02 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -505,7 +505,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
* standard page
**************************************************************/
if( bDuplicate )
- pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->Clone() );
+ pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*mpDoc) );
else
pStandardPage = mpDoc->AllocSdPage(false);
@@ -540,7 +540,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
SdPage* pNotesPage = nullptr;
if( bDuplicate )
- pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->Clone() );
+ pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*mpDoc) );
else
pNotesPage = mpDoc->AllocSdPage(false);
diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx
index 33e9928cafc5..5b0922b148a4 100644
--- a/sd/source/ui/unoidl/unoobj.cxx
+++ b/sd/source/ui/unoidl/unoobj.cxx
@@ -506,7 +506,10 @@ void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const c
if(!pGroup->GetSubList()->GetObjCount())
{
pPage->NbcRemoveObject(pGroup->GetOrdNum());
- delete pGroup;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGroup);
+ SdrObject::Free(pTemp);
}
}
}
diff --git a/sd/source/ui/view/GraphicObjectBar.cxx b/sd/source/ui/view/GraphicObjectBar.cxx
index 90871e3e4456..acecdffd7dac 100644
--- a/sd/source/ui/view/GraphicObjectBar.cxx
+++ b/sd/source/ui/view/GraphicObjectBar.cxx
@@ -129,7 +129,7 @@ void GraphicObjectBar::ExecuteFilter( SfxRequest const & rReq )
if( pPageView )
{
- SdrGrafObj* pFilteredObj = static_cast<SdrGrafObj*>( pObj->Clone() );
+ SdrGrafObj* pFilteredObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) );
OUString aStr = mpView->GetDescriptionOfMarkedObjects();
aStr += " " + SdResId(STR_UNDO_GRAFFILTER);
mpView->BegUndo( aStr );
diff --git a/sd/source/ui/view/drviews6.cxx b/sd/source/ui/view/drviews6.cxx
index 595ec0353681..bfc0fe363e43 100644
--- a/sd/source/ui/view/drviews6.cxx
+++ b/sd/source/ui/view/drviews6.cxx
@@ -279,7 +279,8 @@ void DrawViewShell::ExecBmpMask( SfxRequest const & rReq )
if ( pObj && !mpDrawView->IsTextEdit() )
{
- std::unique_ptr<SdrGrafObj> xNewObj(pObj->Clone());
+ typedef std::unique_ptr< SdrGrafObj, SdrObjectFreeOp > SdrGrafObjPtr;
+ SdrGrafObjPtr xNewObj(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()));
bool bCont = true;
if (xNewObj->IsLinkedGraphic())
diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx
index afc151b29a96..b253e25098ec 100644
--- a/sd/source/ui/view/drviews9.cxx
+++ b/sd/source/ui/view/drviews9.cxx
@@ -151,7 +151,7 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq)
// the empty graphic object gets a new graphic
bInsertNewObject = false;
- SdrGrafObj* pNewGrafObj = pGrafObj->Clone();
+ SdrGrafObj* pNewGrafObj(pGrafObj->CloneSdrObject(pGrafObj->getSdrModelFromSdrObject()));
pNewGrafObj->SetEmptyPresObj(false);
pNewGrafObj->SetOutlinerParaObject(nullptr);
pNewGrafObj->SetGraphic(aGraphic);
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 73f06ae8f975..4100fe9dfacc 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -480,7 +480,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
for(size_t a = 0; a < pMarkList->GetMarkCount(); ++a)
{
SdrMark* pM = pMarkList->GetMark(a);
- SdrObject* pObj = pM->GetMarkedSdrObj()->Clone();
+ SdrObject* pObj(pM->GetMarkedSdrObj()->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
if(pObj)
{
@@ -714,7 +714,8 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && pObj )
{
// replace object
- SdrObject* pNewObj = pObj->Clone();
+ SdrPage* pWorkPage = GetSdrPageView()->GetPage();
+ SdrObject* pNewObj(pObj->CloneSdrObject(pWorkPage->getSdrModelFromSdrPage()));
::tools::Rectangle aPickObjRect( pPickObj2->GetCurrentBoundRect() );
Size aPickObjSize( aPickObjRect.GetSize() );
Point aVec( aPickObjRect.TopLeft() );
@@ -733,7 +734,6 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if( bUndo )
BegUndo(SdResId(STR_UNDO_DRAGDROP));
pNewObj->NbcSetLayer( pPickObj->GetLayer() );
- SdrPage* pWorkPage = GetSdrPageView()->GetPage();
pWorkPage->InsertObject( pNewObj );
if( bUndo )
{
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 0a8792cd8538..9d1cb05ed000 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -111,7 +111,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
if( bIsGraphic )
{
// We fill the object with the Bitmap
- pNewGrafObj = static_cast<SdrGrafObj*>( pPickObj->Clone() );
+ pNewGrafObj = static_cast<SdrGrafObj*>( pPickObj->CloneSdrObject(pPickObj->getSdrModelFromSdrObject()) );
pNewGrafObj->SetGraphic(rGraphic);
}
else
@@ -318,7 +318,7 @@ SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rM
if( mnAction == DND_ACTION_LINK && pPickObj && pPV && dynamic_cast< SdrMediaObj *>( pPickObj ) != nullptr )
{
- pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
+ pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->CloneSdrObject(pPickObj->getSdrModelFromSdrObject()) );
pNewMediaObj->setURL( rMediaURL, ""/*TODO?*/, rMimeType );
BegUndo(SdResId(STR_UNDO_DRAGDROP));
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
index dab305257299..10b901c1d727 100644
--- a/svx/source/core/extedit.cxx
+++ b/svx/source/core/extedit.cxx
@@ -185,7 +185,7 @@ void SdrExternalToolEdit::Update(Graphic & rGraphic)
SdrPageView *const pPageView = m_pView->GetSdrPageView();
if (pPageView)
{
- SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->Clone()));
+ SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->CloneSdrObject(m_pObj->getSdrModelFromSdrObject())));
assert(pNewObj);
OUString const description =
m_pView->GetDescriptionOfMarkedObjects() + " External Edit";
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 70e2c5fb352d..b3d1c996a4f2 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -2277,7 +2277,9 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
// #i40600# if bLineGeometryNeededOnly is set, linestyle does not matter
if(!bLineGeometryNeededOnly && (drawing::LineStyle_NONE == eLineStyle) && (drawing::FillStyle_NONE == eFillStyle))
{
- delete pObj;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pObj);
+ SdrObject::Free(pTemp);
}
else
{
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index a0e2a6badba0..7741fa46b170 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -741,12 +741,19 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
// removing placeholder objects
for (std::vector< E3dCompoundObject* >::iterator aObjectListIter( aPlaceholderObjectList.begin() ); aObjectListIter != aPlaceholderObjectList.end(); )
{
- pScene->Remove3DObj( *aObjectListIter );
- delete *aObjectListIter++;
+ E3dCompoundObject* pTemp(*aObjectListIter++);
+ pScene->Remove3DObj( pTemp );
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp2(pTemp);
+ SdrObject::Free(pTemp2);
}
}
else
- delete pScene;
+ {
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pScene);
+ SdrObject::Free(pTemp);
+ }
}
return pRet;
}
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 753d43c3a0c7..003a43ff7d20 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -170,10 +170,15 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText(
pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
}
- static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pShadowGeometry->Clone(), 0 );
+
+ static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject(
+ pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()),
+ 0);
}
else
- pRenderedShape = pShadowGeometry->Clone();
+ {
+ pRenderedShape = pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject());
+ }
}
// apply text
diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx
index bfd9278767a5..3ba0bfb9ffd7 100644
--- a/svx/source/dialog/compressgraphicdialog.cxx
+++ b/svx/source/dialog/compressgraphicdialog.cxx
@@ -410,7 +410,7 @@ SdrGrafObj* CompressGraphicsDialog::GetCompressedSdrGrafObj()
{
if ( m_dResolution > 0.0 )
{
- SdrGrafObj* pNewObject = m_xGraphicObj->Clone();
+ SdrGrafObj* pNewObject(m_xGraphicObj->CloneSdrObject(m_xGraphicObj->getSdrModelFromSdrObject()));
if ( m_xReduceResolutionCB->get_active() )
{
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx
index 3b0ac0636682..a27dcf0278fd 100644
--- a/svx/source/dialog/connctrl.cxx
+++ b/svx/source/dialog/connctrl.cxx
@@ -156,8 +156,18 @@ void SvxXConnectionPreview::Construct()
if( nInv == SdrInventor::Default && nId == OBJ_EDGE )
{
bFound = true;
+
+ // potential memory leak here (!). Create SdrObjList only when there is
+ // not yet one.
+ if(!pSdrPage)
+ {
+ pSdrPage = new SdrPage(
+ pView->getSdrModelFromSdrView(),
+ false);
+ }
+
const SdrEdgeObj* pTmpEdgeObj = static_cast<const SdrEdgeObj*>(pObj);
- pEdgeObj = pTmpEdgeObj->Clone();
+ pEdgeObj = pTmpEdgeObj->CloneSdrObject(pSdrPage->getSdrModelFromSdrPage());
SdrObjConnection& rConn1 = pEdgeObj->GetConnection( true );
SdrObjConnection& rConn2 = pEdgeObj->GetConnection( false );
@@ -168,25 +178,16 @@ void SvxXConnectionPreview::Construct()
SdrObject* pTmpObj1 = pTmpEdgeObj->GetConnectedNode( true );
SdrObject* pTmpObj2 = pTmpEdgeObj->GetConnectedNode( false );
- // potential memory leak here (!). Create SdrObjList only when there is
- // not yet one.
- if(!pSdrPage)
- {
- pSdrPage = new SdrPage(
- pView->getSdrModelFromSdrView(),
- false);
- }
-
if( pTmpObj1 )
{
- SdrObject* pObj1 = pTmpObj1->Clone();
+ SdrObject* pObj1 = pTmpObj1->CloneSdrObject(pSdrPage->getSdrModelFromSdrPage());
pSdrPage->InsertObject( pObj1 );
pEdgeObj->ConnectToNode( true, pObj1 );
}
if( pTmpObj2 )
{
- SdrObject* pObj2 = pTmpObj2->Clone();
+ SdrObject* pObj2 = pTmpObj2->CloneSdrObject(pSdrPage->getSdrModelFromSdrPage());
pSdrPage->InsertObject( pObj2 );
pEdgeObj->ConnectToNode( false, pObj2 );
}
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx
index 22bb53ba2d18..7388d98f3eaf 100644
--- a/svx/source/dialog/dlgctl3d.cxx
+++ b/svx/source/dialog/dlgctl3d.cxx
@@ -195,8 +195,9 @@ void Svx3DPreviewControl::SetObjectType(SvxPreviewObjectType nType)
{
aSet.Put(mp3DObj->GetMergedItemSet());
mpScene->Remove3DObj( mp3DObj );
- delete mp3DObj;
- mp3DObj = nullptr;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(mp3DObj);
+ SdrObject::Free(pTemp);
}
switch( nType )
@@ -375,7 +376,9 @@ void Svx3DLightControl::ConstructLightObjects()
if(maLightObjects[a])
{
mpScene->Remove3DObj(maLightObjects[a]);
- delete maLightObjects[a];
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(maLightObjects[a]);
+ SdrObject::Free(pTemp);
maLightObjects[a] = nullptr;
}
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index 6275842c6791..848180989269 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -325,7 +325,10 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj )
SdrCircObj* pCircObj = const_cast<SdrCircObj*>( static_cast<const SdrCircObj*>(&rObj) );
SdrPathObj* pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ) );
tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
- delete pPathObj;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pPathObj);
+ SdrObject::Free(pTemp);
IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, "", "", "", "", "", true, false );
pObj->SetExtraEllipse( aPoly.GetBoundRect() );
@@ -396,7 +399,10 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj )
pObj->SetExtraEllipse( aPoly.GetBoundRect() );
// was only created by us temporarily
- delete pPathObj;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pPathObj);
+ SdrObject::Free(pTemp);
+
pUserData->ReplaceObject( IMapObjectPtr(pObj) );
}
break;
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
index 7e9261fef802..b4fdf30ad4bb 100644
--- a/svx/source/dialog/measctrl.cxx
+++ b/svx/source/dialog/measctrl.cxx
@@ -83,7 +83,10 @@ void SvxXMeasurePreview::dispose()
// a StyleSheet of the model which was set. Thus, if You want to keep the object,
// set the model to 0L, if object is not needed (seems to be the case here),
// delete it.
- delete pMeasureObj;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pMeasureObj);
+ SdrObject::Free(pTemp);
delete pModel;
Control::dispose();
diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx
index db33f75517da..a8c92b0556b8 100644
--- a/svx/source/engine3d/cube3d.cxx
+++ b/svx/source/engine3d/cube3d.cxx
@@ -59,6 +59,10 @@ E3dCubeObj::E3dCubeObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dCubeObj::~E3dCubeObj()
+{
+}
+
void E3dCubeObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
aCubePos = rDefault.GetDefaultCubePos();
@@ -78,9 +82,9 @@ SdrObject *E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) c
return nullptr;
}
-E3dCubeObj* E3dCubeObj::Clone(SdrModel* pTargetModel) const
+E3dCubeObj* E3dCubeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dCubeObj >(pTargetModel);
+ return CloneHelper< E3dCubeObj >(rTargetModel);
}
E3dCubeObj& E3dCubeObj::operator=(const E3dCubeObj& rObj)
diff --git a/svx/source/engine3d/extrud3d.cxx b/svx/source/engine3d/extrud3d.cxx
index 3292c7092365..b28132fd3c65 100644
--- a/svx/source/engine3d/extrud3d.cxx
+++ b/svx/source/engine3d/extrud3d.cxx
@@ -80,6 +80,10 @@ E3dExtrudeObj::E3dExtrudeObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dExtrudeObj::~E3dExtrudeObj()
+{
+}
+
void E3dExtrudeObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultExtrudeSmoothed()));
@@ -98,9 +102,9 @@ sal_uInt16 E3dExtrudeObj::GetObjIdentifier() const
return E3D_EXTRUDEOBJ_ID;
}
-E3dExtrudeObj* E3dExtrudeObj::Clone(SdrModel* pTargetModel) const
+E3dExtrudeObj* E3dExtrudeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dExtrudeObj >(pTargetModel);
+ return CloneHelper< E3dExtrudeObj >(rTargetModel);
}
E3dExtrudeObj& E3dExtrudeObj::operator=(const E3dExtrudeObj& rObj)
diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx
index 4e35be70ab0e..40bfd69f276b 100644
--- a/svx/source/engine3d/lathe3d.cxx
+++ b/svx/source/engine3d/lathe3d.cxx
@@ -90,6 +90,10 @@ E3dLatheObj::E3dLatheObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dLatheObj::~E3dLatheObj()
+{
+}
+
void E3dLatheObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
@@ -104,9 +108,9 @@ sal_uInt16 E3dLatheObj::GetObjIdentifier() const
return E3D_LATHEOBJ_ID;
}
-E3dLatheObj* E3dLatheObj::Clone(SdrModel* pTargetModel) const
+E3dLatheObj* E3dLatheObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dLatheObj >(pTargetModel);
+ return CloneHelper< E3dLatheObj >(rTargetModel);
}
E3dLatheObj& E3dLatheObj::operator=(const E3dLatheObj& rObj)
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx
index 80055f7a54d9..522bf6de5e7e 100644
--- a/svx/source/engine3d/obj3d.cxx
+++ b/svx/source/engine3d/obj3d.cxx
@@ -420,9 +420,9 @@ OUString E3dObject::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralObj3d);
}
-E3dObject* E3dObject::Clone(SdrModel* pTargetModel) const
+E3dObject* E3dObject::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dObject >(pTargetModel);
+ return CloneHelper< E3dObject >(rTargetModel);
}
E3dObject& E3dObject::operator=(const E3dObject& rSource)
@@ -640,9 +640,9 @@ void E3dCompoundObject::RecalcSnapRect()
}
}
-E3dCompoundObject* E3dCompoundObject::Clone(SdrModel* pTargetModel) const
+E3dCompoundObject* E3dCompoundObject::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dCompoundObject >(pTargetModel);
+ return CloneHelper< E3dCompoundObject >(rTargetModel);
}
E3dCompoundObject& E3dCompoundObject::operator=(const E3dCompoundObject& rObj)
diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx
index bcb9ba81b9eb..68f808f5e41c 100644
--- a/svx/source/engine3d/polygn3d.cxx
+++ b/svx/source/engine3d/polygn3d.cxx
@@ -218,9 +218,9 @@ SdrObject *E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/
return nullptr;
}
-E3dPolygonObj* E3dPolygonObj::Clone(SdrModel* pTargetModel) const
+E3dPolygonObj* E3dPolygonObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dPolygonObj >(pTargetModel);
+ return CloneHelper< E3dPolygonObj >(rTargetModel);
}
E3dPolygonObj& E3dPolygonObj::operator=(const E3dPolygonObj& rObj)
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index b3c9a401e3c4..43661be94345 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -411,9 +411,9 @@ void E3dScene::removeAllNonSelectedObjects()
}
}
-E3dScene* E3dScene::Clone(SdrModel* pTargetModel) const
+E3dScene* E3dScene::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dScene >(pTargetModel);
+ return CloneHelper< E3dScene >(rTargetModel);
}
E3dScene& E3dScene::operator=(const E3dScene& rSource)
diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx
index af07d916ac4a..a3a3f0c168c1 100644
--- a/svx/source/engine3d/sphere3d.cxx
+++ b/svx/source/engine3d/sphere3d.cxx
@@ -68,6 +68,10 @@ E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dSphereObj::~E3dSphereObj()
+{
+}
+
void E3dSphereObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
// Set defaults
@@ -87,9 +91,9 @@ SdrObject *E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/)
return nullptr;
}
-E3dSphereObj* E3dSphereObj::Clone(SdrModel* pTargetModel) const
+E3dSphereObj* E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dSphereObj >(pTargetModel);
+ return CloneHelper< E3dSphereObj >(rTargetModel);
}
E3dSphereObj& E3dSphereObj::operator=(const E3dSphereObj& rObj)
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index c45a7f995649..7431cb2e875a 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -507,7 +507,7 @@ bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene const * pSrcScene, E3dSce
if(pCompoundObj)
{
- E3dCompoundObject* pNewCompoundObj = pCompoundObj->Clone();
+ E3dCompoundObject* pNewCompoundObj(pCompoundObj->CloneSdrObject(pDstScene->getSdrModelFromSdrObject()));
if(pNewCompoundObj)
{
@@ -997,7 +997,9 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
else
{
// No 3D object was created, throw away everything
- delete pScene;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pScene);
+ SdrObject::Free(pTemp);
}
EndUndo();
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index 3466b5d92f74..8b3ee18c806f 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -357,9 +357,9 @@ void FmFormObj::clonedFrom(const FmFormObj* _pSource)
}
-FmFormObj* FmFormObj::Clone(SdrModel* pTargetModel) const
+FmFormObj* FmFormObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- FmFormObj* pFormObject = CloneHelper< FmFormObj >(pTargetModel);
+ FmFormObj* pFormObject = CloneHelper< FmFormObj >(rTargetModel);
DBG_ASSERT(pFormObject != nullptr, "FmFormObj::Clone : invalid clone !");
if (pFormObject)
pFormObject->clonedFrom(this);
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
index fe94dcfd9245..8b4718ae2da4 100644
--- a/svx/source/form/fmpage.cxx
+++ b/svx/source/form/fmpage.cxx
@@ -68,9 +68,9 @@ FmFormPage::~FmFormPage()
{
}
-SdrPage* FmFormPage::Clone(SdrModel* pNewModelel) const
+SdrPage* FmFormPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- FmFormModel& rFmFormModel(static_cast< FmFormModel& >(nullptr == pNewModelel ? getSdrModelFromSdrPage() : *pNewModelel));
+ FmFormModel& rFmFormModel(static_cast< FmFormModel& >(rTargetModel));
FmFormPage* pClonedFmFormPage(
new FmFormPage(
rFmFormModel,
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index ff339be116f2..9547171a9ef6 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1575,7 +1575,7 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
bool bNeedLabel = ( _nControlObjectID != OBJ_FM_CHECKBOX );
// the label
- ::std::unique_ptr< SdrUnoObj > pLabel;
+ ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pLabel;
Reference< XPropertySet > xLabelModel;
if ( bNeedLabel )
@@ -1613,7 +1613,7 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
}
// the control
- ::std::unique_ptr< SdrUnoObj > pControl( dynamic_cast< SdrUnoObj* >(
+ ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pControl( dynamic_cast< SdrUnoObj* >(
SdrObjFactory::MakeNewObject(
*_pModel,
_nInventor,
diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx
index da9f7c6fbfd7..0533327d6aee 100644
--- a/svx/source/inc/fmobj.hxx
+++ b/svx/source/inc/fmobj.hxx
@@ -46,6 +46,10 @@ class SVX_DLLPUBLIC FmFormObj : public SdrUnoObj
// the last ref device we know, as set at the model
// only to be used for comparison with the current ref device!
+protected:
+ // protected destructor
+ SAL_DLLPRIVATE virtual ~FmFormObj() override;
+
public:
FmFormObj(
SdrModel& rSdrModel,
@@ -66,15 +70,13 @@ public:
SAL_DLLPRIVATE void ClearObjEnv();
public:
- SAL_DLLPRIVATE virtual ~FmFormObj() override;
SAL_DLLPRIVATE virtual void SetPage(SdrPage* pNewPage) override;
SAL_DLLPRIVATE virtual SdrInventor GetObjInventor() const override;
SAL_DLLPRIVATE virtual sal_uInt16 GetObjIdentifier() const override;
SAL_DLLPRIVATE virtual void NbcReformatText() override;
- SAL_DLLPRIVATE virtual FmFormObj* Clone(SdrModel* pTargetModel = nullptr) const override;
- // #116235# virtual SdrObject* Clone(SdrPage* pPage, SdrModel* pModel) const;
+ SAL_DLLPRIVATE virtual FmFormObj* CloneSdrObject(SdrModel& rTargetModel) const override;
SAL_DLLPRIVATE FmFormObj& operator= (const FmFormObj& rObj);
SAL_DLLPRIVATE void clonedFrom(const FmFormObj* _pSource);
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
index 67161c73fe72..dcb7f0b90d0f 100644
--- a/svx/source/sdr/contact/viewcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -240,13 +240,13 @@ namespace sdr
// needed and can be deleted.
// create temp RectObj as TextObj and set needed attributes
- SdrRectObj aRectObj(GetGrafObject().getSdrModelFromSdrObject(), OBJ_TEXT);
- aRectObj.NbcSetText(aDraftText);
- aRectObj.SetMergedItem(SvxColorItem(COL_LIGHTRED, EE_CHAR_COLOR));
+ SdrRectObj* pRectObj(new SdrRectObj(GetGrafObject().getSdrModelFromSdrObject(), OBJ_TEXT));
+ pRectObj->NbcSetText(aDraftText);
+ pRectObj->SetMergedItem(SvxColorItem(COL_LIGHTRED, EE_CHAR_COLOR));
// get SdrText and OPO
- SdrText* pSdrText = aRectObj.getText(0);
- OutlinerParaObject* pOPO = aRectObj.GetOutlinerParaObject();
+ SdrText* pSdrText(pRectObj->getText(0));
+ OutlinerParaObject* pOPO(pRectObj->GetOutlinerParaObject());
if(pSdrText && pOPO)
{
@@ -272,6 +272,10 @@ namespace sdr
const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
xBlockTextPrimitive->get2DDecomposition(xRetval, aViewInformation2D);
}
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pRectObj);
+ SdrObject::Free(pTemp);
}
return xRetval;
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index a1529088dbae..9a495596b372 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -727,7 +727,7 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
// #i101648# check if dragged object is a naked SdrObject (not
// a derivation). This is e.g. used in SW Frame construction
- // as placeholder. Do not use SolidDragging for naked SDrObjects,
+ // as placeholder. Do not use SolidDragging for naked SdrObjects,
// they cannot have a valid optical representation
if(bUseSolidDragging && OBJ_NONE == pCurrentCreate->GetObjIdentifier())
{
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 430d98006fa5..2bc2c74e49e5 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -3587,8 +3587,7 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
// there are currently no easy mechanisms to plug an alternative interaction
// from there
SdrObject* pSdrObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
- struct SdrObjDeleter { void operator()(SdrObject* b) { SdrObject::Free(b); }};
- std::unique_ptr< SdrObject, SdrObjDeleter > pFullDragClone;
+ std::unique_ptr< SdrObject, SdrObjectFreeOp > pFullDragClone;
bool bExternal(false);
SdrObject* pExternalSdrObject(nullptr);
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index f19c01479069..78ade77c3c49 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -899,7 +899,8 @@ void SdrEditView::CopyMarkedObj()
const size_t nMarkCount=aSourceObjectsForCopy.GetMarkCount();
for (size_t nm=0; nm<nMarkCount; ++nm) {
SdrMark* pM=aSourceObjectsForCopy.GetMark(nm);
- SdrObject* pO=pM->GetMarkedSdrObj()->Clone();
+ SdrObject* pSource(pM->GetMarkedSdrObj());
+ SdrObject* pO(pSource->CloneSdrObject(pSource->getSdrModelFromSdrObject()));
if (pO!=nullptr) {
pM->GetPageView()->GetObjList()->InsertObject(pO, SAL_MAX_SIZE);
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 551079c0ce0b..53f109ad414d 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -1588,7 +1588,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
if(pReplacement)
{
- SdrObject* pCandidate = pReplacement->Clone();
+ SdrObject* pCandidate(pReplacement->CloneSdrObject(pReplacement->getSdrModelFromSdrObject()));
DBG_ASSERT(pCandidate, "SdrEditView::ImpDismantleOneObject: Could not clone SdrObject (!)");
if(pCustomShape->GetMergedItem(SDRATTR_SHADOW).GetValue())
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 3f3a93565979..453cadd612b2 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -513,7 +513,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
{
SdrObject* pCandidate = aIter.Next();
OSL_ENSURE(pCandidate && dynamic_cast< SdrObjGroup* >(pCandidate) == nullptr, "SdrObjListIter with SdrIterMode::DeepNoGroups error (!)");
- SdrObject* pNewClone = pCandidate->Clone();
+ SdrObject* pNewClone(pCandidate->CloneSdrObject(pCandidate->getSdrModelFromSdrObject()));
if(pNewClone)
{
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 47fdc5fa4e92..5be0dffeac55 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1479,7 +1479,7 @@ void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
const SdrPage* pPg1=GetPage(nPageNum2);
// Clone to local model
- pPg=pPg1->Clone();
+ pPg = pPg1->CloneSdrPage(*this);
InsertPage(pPg,nDestNum);
if (bUndo)
@@ -1585,7 +1585,7 @@ void SdrModel::Merge(SdrModel& rSourceModel,
{
// Always Clone to new model
const SdrPage* pPg1(rSourceModel.GetMasterPage(i));
- SdrPage* pPg(pPg1->Clone(this));
+ SdrPage* pPg(pPg1->CloneSdrPage(*this));
if(!bTreadSourceAsConst)
{
@@ -1618,7 +1618,7 @@ void SdrModel::Merge(SdrModel& rSourceModel,
{
// Always Clone to new model
const SdrPage* pPg1(rSourceModel.GetPage(nSourcePos));
- SdrPage* pPg(pPg1->Clone(this));
+ SdrPage* pPg(pPg1->CloneSdrPage(*this));
if(!bTreadSourceAsConst)
{
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 0479eb198dcd..e4fb279d5970 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -217,7 +217,7 @@ SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemS
const sal_Int32 nYDist(rOriginalSet.Get(SDRATTR_SHADOWYDIST).GetValue());
const ::Color aShadowColor(rOriginalSet.Get(SDRATTR_SHADOWCOLOR).GetColorValue());
const sal_uInt16 nShadowTransparence(rOriginalSet.Get(SDRATTR_SHADOWTRANSPARENCE).GetValue());
- pRetval = rOriginal.Clone();
+ pRetval = rOriginal.CloneSdrObject(rOriginal.getSdrModelFromSdrObject());
DBG_ASSERT(pRetval, "ImpCreateShadowObjectClone: Could not clone object (!)");
// look for used stuff
@@ -2737,9 +2737,9 @@ void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject
InvalidateRenderGeometry();
}
-SdrObjCustomShape* SdrObjCustomShape::Clone(SdrModel* pTargetModel) const
+SdrObjCustomShape* SdrObjCustomShape::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrObjCustomShape >(pTargetModel);
+ return CloneHelper< SdrObjCustomShape >(rTargetModel);
}
SdrObjCustomShape& SdrObjCustomShape::operator=(const SdrObjCustomShape& rObj)
@@ -2807,7 +2807,7 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co
if ( pRenderedCustomShape )
{
// Clone to same SdrModel
- SdrObject* pCandidate = pRenderedCustomShape->Clone();
+ SdrObject* pCandidate(pRenderedCustomShape->CloneSdrObject(pRenderedCustomShape->getSdrModelFromSdrObject()));
DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
SdrObject::Free( pCandidate );
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index dbe1b1b66c2e..2e2b74aef7f9 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -941,9 +941,9 @@ bool SdrObject::HasLimitedRotation() const
return false;
}
-SdrObject* SdrObject::Clone(SdrModel* pTargetModel) const
+SdrObject* SdrObject::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrObject >(pTargetModel);
+ return CloneHelper< SdrObject >(rTargetModel);
}
SdrObject& SdrObject::operator=(const SdrObject& rObj)
@@ -954,7 +954,7 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
mpProperties.reset();
mpViewContact.reset();
- // The Clone() method uses the local copy constructor from the individual
+ // 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);
@@ -1053,7 +1053,7 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
// create cloned object without text, but with drawing::LineStyle_SOLID,
// COL_BLACK as line color and drawing::FillStyle_NONE
- SdrObject* pClone = Clone();
+ SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
if(pClone)
{
@@ -1128,7 +1128,8 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
}
}
- delete pClone;
+ // Always use SdrObject::Free to delete SdrObjects (!)
+ SdrObject::Free(pClone);
}
return aRetval;
@@ -1266,7 +1267,7 @@ bool SdrObject::supportsFullDrag() const
SdrObject* SdrObject::getFullDragClone() const
{
// default uses simple clone
- return Clone();
+ return CloneSdrObject(getSdrModelFromSdrObject());
}
bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
@@ -2411,7 +2412,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
aSet.Put(XLineWidthItem(0));
- SdrObject* pClone = Clone();
+ SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
pClone->SetMergedItemSet(aSet);
pGroup->GetSubList()->NbcInsertObject(pClone);
@@ -2446,7 +2447,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
if(nullptr == pRetval)
{
// due to current method usage, create and return a clone when nothing has changed
- SdrObject* pClone = Clone();
+ SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
pRetval = pClone;
}
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index 035582dda722..69a65fb1e68b 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -235,9 +235,9 @@ sal_uInt16 SdrCaptionObj::GetObjIdentifier() const
return sal_uInt16(OBJ_CAPTION);
}
-SdrCaptionObj* SdrCaptionObj::Clone(SdrModel* pTargetModel) const
+SdrCaptionObj* SdrCaptionObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrCaptionObj >(pTargetModel);
+ return CloneHelper< SdrCaptionObj >(rTargetModel);
}
SdrCaptionObj& SdrCaptionObj::operator=(const SdrCaptionObj& rObj)
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 1738eb167562..e55f79183d18 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -348,9 +348,9 @@ OUString SdrCircObj::TakeObjNamePlural() const
return SvxResId(pID);
}
-SdrCircObj* SdrCircObj::Clone(SdrModel* pTargetModel) const
+SdrCircObj* SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrCircObj >(pTargetModel);
+ return CloneHelper< SdrCircObj >(rTargetModel);
}
SdrCircObj& SdrCircObj::operator=(const SdrCircObj& rObj)
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index c044e6f013f1..575b31e5e719 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1616,9 +1616,9 @@ void SdrEdgeObj::Reformat()
}
}
-SdrEdgeObj* SdrEdgeObj::Clone(SdrModel* pTargetModel) const
+SdrEdgeObj* SdrEdgeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrEdgeObj >(pTargetModel);
+ return CloneHelper< SdrEdgeObj >(rTargetModel);
}
SdrEdgeObj& SdrEdgeObj::operator=(const SdrEdgeObj& rObj)
@@ -1808,7 +1808,7 @@ bool SdrEdgeObj::hasSpecialDrag() const
SdrObject* SdrEdgeObj::getFullDragClone() const
{
// use Clone operator
- SdrEdgeObj* pRetval = Clone();
+ SdrEdgeObj* pRetval(CloneSdrObject(getSdrModelFromSdrObject()));
// copy connections for clone, SdrEdgeObj::operator= does not do this
pRetval->ConnectToNode(true, GetConnectedNode(true));
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 296027c96386..1f623faeffe9 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -874,9 +874,9 @@ SdrObject* SdrGrafObj::getFullDragClone() const
return pRetval;
}
-SdrGrafObj* SdrGrafObj::Clone(SdrModel* pTargetModel) const
+SdrGrafObj* SdrGrafObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrGrafObj >(pTargetModel);
+ return CloneHelper< SdrGrafObj >(rTargetModel);
}
SdrGrafObj& SdrGrafObj::operator=( const SdrGrafObj& rObj )
@@ -1148,7 +1148,9 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
}
else
{
- delete pGrp;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGrp);
+ SdrObject::Free(pTemp);
}
// #i118485# convert line and fill
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index 60c66de5bc3e..8969b5713f24 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -202,9 +202,9 @@ const tools::Rectangle& SdrObjGroup::GetSnapRect() const
}
}
-SdrObjGroup* SdrObjGroup::Clone(SdrModel* pTargetModel) const
+SdrObjGroup* SdrObjGroup::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrObjGroup >(pTargetModel);
+ return CloneHelper< SdrObjGroup >(rTargetModel);
}
SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj)
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 64b1db6891ae..a7cbdda2297d 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -701,9 +701,9 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
}
}
-SdrMeasureObj* SdrMeasureObj::Clone(SdrModel* pTargetModel) const
+SdrMeasureObj* SdrMeasureObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrMeasureObj >(pTargetModel);
+ return CloneHelper< SdrMeasureObj >(rTargetModel);
}
SdrMeasureObj& SdrMeasureObj::operator=(const SdrMeasureObj& rObj)
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 8a2d04f12523..6767d05eb7d4 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -142,9 +142,9 @@ OUString SdrMediaObj::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralMEDIA);
}
-SdrMediaObj* SdrMediaObj::Clone(SdrModel* pTargetModel) const
+SdrMediaObj* SdrMediaObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrMediaObj >(pTargetModel);
+ return CloneHelper< SdrMediaObj >(rTargetModel);
}
SdrMediaObj& SdrMediaObj::operator=(const SdrMediaObj& rObj)
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 8587f34205bd..30a41a8b4cd1 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1391,9 +1391,9 @@ OUString SdrOle2Obj::TakeObjNamePlural() const
return SvxResId(mpImpl->mbFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
}
-SdrOle2Obj* SdrOle2Obj::Clone(SdrModel* pTargetModel) const
+SdrOle2Obj* SdrOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrOle2Obj >(pTargetModel);
+ return CloneHelper< SdrOle2Obj >(rTargetModel);
}
SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj)
diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx
index bd5f595c3a9d..c9dfa21838de 100644
--- a/svx/source/svdraw/svdopage.cxx
+++ b/svx/source/svdraw/svdopage.cxx
@@ -150,9 +150,9 @@ void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
rInfo.bCanConvToPolyLineToArea=false;
}
-SdrPageObj* SdrPageObj::Clone(SdrModel* pTargetModel) const
+SdrPageObj* SdrPageObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrPageObj >(pTargetModel);
+ return CloneHelper< SdrPageObj >(rTargetModel);
}
SdrPageObj& SdrPageObj::operator=(const SdrPageObj& rObj)
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 01e5df703421..1e8257906e70 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1828,9 +1828,9 @@ sal_uInt16 SdrPathObj::GetObjIdentifier() const
return sal_uInt16(meKind);
}
-SdrPathObj* SdrPathObj::Clone(SdrModel* pTargetModel) const
+SdrPathObj* SdrPathObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrPathObj >(pTargetModel);
+ return CloneHelper< SdrPathObj >(rTargetModel);
}
SdrPathObj& SdrPathObj::operator=(const SdrPathObj& rObj)
@@ -2676,7 +2676,7 @@ SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
basegfx::B2DPolygon aSplitPolyA(aCandidate, 0L, nPnt + 1);
SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyA));
- pNewObj = Clone();
+ pNewObj = CloneSdrObject(getSdrModelFromSdrObject());
basegfx::B2DPolygon aSplitPolyB(aCandidate, nPnt, nPointCount - nPnt);
pNewObj->SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyB));
}
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index 7aebe89c3d7a..c9f8ee955e3b 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -259,9 +259,9 @@ OUString SdrRectObj::TakeObjNamePlural() const
return SvxResId(pResId);
}
-SdrRectObj* SdrRectObj::Clone(SdrModel* pTargetModel) const
+SdrRectObj* SdrRectObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrRectObj >(pTargetModel);
+ return CloneHelper< SdrRectObj >(rTargetModel);
}
SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy)
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index d45af2c7b181..e89dfff7eeb3 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -570,7 +570,7 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle
if(bShadowOn)
{
// force shadow off
- SdrObject* pCopy = Clone();
+ SdrObject* pCopy(CloneSdrObject(getSdrModelFromSdrObject()));
pCopy->SetMergedItem(makeSdrShadowItem(false));
*pContourPolyPolygon = pCopy->TakeContour();
SdrObject::Free( pCopy );
@@ -1010,9 +1010,9 @@ OUString SdrTextObj::TakeObjNamePlural() const
return sName;
}
-SdrTextObj* SdrTextObj::Clone(SdrModel* pTargetModel) const
+SdrTextObj* SdrTextObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrTextObj >(pTargetModel);
+ return CloneHelper< SdrTextObj >(rTargetModel);
}
SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj)
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 1a6d4a50a358..b2b3afd2fc74 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -389,12 +389,17 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
// postprocess; if no result and/or only one object, simplify
if(!pObjectList->GetObjCount())
{
- delete pGroup;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGroup);
+ SdrObject::Free(pTemp);
}
else if(1 == pObjectList->GetObjCount())
{
pRetval = pObjectList->RemoveObject(0);
- delete pGroup;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGroup);
+ SdrObject::Free(pTemp);
}
else
{
diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx
index 830b5d8361f8..3a1cb78770e8 100644
--- a/svx/source/svdraw/svdouno.cxx
+++ b/svx/source/svdraw/svdouno.cxx
@@ -255,9 +255,9 @@ OUString SdrUnoObj::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralUno);
}
-SdrUnoObj* SdrUnoObj::Clone(SdrModel* pTargetModel) const
+SdrUnoObj* SdrUnoObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrUnoObj >(pTargetModel);
+ return CloneHelper< SdrUnoObj >(rTargetModel);
}
SdrUnoObj& SdrUnoObj::operator= (const SdrUnoObj& rObj)
diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx
index 4306ecd577fa..55d564dc71f2 100644
--- a/svx/source/svdraw/svdovirt.cxx
+++ b/svx/source/svdraw/svdovirt.cxx
@@ -122,11 +122,11 @@ void SdrVirtObj::RecalcBoundRect()
aOutRect+=aAnchor;
}
-SdrVirtObj* SdrVirtObj::Clone(SdrModel* pTargetModel) const
+SdrVirtObj* SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrVirtObj >(pTargetModel);
+ return CloneHelper< SdrVirtObj >(rTargetModel);
// TTTT not sure if the above works - how could SdrObjFactory::MakeNewObject
- // create an object wit correct rRefObj (?) OTOH VirtObj probably needs not
+ // 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
// return new SdrVirtObj(
// getSdrModelFromSdrObject(),
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index b5a7f81abccf..1b25b3f7df4f 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -132,15 +132,15 @@ SdrObjList::~SdrObjList()
impClearSdrObjList(false);
}
-void SdrObjList::copyDataFromSdrObjList(const SdrObjList& rSrcList, SdrModel* pNewModelel)
+void SdrObjList::copyDataFromSdrObjList(const SdrObjList& rSrcList)
{
// this function is only supposed to be called once, right after construction
assert(maList.empty());
eListKind=rSrcList.eListKind;
- CopyObjects(rSrcList, pNewModelel);
+ CopyObjects(rSrcList);
}
-void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModelel)
+void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
{
// clear SdrObjects with broadcasting
ClearSdrObjList();
@@ -150,10 +150,20 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModelel)
size_t nCloneErrCnt(0);
const size_t nCount(rSrcList.GetObjCount());
+ if(nullptr == GetOwnerObj() && nullptr == GetPage())
+ {
+ OSL_ENSURE(false, "SdrObjList which is not part of SdrPage or SdrObject (!)");
+ return;
+ }
+
+ SdrModel& rTargetSdrModel(nullptr == GetOwnerObj()
+ ? GetPage()->getSdrModelFromSdrPage()
+ : GetOwnerObj()->getSdrModelFromSdrObject());
+
for (size_t no(0); no < nCount; ++no)
{
SdrObject* pSO(rSrcList.GetObj(no));
- SdrObject* pDO(pSO->Clone(pNewModelel));
+ SdrObject* pDO(pSO->CloneSdrObject(rTargetSdrModel));
if(nullptr != pDO)
{
@@ -1217,16 +1227,16 @@ void SdrPage::lateInit(const SdrPage& rSrcPage)
}
// Now copy the contained objects
- SdrObjList::copyDataFromSdrObjList(rSrcPage, &getSdrModelFromSdrPage());
+ SdrObjList::copyDataFromSdrObjList(rSrcPage);
// be careful and correct eListKind, a member of SdrObjList which
// will be changed by the SdrObjList::lateInit before...
eListKind = (mbMaster) ? SdrObjListKind::MasterPage : SdrObjListKind::DrawPage;
}
-SdrPage* SdrPage::Clone(SdrModel* pNewModelel) const
+SdrPage* SdrPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- SdrPage* pClonedPage(new SdrPage(nullptr == pNewModelel ? getSdrModelFromSdrPage() : *pNewModelel));
+ SdrPage* pClonedPage(new SdrPage(rTargetModel));
pClonedPage->lateInit(*this);
return pClonedPage;
}
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 9e7ee9b300d3..a92305d8ba8a 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -307,7 +307,7 @@ bool SdrExchangeView::Paste(
{
const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
- SdrObject* pNewObj = pSrcOb->Clone();
+ SdrObject* pNewObj(pSrcOb->CloneSdrObject(*mpModel));
if (pNewObj!=nullptr)
{
@@ -742,7 +742,7 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const
}
else
{
- pNewObj = pObj->Clone();
+ pNewObj = pObj->CloneSdrObject(*pNewModel);
pNewObj->SetPage( pnewPage );
}
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index e90b0e8fbab0..7e64ec8956a2 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1634,9 +1634,9 @@ OUString SdrTableObj::TakeObjNamePlural() const
}
-SdrTableObj* SdrTableObj::Clone(SdrModel* pTargetModel) const
+SdrTableObj* SdrTableObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrTableObj >(pTargetModel);
+ return CloneHelper< SdrTableObj >(rTargetModel);
}
SdrTableObj& SdrTableObj::operator=(const SdrTableObj& rObj)
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index 1dadd4983cf5..d504705ce4c6 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -198,7 +198,7 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
if( pPage && pPage->GetObjCount() )
{
// Clone directly to target SdrModel
- SdrObject* pNewObject(pPage->GetObj(0)->Clone(mpDestModel));
+ SdrObject* pNewObject(pPage->GetObj(0)->CloneSdrObject(*mpDestModel));
// center shape on current view
OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice();
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index fadad482fe7f..d77df5f01276 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -200,7 +200,7 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
// 'change' a SdrObject to another SdrModel (including dangerous MigrateItemPool
// stuff), but is no longer. We need to Clone the SdrObject to the target model
// and ::Create a new SvxShape (set SdrObject there, take obver values, ...)
- SdrObject* pClonedSdrShape(pObj->Clone(&mpPage->getSdrModelFromSdrPage()));
+ SdrObject* pClonedSdrShape(pObj->CloneSdrObject(mpPage->getSdrModelFromSdrPage()));
pObj->setUnoShape(nullptr);
pClonedSdrShape->setUnoShape(xShape);
// pShape->InvalidateSdrObject();
diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx
index 1bf753bc3066..50f8363ce562 100644
--- a/svx/source/unogallery/unogaltheme.cxx
+++ b/svx/source/unogallery/unogaltheme.cxx
@@ -261,7 +261,7 @@ void SAL_CALL GalleryTheme::update( )
{
FmFormModel* pTmpModel = new FmFormModel(&pOrigModel->GetItemPool());
// Clone to new target SdrModel
- SdrPage* pNewPage = pOrigPage->Clone(pTmpModel);
+ SdrPage* pNewPage(pOrigPage->CloneSdrPage(*pTmpModel));
pTmpModel->InsertPage(pNewPage, 0);
uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pTmpModel ) );
diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 7898c68154ab..544e55973526 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -186,7 +186,9 @@ public:
class SW_DLLPUBLIC SwFlyDrawContact final : public SwContact
{
private:
- std::unique_ptr<SwFlyDrawObj> mpMasterObj;
+ typedef std::unique_ptr< SwFlyDrawObj, SdrObjectFreeOp > SwFlyDrawObjPtr;
+
+ SwFlyDrawObjPtr mpMasterObj;
void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame* pFly);
@@ -236,18 +238,19 @@ class SwDrawVirtObj : public SdrVirtObj
of original SnapRect) */
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
+ // protected destructor
+ virtual ~SwDrawVirtObj() override;
+
public:
SwDrawVirtObj(
SdrModel& rSdrModel,
SdrObject& _rNewObj,
SwDrawContact& _rDrawContact);
- virtual ~SwDrawVirtObj() override;
-
/// access to offset
virtual const Point GetOffset() const override;
- virtual SwDrawVirtObj* Clone(SdrModel* pTargetModel = nullptr) const override;
+ virtual SwDrawVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override;
SwDrawVirtObj& operator= (const SwDrawVirtObj& rObj);
/// connection to writer layout
@@ -309,6 +312,8 @@ bool CheckControlLayer( const SdrObject *pObj );
/** ContactObject for connection of formats as representatives of draw objects
in SwClient and the objects themselves in Drawing (SDrObjUserCall). */
+typedef std::unique_ptr< SwDrawVirtObj, SdrObjectFreeOp > SwDrawVirtObjPtr;
+
class SwDrawContact final : public SwContact
{
private:
@@ -317,7 +322,7 @@ class SwDrawContact final : public SwContact
SwAnchoredDrawObject maAnchoredDrawObj;
/** container for 'virtual' drawing object supporting drawing objects in headers/footers. */
- std::vector<std::unique_ptr<SwDrawVirtObj>> maDrawVirtObjs;
+ std::vector< SwDrawVirtObjPtr > maDrawVirtObjs;
/** boolean indicating set 'master' drawing
object has been cleared. */
diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx
index 7b3b50e4295d..a599a462d2bb 100644
--- a/sw/inc/dpage.hxx
+++ b/sw/inc/dpage.hxx
@@ -39,7 +39,7 @@ public:
explicit SwDPage(SwDrawModel& rNewModel, bool bMasterPage);
virtual ~SwDPage() override;
- virtual SwDPage* Clone(SdrModel* pNewModel = nullptr) const override;
+ virtual SwDPage* CloneSdrPage(SdrModel& rTargetModel) const override;
// #i3694#
// This GetOffset() method is not needed anymore, it even leads to errors.
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 58e44dc5346d..d50c9f232f94 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -126,7 +126,7 @@ SdrObject* SwDoc::CloneSdrObj( const SdrObject& rObj, bool bMoveWithinDoc,
}
// TTTT Clone directly to target SdrModel
- SdrObject *pObj = rObj.Clone(getIDocumentDrawModelAccess().GetDrawModel());
+ SdrObject *pObj(rObj.CloneSdrObject(*getIDocumentDrawModelAccess().GetDrawModel()));
if( bMoveWithinDoc && SdrInventor::FmForm == pObj->GetObjInventor() )
{
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index c690b2514156..de8d91615722 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -80,6 +80,7 @@ namespace
struct VirtObjAnchoredAtFramePred
{
const SwFrame* m_pAnchorFrame;
+
// #i26791# - compare with master frame
static const SwFrame* FindFrame(const SwFrame* pFrame)
{
@@ -89,10 +90,16 @@ namespace
while(pContentFrame->IsFollow())
pContentFrame = pContentFrame->FindMaster();
return pContentFrame;
- };
- VirtObjAnchoredAtFramePred(const SwFrame* pAnchorFrame) : m_pAnchorFrame(FindFrame(pAnchorFrame)) {};
- bool operator()(const std::unique_ptr<SwDrawVirtObj>& rpDrawVirtObj)
- { return FindFrame(rpDrawVirtObj->GetAnchorFrame()) == m_pAnchorFrame; };
+ }
+
+ VirtObjAnchoredAtFramePred(const SwFrame* pAnchorFrame)
+ : m_pAnchorFrame(FindFrame(pAnchorFrame))
+ {}
+
+ bool operator()(const SwDrawVirtObjPtr& rpDrawVirtObj)
+ {
+ return FindFrame(rpDrawVirtObj->GetAnchorFrame()) == m_pAnchorFrame;
+ }
};
}
@@ -813,7 +820,7 @@ SwFrame* SwDrawContact::GetAnchorFrame(SdrObject const *const pDrawObj)
SwDrawVirtObj* SwDrawContact::AddVirtObj()
{
maDrawVirtObjs.push_back(
- std::unique_ptr<SwDrawVirtObj>(
+ SwDrawVirtObjPtr(
new SwDrawVirtObj(
GetMaster()->getSdrModelFromSdrObject(),
*GetMaster(),
@@ -1676,7 +1683,8 @@ void SwDrawContact::DisconnectObjFromLayout( SdrObject* _pDrawObj )
else
{
const auto ppVirtDrawObj(std::find_if(maDrawVirtObjs.begin(), maDrawVirtObjs.end(),
- [] (const std::unique_ptr<SwDrawVirtObj>& pObj) { return pObj->IsConnected(); }));
+ [] (const SwDrawVirtObjPtr& pObj) { return pObj->IsConnected(); }));
+
if(ppVirtDrawObj != maDrawVirtObjs.end())
{
// replace found 'virtual' drawing object by 'master' drawing
@@ -2180,10 +2188,10 @@ SwDrawVirtObj& SwDrawVirtObj::operator=( const SwDrawVirtObj& rObj )
return *this;
}
-SwDrawVirtObj* SwDrawVirtObj::Clone(SdrModel* pTargetModel) const
+SwDrawVirtObj* SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
{
SwDrawVirtObj* pObj = new SwDrawVirtObj(
- nullptr == pTargetModel ? getSdrModelFromSdrObject() : *pTargetModel,
+ rTargetModel,
rRefObj,
mrDrawContact);
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index d50a7f5780cf..cfedb393d854 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -72,9 +72,9 @@ void SwDPage::lateInit(const SwDPage& rSrcPage)
}
}
-SwDPage* SwDPage::Clone(SdrModel* const pNewModel) const
+SwDPage* SwDPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- SwDrawModel& rSwDrawModel(static_cast< SwDrawModel& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+ SwDrawModel& rSwDrawModel(static_cast< SwDrawModel& >(rTargetModel));
SwDPage* pClonedSwDPage(
new SwDPage(
rSwDrawModel,
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 849787aedc01..478bb781b116 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1362,7 +1362,7 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
}
}
- SdrObject* pNewObj = pClpObj->Clone();
+ SdrObject* pNewObj(pClpObj->CloneSdrObject(pOldObj->getSdrModelFromSdrObject()));
tools::Rectangle aOldObjRect( pOldObj->GetCurrentBoundRect() );
Size aOldObjSize( aOldObjRect.GetSize() );
tools::Rectangle aNewRect( pNewObj->GetCurrentBoundRect() );
@@ -1542,7 +1542,7 @@ bool SwFEShell::Paste(const Graphic &rGrf, const OUString& rURL)
if(dynamic_cast< SdrGrafObj* >(pObj))
{
- SdrGrafObj* pNewGrafObj = static_cast<SdrGrafObj*>(pObj->Clone());
+ SdrGrafObj* pNewGrafObj(static_cast<SdrGrafObj*>(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject())));
pNewGrafObj->SetGraphic(rGrf);
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index 6e157b1ed3db..c22ffae16251 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -40,10 +40,11 @@ protected:
// is called when RecalcBoundRect() is used
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
-public:
+ // protected destructor
+ virtual ~SwFlyDrawObj() override;
+public:
SwFlyDrawObj(SdrModel& rSdrModel);
- virtual ~SwFlyDrawObj() override;
// for instantiation of this class while loading (via factory)
virtual SdrInventor GetObjInventor() const override;
@@ -68,6 +69,9 @@ protected:
// of original SnapRect)
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
+ // protected destructor
+ virtual ~SwVirtFlyDrawObj() override;
+
public:
// for paints triggered form ExecutePrimitive
void wrap_DoPaintObject(
@@ -84,7 +88,6 @@ public:
SdrModel& rSdrModel,
SdrObject& rNew,
SwFlyFrame* pFly);
- virtual ~SwVirtFlyDrawObj() override;
// override method of base class SdrVirtObj
virtual void TakeObjInfo( SdrObjTransformInfoRec& rInfo ) const override;
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index d7b84212e52a..bcc42a8b06f8 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3389,7 +3389,7 @@ OUString SwDrawFrameFormat::GetDescription() const
{
if (pSdrObj != m_pSdrObjectCached)
{
- SdrObject * pSdrObjCopy = pSdrObj->Clone();
+ SdrObject * pSdrObjCopy(pSdrObj->CloneSdrObject(pSdrObj->getSdrModelFromSdrObject()));
SdrUndoNewObj * pSdrUndo = new SdrUndoNewObj(*pSdrObjCopy);
m_sSdrObjectCachedComment = pSdrUndo->GetComment();
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 7e6876432a67..e87b5a06dae7 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -376,8 +376,14 @@ void SwFlyFrame::FinitDrawObj()
}
}
}
- GetVirtDrawObj()->SetUserCall(nullptr); // Else calls delete of the ContactObj
- delete GetVirtDrawObj(); // Deregisters itself at the Master
+
+ // Else calls delete of the ContactObj
+ GetVirtDrawObj()->SetUserCall(nullptr);
+
+ // Deregisters itself at the Master
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(GetVirtDrawObj());
+ SdrObject::Free(pTemp);
}
void SwFlyFrame::ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow )
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index ee2f92901b1e..6497403e5421 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -196,7 +196,9 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet,
delete pGraphicStream;
}
- delete pRet;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pRet);
+ SdrObject::Free(pTemp);
}
}
else
diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx
index 2f84dc2fed6c..f9e461d8b8ba 100644
--- a/sw/source/uibase/shells/drawsh.cxx
+++ b/sw/source/uibase/shells/drawsh.cxx
@@ -138,7 +138,7 @@ void SwDrawShell::InsertPictureFromFile(SdrObject& rObject)
if (SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(&rObject))
{
- SdrGrafObj* pNewGrafObj = pSdrGrafObj->Clone();
+ SdrGrafObj* pNewGrafObj(pSdrGrafObj->CloneSdrObject(pSdrGrafObj->getSdrModelFromSdrObject()));
pNewGrafObj->SetGraphic(aGraphic);