[Libreoffice-commits] core.git: basctl/source chart2/source cui/source include/svx reportdesign/inc reportdesign/source sc/inc sc/source sd/inc sd/source svx/source sw/inc sw/source
Armin Le Grand
Armin.Le.Grand at cib.de
Mon May 7 23:54:12 UTC 2018
basctl/source/dlged/dlgedobj.cxx | 4 -
basctl/source/dlged/dlgedpage.cxx | 4 -
basctl/source/inc/dlgedobj.hxx | 12 ++--
basctl/source/inc/dlgedpage.hxx | 2
chart2/source/controller/drawinglayer/ViewElementListProvider.cxx | 4 +
chart2/source/controller/main/ChartController_Tools.cxx | 2
cui/source/tabpages/tpline.cxx | 21 ++++++--
include/svx/cube3d.hxx | 6 ++
include/svx/extrud3d.hxx | 6 ++
include/svx/fmpage.hxx | 2
include/svx/lathe3d.hxx | 6 ++
include/svx/obj3d.hxx | 14 +++--
include/svx/polygn3d.hxx | 7 +-
include/svx/scene3d.hxx | 7 +-
include/svx/sphere3d.hxx | 6 ++
include/svx/svdoashp.hxx | 6 +-
include/svx/svdobj.hxx | 24 ++++++---
include/svx/svdocapt.hxx | 9 ++-
include/svx/svdocirc.hxx | 8 ++-
include/svx/svdoedge.hxx | 6 +-
include/svx/svdograf.hxx | 12 ++--
include/svx/svdogrp.hxx | 7 ++
include/svx/svdomeas.hxx | 6 +-
include/svx/svdomedia.hxx | 13 ++---
include/svx/svdoole2.hxx | 7 +-
include/svx/svdopage.hxx | 7 +-
include/svx/svdopath.hxx | 8 ++-
include/svx/svdorect.hxx | 7 +-
include/svx/svdotable.hxx | 8 ++-
include/svx/svdotext.hxx | 3 -
include/svx/svdouno.hxx | 8 ++-
include/svx/svdovirt.hxx | 6 +-
include/svx/svdpage.hxx | 8 +--
reportdesign/inc/RptObject.hxx | 19 +++++--
reportdesign/inc/RptPage.hxx | 2
reportdesign/source/core/api/Shape.cxx | 2
reportdesign/source/core/sdr/RptObject.cxx | 8 +--
reportdesign/source/core/sdr/RptPage.cxx | 4 -
reportdesign/source/ui/report/ReportController.cxx | 11 +++-
reportdesign/source/ui/report/ReportSection.cxx | 4 -
sc/inc/drawpage.hxx | 2
sc/source/core/data/documen9.cxx | 2
sc/source/core/data/drawpage.cxx | 4 -
sc/source/core/data/drwlayer.cxx | 6 +-
sc/source/filter/excel/xiescher.cxx | 4 -
sc/source/filter/inc/xcl97rec.hxx | 3 -
sc/source/filter/inc/xiescher.hxx | 6 --
sc/source/filter/xcl97/xcl97rec.cxx | 2
sc/source/ui/drawfunc/graphsh.cxx | 4 -
sc/source/ui/view/drawview.cxx | 2
sc/source/ui/view/viewfun7.cxx | 2
sd/inc/sdpage.hxx | 2
sd/source/core/drawdoc2.cxx | 4 -
sd/source/core/drawdoc3.cxx | 4 -
sd/source/core/sdpage2.cxx | 4 -
sd/source/filter/ppt/pptin.cxx | 2
sd/source/ui/animations/motionpathtag.cxx | 6 +-
sd/source/ui/dlg/animobjs.cxx | 22 ++++++--
sd/source/ui/func/fumorph.cxx | 12 +++-
sd/source/ui/func/fuvect.cxx | 2
sd/source/ui/sidebar/DocumentHelper.cxx | 4 -
sd/source/ui/unoidl/unomodel.cxx | 4 -
sd/source/ui/unoidl/unoobj.cxx | 5 +-
sd/source/ui/view/GraphicObjectBar.cxx | 2
sd/source/ui/view/drviews6.cxx | 3 -
sd/source/ui/view/drviews9.cxx | 2
sd/source/ui/view/sdview3.cxx | 6 +-
sd/source/ui/view/sdview4.cxx | 4 -
svx/source/core/extedit.cxx | 2
svx/source/customshapes/EnhancedCustomShape2d.cxx | 4 +
svx/source/customshapes/EnhancedCustomShape3d.cxx | 13 ++++-
svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 9 ++-
svx/source/dialog/compressgraphicdialog.cxx | 2
svx/source/dialog/connctrl.cxx | 25 +++++-----
svx/source/dialog/dlgctl3d.cxx | 9 ++-
svx/source/dialog/imapwnd.cxx | 10 +++-
svx/source/dialog/measctrl.cxx | 5 +-
svx/source/engine3d/cube3d.cxx | 8 ++-
svx/source/engine3d/extrud3d.cxx | 8 ++-
svx/source/engine3d/lathe3d.cxx | 8 ++-
svx/source/engine3d/obj3d.cxx | 8 +--
svx/source/engine3d/polygn3d.cxx | 4 -
svx/source/engine3d/scene3d.cxx | 4 -
svx/source/engine3d/sphere3d.cxx | 8 ++-
svx/source/engine3d/view3d.cxx | 6 +-
svx/source/form/fmobj.cxx | 4 -
svx/source/form/fmpage.cxx | 4 -
svx/source/form/fmvwimp.cxx | 4 -
svx/source/inc/fmobj.hxx | 8 ++-
svx/source/sdr/contact/viewcontactofgraphic.cxx | 14 +++--
svx/source/svdraw/svdcrtv.cxx | 2
svx/source/svdraw/svddrgmt.cxx | 3 -
svx/source/svdraw/svdedtv.cxx | 3 -
svx/source/svdraw/svdedtv2.cxx | 2
svx/source/svdraw/svdfmtf.cxx | 2
svx/source/svdraw/svdmodel.cxx | 6 +-
svx/source/svdraw/svdoashp.cxx | 8 +--
svx/source/svdraw/svdobj.cxx | 17 +++---
svx/source/svdraw/svdocapt.cxx | 4 -
svx/source/svdraw/svdocirc.cxx | 4 -
svx/source/svdraw/svdoedge.cxx | 6 +-
svx/source/svdraw/svdograf.cxx | 8 ++-
svx/source/svdraw/svdogrp.cxx | 4 -
svx/source/svdraw/svdomeas.cxx | 4 -
svx/source/svdraw/svdomedia.cxx | 4 -
svx/source/svdraw/svdoole2.cxx | 4 -
svx/source/svdraw/svdopage.cxx | 4 -
svx/source/svdraw/svdopath.cxx | 6 +-
svx/source/svdraw/svdorect.cxx | 4 -
svx/source/svdraw/svdotext.cxx | 6 +-
svx/source/svdraw/svdotxtr.cxx | 9 ++-
svx/source/svdraw/svdouno.cxx | 4 -
svx/source/svdraw/svdovirt.cxx | 6 +-
svx/source/svdraw/svdpage.cxx | 24 ++++++---
svx/source/svdraw/svdxcgv.cxx | 4 -
svx/source/table/svdotable.cxx | 4 -
svx/source/tbxctrls/fontworkgallery.cxx | 2
svx/source/unodraw/unopage.cxx | 2
svx/source/unogallery/unogaltheme.cxx | 2
sw/inc/dcontact.hxx | 15 ++++--
sw/inc/dpage.hxx | 2
sw/source/core/doc/doclay.cxx | 2
sw/source/core/draw/dcontact.cxx | 24 ++++++---
sw/source/core/draw/dpage.cxx | 4 -
sw/source/core/frmedt/fecopy.cxx | 4 -
sw/source/core/inc/dflyobj.hxx | 9 ++-
sw/source/core/layout/atrfrm.cxx | 2
sw/source/core/layout/fly.cxx | 10 +++-
sw/source/filter/ww8/wrtww8gr.cxx | 4 +
sw/source/uibase/shells/drawsh.cxx | 2
130 files changed, 510 insertions(+), 324 deletions(-)
New commits:
commit 91b0d2122bdee361bf5412a42d48ff051159cbf2
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date: Mon May 7 11:44:26 2018 +0200
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 at libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>
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
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list