summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
Diffstat (limited to 'svx')
-rw-r--r--svx/source/core/extedit.cxx2
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx4
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.cxx13
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx9
-rw-r--r--svx/source/dialog/compressgraphicdialog.cxx2
-rw-r--r--svx/source/dialog/connctrl.cxx25
-rw-r--r--svx/source/dialog/dlgctl3d.cxx9
-rw-r--r--svx/source/dialog/imapwnd.cxx10
-rw-r--r--svx/source/dialog/measctrl.cxx5
-rw-r--r--svx/source/engine3d/cube3d.cxx8
-rw-r--r--svx/source/engine3d/extrud3d.cxx8
-rw-r--r--svx/source/engine3d/lathe3d.cxx8
-rw-r--r--svx/source/engine3d/obj3d.cxx8
-rw-r--r--svx/source/engine3d/polygn3d.cxx4
-rw-r--r--svx/source/engine3d/scene3d.cxx4
-rw-r--r--svx/source/engine3d/sphere3d.cxx8
-rw-r--r--svx/source/engine3d/view3d.cxx6
-rw-r--r--svx/source/form/fmobj.cxx4
-rw-r--r--svx/source/form/fmpage.cxx4
-rw-r--r--svx/source/form/fmvwimp.cxx4
-rw-r--r--svx/source/inc/fmobj.hxx8
-rw-r--r--svx/source/sdr/contact/viewcontactofgraphic.cxx14
-rw-r--r--svx/source/svdraw/svdcrtv.cxx2
-rw-r--r--svx/source/svdraw/svddrgmt.cxx3
-rw-r--r--svx/source/svdraw/svdedtv.cxx3
-rw-r--r--svx/source/svdraw/svdedtv2.cxx2
-rw-r--r--svx/source/svdraw/svdfmtf.cxx2
-rw-r--r--svx/source/svdraw/svdmodel.cxx6
-rw-r--r--svx/source/svdraw/svdoashp.cxx8
-rw-r--r--svx/source/svdraw/svdobj.cxx17
-rw-r--r--svx/source/svdraw/svdocapt.cxx4
-rw-r--r--svx/source/svdraw/svdocirc.cxx4
-rw-r--r--svx/source/svdraw/svdoedge.cxx6
-rw-r--r--svx/source/svdraw/svdograf.cxx8
-rw-r--r--svx/source/svdraw/svdogrp.cxx4
-rw-r--r--svx/source/svdraw/svdomeas.cxx4
-rw-r--r--svx/source/svdraw/svdomedia.cxx4
-rw-r--r--svx/source/svdraw/svdoole2.cxx4
-rw-r--r--svx/source/svdraw/svdopage.cxx4
-rw-r--r--svx/source/svdraw/svdopath.cxx6
-rw-r--r--svx/source/svdraw/svdorect.cxx4
-rw-r--r--svx/source/svdraw/svdotext.cxx6
-rw-r--r--svx/source/svdraw/svdotxtr.cxx9
-rw-r--r--svx/source/svdraw/svdouno.cxx4
-rw-r--r--svx/source/svdraw/svdovirt.cxx6
-rw-r--r--svx/source/svdraw/svdpage.cxx24
-rw-r--r--svx/source/svdraw/svdxcgv.cxx4
-rw-r--r--svx/source/table/svdotable.cxx4
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx2
-rw-r--r--svx/source/unodraw/unopage.cxx2
-rw-r--r--svx/source/unogallery/unogaltheme.cxx2
51 files changed, 197 insertions, 128 deletions
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
index dab305257299..10b901c1d727 100644
--- a/svx/source/core/extedit.cxx
+++ b/svx/source/core/extedit.cxx
@@ -185,7 +185,7 @@ void SdrExternalToolEdit::Update(Graphic & rGraphic)
SdrPageView *const pPageView = m_pView->GetSdrPageView();
if (pPageView)
{
- SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->Clone()));
+ SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->CloneSdrObject(m_pObj->getSdrModelFromSdrObject())));
assert(pNewObj);
OUString const description =
m_pView->GetDescriptionOfMarkedObjects() + " External Edit";
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 70e2c5fb352d..b3d1c996a4f2 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -2277,7 +2277,9 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
// #i40600# if bLineGeometryNeededOnly is set, linestyle does not matter
if(!bLineGeometryNeededOnly && (drawing::LineStyle_NONE == eLineStyle) && (drawing::FillStyle_NONE == eFillStyle))
{
- delete pObj;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pObj);
+ SdrObject::Free(pTemp);
}
else
{
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index a0e2a6badba0..7741fa46b170 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -741,12 +741,19 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
// removing placeholder objects
for (std::vector< E3dCompoundObject* >::iterator aObjectListIter( aPlaceholderObjectList.begin() ); aObjectListIter != aPlaceholderObjectList.end(); )
{
- pScene->Remove3DObj( *aObjectListIter );
- delete *aObjectListIter++;
+ E3dCompoundObject* pTemp(*aObjectListIter++);
+ pScene->Remove3DObj( pTemp );
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp2(pTemp);
+ SdrObject::Free(pTemp2);
}
}
else
- delete pScene;
+ {
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pScene);
+ SdrObject::Free(pTemp);
+ }
}
return pRet;
}
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 753d43c3a0c7..003a43ff7d20 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -170,10 +170,15 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText(
pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
}
- static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pShadowGeometry->Clone(), 0 );
+
+ static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject(
+ pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()),
+ 0);
}
else
- pRenderedShape = pShadowGeometry->Clone();
+ {
+ pRenderedShape = pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject());
+ }
}
// apply text
diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx
index bfd9278767a5..3ba0bfb9ffd7 100644
--- a/svx/source/dialog/compressgraphicdialog.cxx
+++ b/svx/source/dialog/compressgraphicdialog.cxx
@@ -410,7 +410,7 @@ SdrGrafObj* CompressGraphicsDialog::GetCompressedSdrGrafObj()
{
if ( m_dResolution > 0.0 )
{
- SdrGrafObj* pNewObject = m_xGraphicObj->Clone();
+ SdrGrafObj* pNewObject(m_xGraphicObj->CloneSdrObject(m_xGraphicObj->getSdrModelFromSdrObject()));
if ( m_xReduceResolutionCB->get_active() )
{
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx
index 3b0ac0636682..a27dcf0278fd 100644
--- a/svx/source/dialog/connctrl.cxx
+++ b/svx/source/dialog/connctrl.cxx
@@ -156,8 +156,18 @@ void SvxXConnectionPreview::Construct()
if( nInv == SdrInventor::Default && nId == OBJ_EDGE )
{
bFound = true;
+
+ // potential memory leak here (!). Create SdrObjList only when there is
+ // not yet one.
+ if(!pSdrPage)
+ {
+ pSdrPage = new SdrPage(
+ pView->getSdrModelFromSdrView(),
+ false);
+ }
+
const SdrEdgeObj* pTmpEdgeObj = static_cast<const SdrEdgeObj*>(pObj);
- pEdgeObj = pTmpEdgeObj->Clone();
+ pEdgeObj = pTmpEdgeObj->CloneSdrObject(pSdrPage->getSdrModelFromSdrPage());
SdrObjConnection& rConn1 = pEdgeObj->GetConnection( true );
SdrObjConnection& rConn2 = pEdgeObj->GetConnection( false );
@@ -168,25 +178,16 @@ void SvxXConnectionPreview::Construct()
SdrObject* pTmpObj1 = pTmpEdgeObj->GetConnectedNode( true );
SdrObject* pTmpObj2 = pTmpEdgeObj->GetConnectedNode( false );
- // potential memory leak here (!). Create SdrObjList only when there is
- // not yet one.
- if(!pSdrPage)
- {
- pSdrPage = new SdrPage(
- pView->getSdrModelFromSdrView(),
- false);
- }
-
if( pTmpObj1 )
{
- SdrObject* pObj1 = pTmpObj1->Clone();
+ SdrObject* pObj1 = pTmpObj1->CloneSdrObject(pSdrPage->getSdrModelFromSdrPage());
pSdrPage->InsertObject( pObj1 );
pEdgeObj->ConnectToNode( true, pObj1 );
}
if( pTmpObj2 )
{
- SdrObject* pObj2 = pTmpObj2->Clone();
+ SdrObject* pObj2 = pTmpObj2->CloneSdrObject(pSdrPage->getSdrModelFromSdrPage());
pSdrPage->InsertObject( pObj2 );
pEdgeObj->ConnectToNode( false, pObj2 );
}
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx
index 22bb53ba2d18..7388d98f3eaf 100644
--- a/svx/source/dialog/dlgctl3d.cxx
+++ b/svx/source/dialog/dlgctl3d.cxx
@@ -195,8 +195,9 @@ void Svx3DPreviewControl::SetObjectType(SvxPreviewObjectType nType)
{
aSet.Put(mp3DObj->GetMergedItemSet());
mpScene->Remove3DObj( mp3DObj );
- delete mp3DObj;
- mp3DObj = nullptr;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(mp3DObj);
+ SdrObject::Free(pTemp);
}
switch( nType )
@@ -375,7 +376,9 @@ void Svx3DLightControl::ConstructLightObjects()
if(maLightObjects[a])
{
mpScene->Remove3DObj(maLightObjects[a]);
- delete maLightObjects[a];
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(maLightObjects[a]);
+ SdrObject::Free(pTemp);
maLightObjects[a] = nullptr;
}
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index 6275842c6791..848180989269 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -325,7 +325,10 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj )
SdrCircObj* pCircObj = const_cast<SdrCircObj*>( static_cast<const SdrCircObj*>(&rObj) );
SdrPathObj* pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ) );
tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
- delete pPathObj;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pPathObj);
+ SdrObject::Free(pTemp);
IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, "", "", "", "", "", true, false );
pObj->SetExtraEllipse( aPoly.GetBoundRect() );
@@ -396,7 +399,10 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj )
pObj->SetExtraEllipse( aPoly.GetBoundRect() );
// was only created by us temporarily
- delete pPathObj;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pPathObj);
+ SdrObject::Free(pTemp);
+
pUserData->ReplaceObject( IMapObjectPtr(pObj) );
}
break;
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
index 7e9261fef802..b4fdf30ad4bb 100644
--- a/svx/source/dialog/measctrl.cxx
+++ b/svx/source/dialog/measctrl.cxx
@@ -83,7 +83,10 @@ void SvxXMeasurePreview::dispose()
// a StyleSheet of the model which was set. Thus, if You want to keep the object,
// set the model to 0L, if object is not needed (seems to be the case here),
// delete it.
- delete pMeasureObj;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pMeasureObj);
+ SdrObject::Free(pTemp);
delete pModel;
Control::dispose();
diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx
index db33f75517da..a8c92b0556b8 100644
--- a/svx/source/engine3d/cube3d.cxx
+++ b/svx/source/engine3d/cube3d.cxx
@@ -59,6 +59,10 @@ E3dCubeObj::E3dCubeObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dCubeObj::~E3dCubeObj()
+{
+}
+
void E3dCubeObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
aCubePos = rDefault.GetDefaultCubePos();
@@ -78,9 +82,9 @@ SdrObject *E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) c
return nullptr;
}
-E3dCubeObj* E3dCubeObj::Clone(SdrModel* pTargetModel) const
+E3dCubeObj* E3dCubeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dCubeObj >(pTargetModel);
+ return CloneHelper< E3dCubeObj >(rTargetModel);
}
E3dCubeObj& E3dCubeObj::operator=(const E3dCubeObj& rObj)
diff --git a/svx/source/engine3d/extrud3d.cxx b/svx/source/engine3d/extrud3d.cxx
index 3292c7092365..b28132fd3c65 100644
--- a/svx/source/engine3d/extrud3d.cxx
+++ b/svx/source/engine3d/extrud3d.cxx
@@ -80,6 +80,10 @@ E3dExtrudeObj::E3dExtrudeObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dExtrudeObj::~E3dExtrudeObj()
+{
+}
+
void E3dExtrudeObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultExtrudeSmoothed()));
@@ -98,9 +102,9 @@ sal_uInt16 E3dExtrudeObj::GetObjIdentifier() const
return E3D_EXTRUDEOBJ_ID;
}
-E3dExtrudeObj* E3dExtrudeObj::Clone(SdrModel* pTargetModel) const
+E3dExtrudeObj* E3dExtrudeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dExtrudeObj >(pTargetModel);
+ return CloneHelper< E3dExtrudeObj >(rTargetModel);
}
E3dExtrudeObj& E3dExtrudeObj::operator=(const E3dExtrudeObj& rObj)
diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx
index 4e35be70ab0e..40bfd69f276b 100644
--- a/svx/source/engine3d/lathe3d.cxx
+++ b/svx/source/engine3d/lathe3d.cxx
@@ -90,6 +90,10 @@ E3dLatheObj::E3dLatheObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dLatheObj::~E3dLatheObj()
+{
+}
+
void E3dLatheObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
@@ -104,9 +108,9 @@ sal_uInt16 E3dLatheObj::GetObjIdentifier() const
return E3D_LATHEOBJ_ID;
}
-E3dLatheObj* E3dLatheObj::Clone(SdrModel* pTargetModel) const
+E3dLatheObj* E3dLatheObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dLatheObj >(pTargetModel);
+ return CloneHelper< E3dLatheObj >(rTargetModel);
}
E3dLatheObj& E3dLatheObj::operator=(const E3dLatheObj& rObj)
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx
index 80055f7a54d9..522bf6de5e7e 100644
--- a/svx/source/engine3d/obj3d.cxx
+++ b/svx/source/engine3d/obj3d.cxx
@@ -420,9 +420,9 @@ OUString E3dObject::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralObj3d);
}
-E3dObject* E3dObject::Clone(SdrModel* pTargetModel) const
+E3dObject* E3dObject::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dObject >(pTargetModel);
+ return CloneHelper< E3dObject >(rTargetModel);
}
E3dObject& E3dObject::operator=(const E3dObject& rSource)
@@ -640,9 +640,9 @@ void E3dCompoundObject::RecalcSnapRect()
}
}
-E3dCompoundObject* E3dCompoundObject::Clone(SdrModel* pTargetModel) const
+E3dCompoundObject* E3dCompoundObject::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dCompoundObject >(pTargetModel);
+ return CloneHelper< E3dCompoundObject >(rTargetModel);
}
E3dCompoundObject& E3dCompoundObject::operator=(const E3dCompoundObject& rObj)
diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx
index bcb9ba81b9eb..68f808f5e41c 100644
--- a/svx/source/engine3d/polygn3d.cxx
+++ b/svx/source/engine3d/polygn3d.cxx
@@ -218,9 +218,9 @@ SdrObject *E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/
return nullptr;
}
-E3dPolygonObj* E3dPolygonObj::Clone(SdrModel* pTargetModel) const
+E3dPolygonObj* E3dPolygonObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dPolygonObj >(pTargetModel);
+ return CloneHelper< E3dPolygonObj >(rTargetModel);
}
E3dPolygonObj& E3dPolygonObj::operator=(const E3dPolygonObj& rObj)
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index b3c9a401e3c4..43661be94345 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -411,9 +411,9 @@ void E3dScene::removeAllNonSelectedObjects()
}
}
-E3dScene* E3dScene::Clone(SdrModel* pTargetModel) const
+E3dScene* E3dScene::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dScene >(pTargetModel);
+ return CloneHelper< E3dScene >(rTargetModel);
}
E3dScene& E3dScene::operator=(const E3dScene& rSource)
diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx
index af07d916ac4a..a3a3f0c168c1 100644
--- a/svx/source/engine3d/sphere3d.cxx
+++ b/svx/source/engine3d/sphere3d.cxx
@@ -68,6 +68,10 @@ E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel)
SetDefaultAttributes(aDefault);
}
+E3dSphereObj::~E3dSphereObj()
+{
+}
+
void E3dSphereObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
// Set defaults
@@ -87,9 +91,9 @@ SdrObject *E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/)
return nullptr;
}
-E3dSphereObj* E3dSphereObj::Clone(SdrModel* pTargetModel) const
+E3dSphereObj* E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< E3dSphereObj >(pTargetModel);
+ return CloneHelper< E3dSphereObj >(rTargetModel);
}
E3dSphereObj& E3dSphereObj::operator=(const E3dSphereObj& rObj)
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index c45a7f995649..7431cb2e875a 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -507,7 +507,7 @@ bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene const * pSrcScene, E3dSce
if(pCompoundObj)
{
- E3dCompoundObject* pNewCompoundObj = pCompoundObj->Clone();
+ E3dCompoundObject* pNewCompoundObj(pCompoundObj->CloneSdrObject(pDstScene->getSdrModelFromSdrObject()));
if(pNewCompoundObj)
{
@@ -997,7 +997,9 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
else
{
// No 3D object was created, throw away everything
- delete pScene;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pScene);
+ SdrObject::Free(pTemp);
}
EndUndo();
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index 3466b5d92f74..8b3ee18c806f 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -357,9 +357,9 @@ void FmFormObj::clonedFrom(const FmFormObj* _pSource)
}
-FmFormObj* FmFormObj::Clone(SdrModel* pTargetModel) const
+FmFormObj* FmFormObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- FmFormObj* pFormObject = CloneHelper< FmFormObj >(pTargetModel);
+ FmFormObj* pFormObject = CloneHelper< FmFormObj >(rTargetModel);
DBG_ASSERT(pFormObject != nullptr, "FmFormObj::Clone : invalid clone !");
if (pFormObject)
pFormObject->clonedFrom(this);
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
index fe94dcfd9245..8b4718ae2da4 100644
--- a/svx/source/form/fmpage.cxx
+++ b/svx/source/form/fmpage.cxx
@@ -68,9 +68,9 @@ FmFormPage::~FmFormPage()
{
}
-SdrPage* FmFormPage::Clone(SdrModel* pNewModelel) const
+SdrPage* FmFormPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- FmFormModel& rFmFormModel(static_cast< FmFormModel& >(nullptr == pNewModelel ? getSdrModelFromSdrPage() : *pNewModelel));
+ FmFormModel& rFmFormModel(static_cast< FmFormModel& >(rTargetModel));
FmFormPage* pClonedFmFormPage(
new FmFormPage(
rFmFormModel,
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index ff339be116f2..9547171a9ef6 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1575,7 +1575,7 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
bool bNeedLabel = ( _nControlObjectID != OBJ_FM_CHECKBOX );
// the label
- ::std::unique_ptr< SdrUnoObj > pLabel;
+ ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pLabel;
Reference< XPropertySet > xLabelModel;
if ( bNeedLabel )
@@ -1613,7 +1613,7 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
}
// the control
- ::std::unique_ptr< SdrUnoObj > pControl( dynamic_cast< SdrUnoObj* >(
+ ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pControl( dynamic_cast< SdrUnoObj* >(
SdrObjFactory::MakeNewObject(
*_pModel,
_nInventor,
diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx
index da9f7c6fbfd7..0533327d6aee 100644
--- a/svx/source/inc/fmobj.hxx
+++ b/svx/source/inc/fmobj.hxx
@@ -46,6 +46,10 @@ class SVX_DLLPUBLIC FmFormObj : public SdrUnoObj
// the last ref device we know, as set at the model
// only to be used for comparison with the current ref device!
+protected:
+ // protected destructor
+ SAL_DLLPRIVATE virtual ~FmFormObj() override;
+
public:
FmFormObj(
SdrModel& rSdrModel,
@@ -66,15 +70,13 @@ public:
SAL_DLLPRIVATE void ClearObjEnv();
public:
- SAL_DLLPRIVATE virtual ~FmFormObj() override;
SAL_DLLPRIVATE virtual void SetPage(SdrPage* pNewPage) override;
SAL_DLLPRIVATE virtual SdrInventor GetObjInventor() const override;
SAL_DLLPRIVATE virtual sal_uInt16 GetObjIdentifier() const override;
SAL_DLLPRIVATE virtual void NbcReformatText() override;
- SAL_DLLPRIVATE virtual FmFormObj* Clone(SdrModel* pTargetModel = nullptr) const override;
- // #116235# virtual SdrObject* Clone(SdrPage* pPage, SdrModel* pModel) const;
+ SAL_DLLPRIVATE virtual FmFormObj* CloneSdrObject(SdrModel& rTargetModel) const override;
SAL_DLLPRIVATE FmFormObj& operator= (const FmFormObj& rObj);
SAL_DLLPRIVATE void clonedFrom(const FmFormObj* _pSource);
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
index 67161c73fe72..dcb7f0b90d0f 100644
--- a/svx/source/sdr/contact/viewcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -240,13 +240,13 @@ namespace sdr
// needed and can be deleted.
// create temp RectObj as TextObj and set needed attributes
- SdrRectObj aRectObj(GetGrafObject().getSdrModelFromSdrObject(), OBJ_TEXT);
- aRectObj.NbcSetText(aDraftText);
- aRectObj.SetMergedItem(SvxColorItem(COL_LIGHTRED, EE_CHAR_COLOR));
+ SdrRectObj* pRectObj(new SdrRectObj(GetGrafObject().getSdrModelFromSdrObject(), OBJ_TEXT));
+ pRectObj->NbcSetText(aDraftText);
+ pRectObj->SetMergedItem(SvxColorItem(COL_LIGHTRED, EE_CHAR_COLOR));
// get SdrText and OPO
- SdrText* pSdrText = aRectObj.getText(0);
- OutlinerParaObject* pOPO = aRectObj.GetOutlinerParaObject();
+ SdrText* pSdrText(pRectObj->getText(0));
+ OutlinerParaObject* pOPO(pRectObj->GetOutlinerParaObject());
if(pSdrText && pOPO)
{
@@ -272,6 +272,10 @@ namespace sdr
const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
xBlockTextPrimitive->get2DDecomposition(xRetval, aViewInformation2D);
}
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pRectObj);
+ SdrObject::Free(pTemp);
}
return xRetval;
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index a1529088dbae..9a495596b372 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -727,7 +727,7 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
// #i101648# check if dragged object is a naked SdrObject (not
// a derivation). This is e.g. used in SW Frame construction
- // as placeholder. Do not use SolidDragging for naked SDrObjects,
+ // as placeholder. Do not use SolidDragging for naked SdrObjects,
// they cannot have a valid optical representation
if(bUseSolidDragging && OBJ_NONE == pCurrentCreate->GetObjIdentifier())
{
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 430d98006fa5..2bc2c74e49e5 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -3587,8 +3587,7 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
// there are currently no easy mechanisms to plug an alternative interaction
// from there
SdrObject* pSdrObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
- struct SdrObjDeleter { void operator()(SdrObject* b) { SdrObject::Free(b); }};
- std::unique_ptr< SdrObject, SdrObjDeleter > pFullDragClone;
+ std::unique_ptr< SdrObject, SdrObjectFreeOp > pFullDragClone;
bool bExternal(false);
SdrObject* pExternalSdrObject(nullptr);
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index f19c01479069..78ade77c3c49 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -899,7 +899,8 @@ void SdrEditView::CopyMarkedObj()
const size_t nMarkCount=aSourceObjectsForCopy.GetMarkCount();
for (size_t nm=0; nm<nMarkCount; ++nm) {
SdrMark* pM=aSourceObjectsForCopy.GetMark(nm);
- SdrObject* pO=pM->GetMarkedSdrObj()->Clone();
+ SdrObject* pSource(pM->GetMarkedSdrObj());
+ SdrObject* pO(pSource->CloneSdrObject(pSource->getSdrModelFromSdrObject()));
if (pO!=nullptr) {
pM->GetPageView()->GetObjList()->InsertObject(pO, SAL_MAX_SIZE);
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 551079c0ce0b..53f109ad414d 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -1588,7 +1588,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
if(pReplacement)
{
- SdrObject* pCandidate = pReplacement->Clone();
+ SdrObject* pCandidate(pReplacement->CloneSdrObject(pReplacement->getSdrModelFromSdrObject()));
DBG_ASSERT(pCandidate, "SdrEditView::ImpDismantleOneObject: Could not clone SdrObject (!)");
if(pCustomShape->GetMergedItem(SDRATTR_SHADOW).GetValue())
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 3f3a93565979..453cadd612b2 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -513,7 +513,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
{
SdrObject* pCandidate = aIter.Next();
OSL_ENSURE(pCandidate && dynamic_cast< SdrObjGroup* >(pCandidate) == nullptr, "SdrObjListIter with SdrIterMode::DeepNoGroups error (!)");
- SdrObject* pNewClone = pCandidate->Clone();
+ SdrObject* pNewClone(pCandidate->CloneSdrObject(pCandidate->getSdrModelFromSdrObject()));
if(pNewClone)
{
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 47fdc5fa4e92..5be0dffeac55 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1479,7 +1479,7 @@ void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
const SdrPage* pPg1=GetPage(nPageNum2);
// Clone to local model
- pPg=pPg1->Clone();
+ pPg = pPg1->CloneSdrPage(*this);
InsertPage(pPg,nDestNum);
if (bUndo)
@@ -1585,7 +1585,7 @@ void SdrModel::Merge(SdrModel& rSourceModel,
{
// Always Clone to new model
const SdrPage* pPg1(rSourceModel.GetMasterPage(i));
- SdrPage* pPg(pPg1->Clone(this));
+ SdrPage* pPg(pPg1->CloneSdrPage(*this));
if(!bTreadSourceAsConst)
{
@@ -1618,7 +1618,7 @@ void SdrModel::Merge(SdrModel& rSourceModel,
{
// Always Clone to new model
const SdrPage* pPg1(rSourceModel.GetPage(nSourcePos));
- SdrPage* pPg(pPg1->Clone(this));
+ SdrPage* pPg(pPg1->CloneSdrPage(*this));
if(!bTreadSourceAsConst)
{
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 0479eb198dcd..e4fb279d5970 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -217,7 +217,7 @@ SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemS
const sal_Int32 nYDist(rOriginalSet.Get(SDRATTR_SHADOWYDIST).GetValue());
const ::Color aShadowColor(rOriginalSet.Get(SDRATTR_SHADOWCOLOR).GetColorValue());
const sal_uInt16 nShadowTransparence(rOriginalSet.Get(SDRATTR_SHADOWTRANSPARENCE).GetValue());
- pRetval = rOriginal.Clone();
+ pRetval = rOriginal.CloneSdrObject(rOriginal.getSdrModelFromSdrObject());
DBG_ASSERT(pRetval, "ImpCreateShadowObjectClone: Could not clone object (!)");
// look for used stuff
@@ -2737,9 +2737,9 @@ void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject
InvalidateRenderGeometry();
}
-SdrObjCustomShape* SdrObjCustomShape::Clone(SdrModel* pTargetModel) const
+SdrObjCustomShape* SdrObjCustomShape::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrObjCustomShape >(pTargetModel);
+ return CloneHelper< SdrObjCustomShape >(rTargetModel);
}
SdrObjCustomShape& SdrObjCustomShape::operator=(const SdrObjCustomShape& rObj)
@@ -2807,7 +2807,7 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co
if ( pRenderedCustomShape )
{
// Clone to same SdrModel
- SdrObject* pCandidate = pRenderedCustomShape->Clone();
+ SdrObject* pCandidate(pRenderedCustomShape->CloneSdrObject(pRenderedCustomShape->getSdrModelFromSdrObject()));
DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
SdrObject::Free( pCandidate );
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index dbe1b1b66c2e..2e2b74aef7f9 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -941,9 +941,9 @@ bool SdrObject::HasLimitedRotation() const
return false;
}
-SdrObject* SdrObject::Clone(SdrModel* pTargetModel) const
+SdrObject* SdrObject::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrObject >(pTargetModel);
+ return CloneHelper< SdrObject >(rTargetModel);
}
SdrObject& SdrObject::operator=(const SdrObject& rObj)
@@ -954,7 +954,7 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
mpProperties.reset();
mpViewContact.reset();
- // The Clone() method uses the local copy constructor from the individual
+ // The CloneSdrObject() method uses the local copy constructor from the individual
// sdr::properties::BaseProperties class. Since the target class maybe for another
// draw object, an SdrObject needs to be provided, as in the normal constructor.
mpProperties = rObj.GetProperties().Clone(*this);
@@ -1053,7 +1053,7 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
// create cloned object without text, but with drawing::LineStyle_SOLID,
// COL_BLACK as line color and drawing::FillStyle_NONE
- SdrObject* pClone = Clone();
+ SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
if(pClone)
{
@@ -1128,7 +1128,8 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
}
}
- delete pClone;
+ // Always use SdrObject::Free to delete SdrObjects (!)
+ SdrObject::Free(pClone);
}
return aRetval;
@@ -1266,7 +1267,7 @@ bool SdrObject::supportsFullDrag() const
SdrObject* SdrObject::getFullDragClone() const
{
// default uses simple clone
- return Clone();
+ return CloneSdrObject(getSdrModelFromSdrObject());
}
bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
@@ -2411,7 +2412,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
aSet.Put(XLineWidthItem(0));
- SdrObject* pClone = Clone();
+ SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
pClone->SetMergedItemSet(aSet);
pGroup->GetSubList()->NbcInsertObject(pClone);
@@ -2446,7 +2447,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
if(nullptr == pRetval)
{
// due to current method usage, create and return a clone when nothing has changed
- SdrObject* pClone = Clone();
+ SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
pRetval = pClone;
}
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index 035582dda722..69a65fb1e68b 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -235,9 +235,9 @@ sal_uInt16 SdrCaptionObj::GetObjIdentifier() const
return sal_uInt16(OBJ_CAPTION);
}
-SdrCaptionObj* SdrCaptionObj::Clone(SdrModel* pTargetModel) const
+SdrCaptionObj* SdrCaptionObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrCaptionObj >(pTargetModel);
+ return CloneHelper< SdrCaptionObj >(rTargetModel);
}
SdrCaptionObj& SdrCaptionObj::operator=(const SdrCaptionObj& rObj)
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 1738eb167562..e55f79183d18 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -348,9 +348,9 @@ OUString SdrCircObj::TakeObjNamePlural() const
return SvxResId(pID);
}
-SdrCircObj* SdrCircObj::Clone(SdrModel* pTargetModel) const
+SdrCircObj* SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrCircObj >(pTargetModel);
+ return CloneHelper< SdrCircObj >(rTargetModel);
}
SdrCircObj& SdrCircObj::operator=(const SdrCircObj& rObj)
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index c044e6f013f1..575b31e5e719 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1616,9 +1616,9 @@ void SdrEdgeObj::Reformat()
}
}
-SdrEdgeObj* SdrEdgeObj::Clone(SdrModel* pTargetModel) const
+SdrEdgeObj* SdrEdgeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrEdgeObj >(pTargetModel);
+ return CloneHelper< SdrEdgeObj >(rTargetModel);
}
SdrEdgeObj& SdrEdgeObj::operator=(const SdrEdgeObj& rObj)
@@ -1808,7 +1808,7 @@ bool SdrEdgeObj::hasSpecialDrag() const
SdrObject* SdrEdgeObj::getFullDragClone() const
{
// use Clone operator
- SdrEdgeObj* pRetval = Clone();
+ SdrEdgeObj* pRetval(CloneSdrObject(getSdrModelFromSdrObject()));
// copy connections for clone, SdrEdgeObj::operator= does not do this
pRetval->ConnectToNode(true, GetConnectedNode(true));
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 296027c96386..1f623faeffe9 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -874,9 +874,9 @@ SdrObject* SdrGrafObj::getFullDragClone() const
return pRetval;
}
-SdrGrafObj* SdrGrafObj::Clone(SdrModel* pTargetModel) const
+SdrGrafObj* SdrGrafObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrGrafObj >(pTargetModel);
+ return CloneHelper< SdrGrafObj >(rTargetModel);
}
SdrGrafObj& SdrGrafObj::operator=( const SdrGrafObj& rObj )
@@ -1148,7 +1148,9 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
}
else
{
- delete pGrp;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGrp);
+ SdrObject::Free(pTemp);
}
// #i118485# convert line and fill
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index 60c66de5bc3e..8969b5713f24 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -202,9 +202,9 @@ const tools::Rectangle& SdrObjGroup::GetSnapRect() const
}
}
-SdrObjGroup* SdrObjGroup::Clone(SdrModel* pTargetModel) const
+SdrObjGroup* SdrObjGroup::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrObjGroup >(pTargetModel);
+ return CloneHelper< SdrObjGroup >(rTargetModel);
}
SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj)
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 64b1db6891ae..a7cbdda2297d 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -701,9 +701,9 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
}
}
-SdrMeasureObj* SdrMeasureObj::Clone(SdrModel* pTargetModel) const
+SdrMeasureObj* SdrMeasureObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrMeasureObj >(pTargetModel);
+ return CloneHelper< SdrMeasureObj >(rTargetModel);
}
SdrMeasureObj& SdrMeasureObj::operator=(const SdrMeasureObj& rObj)
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 8a2d04f12523..6767d05eb7d4 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -142,9 +142,9 @@ OUString SdrMediaObj::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralMEDIA);
}
-SdrMediaObj* SdrMediaObj::Clone(SdrModel* pTargetModel) const
+SdrMediaObj* SdrMediaObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrMediaObj >(pTargetModel);
+ return CloneHelper< SdrMediaObj >(rTargetModel);
}
SdrMediaObj& SdrMediaObj::operator=(const SdrMediaObj& rObj)
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 8587f34205bd..30a41a8b4cd1 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1391,9 +1391,9 @@ OUString SdrOle2Obj::TakeObjNamePlural() const
return SvxResId(mpImpl->mbFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
}
-SdrOle2Obj* SdrOle2Obj::Clone(SdrModel* pTargetModel) const
+SdrOle2Obj* SdrOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrOle2Obj >(pTargetModel);
+ return CloneHelper< SdrOle2Obj >(rTargetModel);
}
SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj)
diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx
index bd5f595c3a9d..c9dfa21838de 100644
--- a/svx/source/svdraw/svdopage.cxx
+++ b/svx/source/svdraw/svdopage.cxx
@@ -150,9 +150,9 @@ void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
rInfo.bCanConvToPolyLineToArea=false;
}
-SdrPageObj* SdrPageObj::Clone(SdrModel* pTargetModel) const
+SdrPageObj* SdrPageObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrPageObj >(pTargetModel);
+ return CloneHelper< SdrPageObj >(rTargetModel);
}
SdrPageObj& SdrPageObj::operator=(const SdrPageObj& rObj)
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 01e5df703421..1e8257906e70 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1828,9 +1828,9 @@ sal_uInt16 SdrPathObj::GetObjIdentifier() const
return sal_uInt16(meKind);
}
-SdrPathObj* SdrPathObj::Clone(SdrModel* pTargetModel) const
+SdrPathObj* SdrPathObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrPathObj >(pTargetModel);
+ return CloneHelper< SdrPathObj >(rTargetModel);
}
SdrPathObj& SdrPathObj::operator=(const SdrPathObj& rObj)
@@ -2676,7 +2676,7 @@ SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
basegfx::B2DPolygon aSplitPolyA(aCandidate, 0L, nPnt + 1);
SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyA));
- pNewObj = Clone();
+ pNewObj = CloneSdrObject(getSdrModelFromSdrObject());
basegfx::B2DPolygon aSplitPolyB(aCandidate, nPnt, nPointCount - nPnt);
pNewObj->SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyB));
}
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index 7aebe89c3d7a..c9f8ee955e3b 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -259,9 +259,9 @@ OUString SdrRectObj::TakeObjNamePlural() const
return SvxResId(pResId);
}
-SdrRectObj* SdrRectObj::Clone(SdrModel* pTargetModel) const
+SdrRectObj* SdrRectObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrRectObj >(pTargetModel);
+ return CloneHelper< SdrRectObj >(rTargetModel);
}
SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy)
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index d45af2c7b181..e89dfff7eeb3 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -570,7 +570,7 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle
if(bShadowOn)
{
// force shadow off
- SdrObject* pCopy = Clone();
+ SdrObject* pCopy(CloneSdrObject(getSdrModelFromSdrObject()));
pCopy->SetMergedItem(makeSdrShadowItem(false));
*pContourPolyPolygon = pCopy->TakeContour();
SdrObject::Free( pCopy );
@@ -1010,9 +1010,9 @@ OUString SdrTextObj::TakeObjNamePlural() const
return sName;
}
-SdrTextObj* SdrTextObj::Clone(SdrModel* pTargetModel) const
+SdrTextObj* SdrTextObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrTextObj >(pTargetModel);
+ return CloneHelper< SdrTextObj >(rTargetModel);
}
SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj)
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 1a6d4a50a358..b2b3afd2fc74 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -389,12 +389,17 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
// postprocess; if no result and/or only one object, simplify
if(!pObjectList->GetObjCount())
{
- delete pGroup;
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGroup);
+ SdrObject::Free(pTemp);
}
else if(1 == pObjectList->GetObjCount())
{
pRetval = pObjectList->RemoveObject(0);
- delete pGroup;
+
+ // always use SdrObject::Free(...) for SdrObjects (!)
+ SdrObject* pTemp(pGroup);
+ SdrObject::Free(pTemp);
}
else
{
diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx
index 830b5d8361f8..3a1cb78770e8 100644
--- a/svx/source/svdraw/svdouno.cxx
+++ b/svx/source/svdraw/svdouno.cxx
@@ -255,9 +255,9 @@ OUString SdrUnoObj::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralUno);
}
-SdrUnoObj* SdrUnoObj::Clone(SdrModel* pTargetModel) const
+SdrUnoObj* SdrUnoObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrUnoObj >(pTargetModel);
+ return CloneHelper< SdrUnoObj >(rTargetModel);
}
SdrUnoObj& SdrUnoObj::operator= (const SdrUnoObj& rObj)
diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx
index 4306ecd577fa..55d564dc71f2 100644
--- a/svx/source/svdraw/svdovirt.cxx
+++ b/svx/source/svdraw/svdovirt.cxx
@@ -122,11 +122,11 @@ void SdrVirtObj::RecalcBoundRect()
aOutRect+=aAnchor;
}
-SdrVirtObj* SdrVirtObj::Clone(SdrModel* pTargetModel) const
+SdrVirtObj* SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrVirtObj >(pTargetModel);
+ return CloneHelper< SdrVirtObj >(rTargetModel);
// TTTT not sure if the above works - how could SdrObjFactory::MakeNewObject
- // create an object wit correct rRefObj (?) OTOH VirtObj probably needs not
+ // create an object with correct rRefObj (?) OTOH VirtObj probably needs not
// to be cloned ever - only used in Writer for multiple instances e.g. Header/Footer
// return new SdrVirtObj(
// getSdrModelFromSdrObject(),
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index b5a7f81abccf..1b25b3f7df4f 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -132,15 +132,15 @@ SdrObjList::~SdrObjList()
impClearSdrObjList(false);
}
-void SdrObjList::copyDataFromSdrObjList(const SdrObjList& rSrcList, SdrModel* pNewModelel)
+void SdrObjList::copyDataFromSdrObjList(const SdrObjList& rSrcList)
{
// this function is only supposed to be called once, right after construction
assert(maList.empty());
eListKind=rSrcList.eListKind;
- CopyObjects(rSrcList, pNewModelel);
+ CopyObjects(rSrcList);
}
-void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModelel)
+void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
{
// clear SdrObjects with broadcasting
ClearSdrObjList();
@@ -150,10 +150,20 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModelel)
size_t nCloneErrCnt(0);
const size_t nCount(rSrcList.GetObjCount());
+ if(nullptr == GetOwnerObj() && nullptr == GetPage())
+ {
+ OSL_ENSURE(false, "SdrObjList which is not part of SdrPage or SdrObject (!)");
+ return;
+ }
+
+ SdrModel& rTargetSdrModel(nullptr == GetOwnerObj()
+ ? GetPage()->getSdrModelFromSdrPage()
+ : GetOwnerObj()->getSdrModelFromSdrObject());
+
for (size_t no(0); no < nCount; ++no)
{
SdrObject* pSO(rSrcList.GetObj(no));
- SdrObject* pDO(pSO->Clone(pNewModelel));
+ SdrObject* pDO(pSO->CloneSdrObject(rTargetSdrModel));
if(nullptr != pDO)
{
@@ -1217,16 +1227,16 @@ void SdrPage::lateInit(const SdrPage& rSrcPage)
}
// Now copy the contained objects
- SdrObjList::copyDataFromSdrObjList(rSrcPage, &getSdrModelFromSdrPage());
+ SdrObjList::copyDataFromSdrObjList(rSrcPage);
// be careful and correct eListKind, a member of SdrObjList which
// will be changed by the SdrObjList::lateInit before...
eListKind = (mbMaster) ? SdrObjListKind::MasterPage : SdrObjListKind::DrawPage;
}
-SdrPage* SdrPage::Clone(SdrModel* pNewModelel) const
+SdrPage* SdrPage::CloneSdrPage(SdrModel& rTargetModel) const
{
- SdrPage* pClonedPage(new SdrPage(nullptr == pNewModelel ? getSdrModelFromSdrPage() : *pNewModelel));
+ SdrPage* pClonedPage(new SdrPage(rTargetModel));
pClonedPage->lateInit(*this);
return pClonedPage;
}
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 9e7ee9b300d3..a92305d8ba8a 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -307,7 +307,7 @@ bool SdrExchangeView::Paste(
{
const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
- SdrObject* pNewObj = pSrcOb->Clone();
+ SdrObject* pNewObj(pSrcOb->CloneSdrObject(*mpModel));
if (pNewObj!=nullptr)
{
@@ -742,7 +742,7 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const
}
else
{
- pNewObj = pObj->Clone();
+ pNewObj = pObj->CloneSdrObject(*pNewModel);
pNewObj->SetPage( pnewPage );
}
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index e90b0e8fbab0..7e64ec8956a2 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1634,9 +1634,9 @@ OUString SdrTableObj::TakeObjNamePlural() const
}
-SdrTableObj* SdrTableObj::Clone(SdrModel* pTargetModel) const
+SdrTableObj* SdrTableObj::CloneSdrObject(SdrModel& rTargetModel) const
{
- return CloneHelper< SdrTableObj >(pTargetModel);
+ return CloneHelper< SdrTableObj >(rTargetModel);
}
SdrTableObj& SdrTableObj::operator=(const SdrTableObj& rObj)
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index 1dadd4983cf5..d504705ce4c6 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -198,7 +198,7 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
if( pPage && pPage->GetObjCount() )
{
// Clone directly to target SdrModel
- SdrObject* pNewObject(pPage->GetObj(0)->Clone(mpDestModel));
+ SdrObject* pNewObject(pPage->GetObj(0)->CloneSdrObject(*mpDestModel));
// center shape on current view
OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice();
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index fadad482fe7f..d77df5f01276 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -200,7 +200,7 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
// 'change' a SdrObject to another SdrModel (including dangerous MigrateItemPool
// stuff), but is no longer. We need to Clone the SdrObject to the target model
// and ::Create a new SvxShape (set SdrObject there, take obver values, ...)
- SdrObject* pClonedSdrShape(pObj->Clone(&mpPage->getSdrModelFromSdrPage()));
+ SdrObject* pClonedSdrShape(pObj->CloneSdrObject(mpPage->getSdrModelFromSdrPage()));
pObj->setUnoShape(nullptr);
pClonedSdrShape->setUnoShape(xShape);
// pShape->InvalidateSdrObject();
diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx
index 1bf753bc3066..50f8363ce562 100644
--- a/svx/source/unogallery/unogaltheme.cxx
+++ b/svx/source/unogallery/unogaltheme.cxx
@@ -261,7 +261,7 @@ void SAL_CALL GalleryTheme::update( )
{
FmFormModel* pTmpModel = new FmFormModel(&pOrigModel->GetItemPool());
// Clone to new target SdrModel
- SdrPage* pNewPage = pOrigPage->Clone(pTmpModel);
+ SdrPage* pNewPage(pOrigPage->CloneSdrPage(*pTmpModel));
pTmpModel->InsertPage(pNewPage, 0);
uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pTmpModel ) );