diff options
Diffstat (limited to 'svx/source/svdraw')
25 files changed, 83 insertions, 65 deletions
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 ); } |