diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-06 09:14:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-06 12:50:57 +0200 |
commit | fc161dc07cafda54ebdabd4c66dfd6528cc11813 (patch) | |
tree | 81b5ccfca3793741ac74a4591f0b6605986eabe3 /svx | |
parent | dc79dc76f18148296ae18ed7251cf61505e25d44 (diff) |
use unique_ptr in DoConvertToPolyObj
Change-Id: Ia7f9ff4d8f7b9834b6634e5c126bd65014dacf19
Reviewed-on: https://gerrit.libreoffice.org/78684
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
24 files changed, 86 insertions, 93 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx index 2d53139baea4..339f99fd3b59 100644 --- a/svx/source/customshapes/EnhancedCustomShape3d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx @@ -459,11 +459,10 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( } else { - SdrObject* pNewObj = pNext->ConvertToPolyObj( false, false ); - SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj ); + SdrObjectUniquePtr pNewObj = pNext->ConvertToPolyObj( false, false ); + SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() ); if ( pPath ) aPolyPoly = pPath->GetPathPoly(); - SdrObject::Free( pNewObj ); } if( aPolyPoly.count() ) diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 95cb473a86a2..a7b08f99afc4 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -459,7 +459,6 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom while ( aIter.IsMore() ) { - SdrObject* pNewObj = nullptr; basegfx::B2DPolyPolygon aPP; const SdrObject* pNext = aIter.Next(); @@ -469,16 +468,14 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom } else { - pNewObj = pNext->ConvertToPolyObj( false, false ); - SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj ); + SdrObjectUniquePtr pNewObj = pNext->ConvertToPolyObj( false, false ); + SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() ); if ( pPath ) aPP = pPath->GetPathPoly(); } if ( aPP.count() ) aPolyPolygon.append(aPP); - - SdrObject::Free( pNewObj ); } SdrObject::Free( pObj ); basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPolygon, diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx index 3a5d0b4ea6b4..55ebd74a2d32 100644 --- a/svx/source/dialog/imapwnd.cxx +++ b/svx/source/dialog/imapwnd.cxx @@ -317,7 +317,7 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj ) case OBJ_CIRC: { SdrCircObj* pCircObj = const_cast<SdrCircObj*>( static_cast<const SdrCircObj*>(&rObj) ); - SdrPathObj* pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ) ); + SdrPathObj* pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ).release() ); tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0)); // always use SdrObject::Free(...) for SdrObjects (!) @@ -386,7 +386,7 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj ) case OBJ_CIRC: { const SdrCircObj& rCircObj = static_cast<const SdrCircObj&>(rObj); - SdrPathObj* pPathObj = static_cast<SdrPathObj*>( rCircObj.ConvertToPolyObj( false, false ) ); + SdrPathObj* pPathObj = static_cast<SdrPathObj*>( rCircObj.ConvertToPolyObj( false, false ).release() ); tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0)); IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, "", bActive, false ); diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx index 8d2758f67fc6..2a092ef89fec 100644 --- a/svx/source/engine3d/cube3d.cxx +++ b/svx/source/engine3d/cube3d.cxx @@ -78,7 +78,7 @@ sal_uInt16 E3dCubeObj::GetObjIdentifier() const // Convert the object into a group object consisting of 6 polygons -SdrObject *E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const +SdrObjectUniquePtr E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const { return nullptr; } diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx index bc5bbd32fce2..1b6b16557e9b 100644 --- a/svx/source/engine3d/lathe3d.cxx +++ b/svx/source/engine3d/lathe3d.cxx @@ -128,7 +128,7 @@ E3dLatheObj& E3dLatheObj::operator=(const E3dLatheObj& rObj) // Convert the object to group object consisting of n polygons -SdrObject *E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const +SdrObjectUniquePtr E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const { return nullptr; } diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx index d5136106ab99..b69a4ad35231 100644 --- a/svx/source/engine3d/polygn3d.cxx +++ b/svx/source/engine3d/polygn3d.cxx @@ -213,7 +213,7 @@ void E3dPolygonObj::SetPolyTexture2D(const basegfx::B2DPolyPolygon& rNewPolyText // Convert the object into a group object consisting of 6 polygons -SdrObject *E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const +SdrObjectUniquePtr E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const { return nullptr; } diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx index 4beaf3b1e811..0f5f9b5d88df 100644 --- a/svx/source/engine3d/sphere3d.cxx +++ b/svx/source/engine3d/sphere3d.cxx @@ -87,7 +87,7 @@ sal_uInt16 E3dSphereObj::GetObjIdentifier() const // Convert the object into a group object consisting of n polygons -SdrObject *E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const +SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const { return nullptr; } diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index 67b974b26cb0..832d71b42f68 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -789,7 +789,7 @@ void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, bool bExtrude ImpChangeSomeAttributesFor3DConversion(pObj); // convert completely to path objects - SdrObject* pNewObj1 = pObj->ConvertToPolyObj(false, false); + SdrObject* pNewObj1 = pObj->ConvertToPolyObj(false, false).release(); if(pNewObj1) { diff --git a/svx/source/engine3d/view3d1.cxx b/svx/source/engine3d/view3d1.cxx index b7e9830ef3d4..6f275fb2a919 100644 --- a/svx/source/engine3d/view3d1.cxx +++ b/svx/source/engine3d/view3d1.cxx @@ -56,7 +56,7 @@ void E3dView::ConvertMarkedToPolyObj() auto pScene = dynamic_cast< const E3dScene* >(pObj); if (pScene) { - pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/); + pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/).release(); if (pNewObj) { BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDE)); diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index 5a7bf23d64f4..f0836ed14f69 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -632,7 +632,7 @@ basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon1(const SdrObject* pObj) } else { - SdrObject* pConvObj = pObj->ConvertToPolyObj(true/*bCombine*/, false); + SdrObjectUniquePtr pConvObj = pObj->ConvertToPolyObj(true/*bCombine*/, false); if(pConvObj) { @@ -655,15 +655,13 @@ basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon1(const SdrObject* pObj) } else { - pPath = dynamic_cast<SdrPathObj*>( pConvObj ); + pPath = dynamic_cast<SdrPathObj*>( pConvObj.get() ); if(pPath) { aRetval = pPath->GetPathPoly(); } } - - SdrObject::Free( pConvObj ); } } @@ -1970,24 +1968,20 @@ void SdrEditView::UnGroupMarked() SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea) { - SdrObject* pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea); - if (pNewObj!=nullptr) + SdrObjectUniquePtr pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea); + if (pNewObj) { - SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject(); - DBG_ASSERT(pOL!=nullptr,"ConvertTo: Object doesn't return object list"); - if (pOL!=nullptr) - { - const bool bUndo = IsUndoEnabled(); - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj)); + SdrObjList* pOL = pObj->getParentSdrObjListFromSdrObject(); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj)); - pOL->ReplaceObject(pNewObj,pObj->GetOrdNum()); + pOL->ReplaceObject(pNewObj.get(), pObj->GetOrdNum()); - if( !bUndo ) - SdrObject::Free(pObj); - } + if( !bUndo ) + SdrObject::Free(pObj); } - return pNewObj; + return pNewObj.release(); } void SdrEditView::ImpConvertTo(bool bPath, bool bLineToArea) diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index e460361efe8d..f850e6fadf1f 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -500,7 +500,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale) // here text needs to be clipped; to do so, convert to SdrObjects with polygons // and add these recursively. Delete original object, do not add in this run - SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true); + SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true).release(); SdrObject::Free(pObj); if(pConverted) diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index d42b0d17e81e..2b5da22e606d 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2799,7 +2799,7 @@ basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const return basegfx::B2DPolyPolygon(); } -SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) const { // #i37011# SdrObjectUniquePtr pRetval; @@ -2821,7 +2821,7 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co // Clone to same SdrModel SdrObject* pCandidate(pRenderedCustomShape->CloneSdrObject(pRenderedCustomShape->getSdrModelFromSdrObject())); DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)"); - pRetval.reset(pCandidate->DoConvertToPolyObj(bBezier, bAddText)); + pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText); SdrObject::Free( pCandidate ); if(pRetval) @@ -2839,7 +2839,7 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co } } - return pRetval.release(); + return pRetval; } void SdrObjCustomShape::NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr ) diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 6b707aeae231..c1cb84e9b3c0 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -2531,15 +2531,14 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash) } -SdrObject* SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const +SdrObjectUniquePtr SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const { - SdrObject* pRet = DoConvertToPolyObj(bBezier, true); + SdrObjectUniquePtr pRet = DoConvertToPolyObj(bBezier, true); if(pRet && bLineToArea) { - SdrObject* pNewRet = ConvertToContourObj(pRet); - delete pRet; - pRet = pNewRet; + SdrObject* pNewRet = ConvertToContourObj(pRet.get()); + pRet.reset(pNewRet); } // #i73441# preserve LayerID @@ -2552,7 +2551,7 @@ SdrObject* SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const } -SdrObject* SdrObject::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const +SdrObjectUniquePtr SdrObject::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const { return nullptr; } diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index d07dccc980dc..7e104c45c321 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -694,26 +694,34 @@ void SdrCaptionObj::RestGeoData(const SdrObjGeoData& rGeo) aTailPoly=rCGeo.aTailPoly; } -SdrObject* SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const -{ - SdrObject* pRect=SdrRectObj::DoConvertToPolyObj(bBezier, bAddText); - SdrObject* pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), false, bBezier).release(); - SdrObject* pRet=(pTail!=nullptr) ? pTail : pRect; - if (pTail!=nullptr && pRect!=nullptr) { - bool bInsRect = true; - bool bInsTail = true; - SdrObjList* pOL=pTail->GetSubList(); - if (pOL!=nullptr) { pRet=pRect; bInsTail = false; } - if (pOL==nullptr) pOL=pRect->GetSubList(); - if (pOL!=nullptr) { pRet=pRect; bInsRect = false; } - if (pOL==nullptr) +SdrObjectUniquePtr SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +{ + SdrObjectUniquePtr pRect = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText); + SdrObjectUniquePtr pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), false, bBezier); + SdrObjectUniquePtr pRet; + if (pTail && !pRect) + pRet = std::move(pTail); + else if (pRect && !pTail) + pRet = std::move(pRect); + else if (pTail && pRect) + { + if (pTail->GetSubList()) + { + pTail->GetSubList()->NbcInsertObject(pRect.release()); + pRet = std::move(pTail); + } + else if (pRect->GetSubList()) + { + pRect->GetSubList()->NbcInsertObject(pTail.release(),0); + pRet = std::move(pRect); + } + else { SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject()); - pOL=pGrp->GetSubList(); - pRet=pGrp; + pGrp->GetSubList()->NbcInsertObject(pRect.release()); + pGrp->GetSubList()->NbcInsertObject(pTail.release(),0); + pRet.reset(pGrp); } - if (bInsRect) pOL->NbcInsertObject(pRect); - if (bInsTail) pOL->NbcInsertObject(pTail,0); } return pRet; } diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 6e05fce61690..29a5e54fb336 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -1147,7 +1147,7 @@ void SdrCircObj::ImpSetCircInfoToAttr() } } -SdrObject* SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { const bool bFill(meCircleKind != SdrCircKind::Arc); const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle)); @@ -1158,7 +1158,7 @@ SdrObject* SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const pRet = ImpConvertAddText(std::move(pRet), bBezier); } - return pRet.release(); + return pRet; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index 97c057836359..a06fde26b304 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -2401,7 +2401,7 @@ void SdrEdgeObj::NbcShear(const Point& rRef, long nAngle, double tn, bool bVShea } } -SdrObject* SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { basegfx::B2DPolyPolygon aPolyPolygon; aPolyPolygon.append(pEdgeTrack->getB2DPolygon()); @@ -2412,7 +2412,7 @@ SdrObject* SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const pRet = ImpConvertAddText(std::move(pRet), bBezier); } - return pRet.release(); + return pRet; } sal_uInt32 SdrEdgeObj::GetSnapPointCount() const diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 306f0543ab97..7e14a6d3bdd9 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -917,7 +917,7 @@ sal_Int32 SdrGrafObj::getEmbeddedPageNumber() const return mpGraphicObject->GetGraphic().getPageNumber(); } -SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const +SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const { SdrObject* pRetval = nullptr; GraphicType aGraphicType(GetGraphicType()); @@ -964,7 +964,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const if( pRetval ) { SdrObject* pHalfDone = pRetval; - pRetval = pHalfDone->DoConvertToPolyObj(bBezier, bAddText); + pRetval = pRetval->DoConvertToPolyObj(bBezier, bAddText).release(); SdrObject::Free( pHalfDone ); // resulting object is newly created if( pRetval ) @@ -987,7 +987,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const } // #i118485# convert line and fill - SdrObject* pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false); + SdrObjectUniquePtr pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false); if(pLineFill) { @@ -1002,11 +1002,11 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const pGrp->GetSubList()->NbcInsertObject(pRetval); } - pGrp->GetSubList()->NbcInsertObject(pLineFill, 0); + pGrp->GetSubList()->NbcInsertObject(pLineFill.release(), 0); } else { - pRetval = pLineFill; + pRetval = pLineFill.release(); } } @@ -1015,7 +1015,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const case GraphicType::Bitmap: { // create basic object and add fill - pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText); + pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText).release(); // save bitmap as an attribute if(pRetval) @@ -1035,12 +1035,12 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const case GraphicType::NONE: case GraphicType::Default: { - pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText); + pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText).release(); break; } } - return pRetval; + return SdrObjectUniquePtr(pRetval); } void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index c50ba9524908..4121332d441c 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -775,19 +775,19 @@ void SdrObjGroup::NbcReformatText() NbcReformatAllTextObjects(); } -SdrObject* SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const { - SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject()); + SdrObjectUniquePtr pGroup( new SdrObjGroup(getSdrModelFromSdrObject()) ); const size_t nObjCount(GetObjCount()); for(size_t a=0; a < nObjCount; ++a) { SdrObject* pIterObj(GetObj(a)); - SdrObject* pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText)); + SdrObjectUniquePtr pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText)); // pResult can be NULL e.g. for empty objects if( pResult ) - pGroup->GetSubList()->NbcInsertObject(pResult); + pGroup->GetSubList()->NbcInsertObject(pResult.release()); } return pGroup; diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 7f01b2074582..c992fadae228 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -1131,7 +1131,7 @@ void SdrMeasureObj::RestGeoData(const SdrObjGeoData& rGeo) SetTextDirty(); } -SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { // get XOR Poly as base XPolyPolygon aTmpPolyPolygon(TakeXorPoly()); @@ -1259,11 +1259,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const if(bAddText) { - return ImpConvertAddText(std::move(pGroup), bBezier).release(); + return ImpConvertAddText(std::move(pGroup), bBezier); } else { - return pGroup.release(); + return pGroup; } } diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index f0384fbc8d3e..604d6c8eb9a5 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -1225,15 +1225,14 @@ SdrObjectUniquePtr SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const } } -SdrObject* SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { // #i118485# missing converter added SdrObjectUniquePtr pRetval = createSdrGrafObjReplacement(true); if(pRetval) { - SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText); - return pRetval2; + return pRetval->DoConvertToPolyObj(bBezier, bAddText); } return nullptr; diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index e15e8a6b8e55..6cec19162691 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2668,7 +2668,7 @@ SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index) return pNewObj; } -SdrObject* SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { // #i89784# check for FontWork with activated HideContour const drawinglayer::attribute::SdrTextAttribute aText( @@ -2706,7 +2706,7 @@ SdrObject* SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const pRet = ImpConvertAddText(std::move(pRet), bBezier); } - return pRet.release(); + return pRet; } SdrObjGeoData* SdrPathObj::NewGeoData() const diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 43da02b4c7d2..5a4faf6b1337 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -554,7 +554,7 @@ SdrGluePoint SdrRectObj::GetCornerGluePoint(sal_uInt16 nPosNum) const return aGP; } -SdrObject* SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { XPolygon aXP(ImpCalcXPoly(maRect,GetEckenradius())); { // TODO: this is only for the moment, until we have the new TakeContour() @@ -579,7 +579,7 @@ SdrObject* SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const pRet = ImpConvertAddText(std::move(pRet), bBezier); } - return pRet.release(); + return pRet; } void SdrRectObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index d4203b212cd2..f3fe7dfe0a69 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -415,11 +415,11 @@ SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly } -SdrObject* SdrTextObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const +SdrObjectUniquePtr SdrTextObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { if(bAddText) { - return ImpConvertContainedTextToSdrPathObjs(!bBezier).release(); + return ImpConvertContainedTextToSdrPathObjs(!bBezier); } return nullptr; diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 6ac08e5e7f9d..a5f47cc94e8e 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -527,7 +527,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale) // here text needs to be clipped; to do so, convert to SdrObjects with polygons // and add these recursively. Delete original object, do not add in this run - SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true); + SdrObjectUniquePtr pConverted = pSdrTextObj->ConvertToPolyObj(true, true); SdrObject::Free(pObj); if (pConverted) @@ -557,9 +557,6 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale) OSL_ENSURE(false, "SdrObject::Clone() failed (!)"); } } - - // cleanup temporary conversion objects - SdrObject::Free(pConverted); } break; |