diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-04 15:20:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-05 10:54:28 +0200 |
commit | 518fdc296a45a2b47eb8f2c377522fb39cdcccf2 (patch) | |
tree | 443514bef2e6754129ca8f20b311e97646e5b9ee | |
parent | 724e92d6bfa9900e40546df5c05da44e9d33b856 (diff) |
use more std::unique_ptr in EnhancedCustomShapeEngine
Change-Id: Ib488b15e55492fb469258bfba59e6475dbdb058f
Reviewed-on: https://gerrit.libreoffice.org/61400
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 6a8dd7d3986e..aebd702737a1 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -72,9 +72,9 @@ class EnhancedCustomShapeEngine : public cppu::WeakImplHelper css::uno::Reference< css::drawing::XShape > mxShape; bool mbForceGroupWithText; - SdrObject* ImplForceGroupWithText( + std::unique_ptr<SdrObject, SdrObjectFreeOp> ImplForceGroupWithText( const SdrObjCustomShape& rSdrObjCustomShape, - SdrObject* pRenderedShape); + std::unique_ptr<SdrObject, SdrObjectFreeOp> pRenderedShape); public: EnhancedCustomShapeEngine(); @@ -149,9 +149,9 @@ Sequence< OUString > SAL_CALL EnhancedCustomShapeEngine::getSupportedServiceName } // XCustomShapeEngine -SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( +std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForceGroupWithText( const SdrObjCustomShape& rSdrObjCustomShape, - SdrObject* pRenderedShape) + std::unique_ptr<SdrObject, SdrObjectFreeOp> pRenderedShape) { const bool bHasText(rSdrObjCustomShape.HasText()); @@ -164,20 +164,20 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( { if ( pRenderedShape ) { - if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape) == nullptr ) + if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape.get() ) == nullptr ) { - SdrObject* pTmp = pRenderedShape; - pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject()); - static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp ); + auto pTmp = std::move(pRenderedShape); + pRenderedShape.reset(new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject())); + static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.release() ); } - static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( + static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()), 0); } else { - pRenderedShape = pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()); + pRenderedShape.reset( pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()) ); } } @@ -185,10 +185,10 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( if ( bHasText ) { // #i37011# also create a text object and add at rPos + 1 - SdrObject* pTextObj = SdrObjFactory::MakeNewObject( + std::unique_ptr<SdrObject, SdrObjectFreeOp> pTextObj( SdrObjFactory::MakeNewObject( rSdrObjCustomShape.getSdrModelFromSdrObject(), rSdrObjCustomShape.GetObjInventor(), - OBJ_TEXT); + OBJ_TEXT) ); // Copy text content OutlinerParaObject* pParaObj(rSdrObjCustomShape.GetOutlinerParaObject()); @@ -234,26 +234,26 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( if ( pRenderedShape ) { - if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape) == nullptr ) + if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape.get() ) == nullptr ) { - SdrObject* pTmp = pRenderedShape; - pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject()); - static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp ); + auto pTmp = std::move(pRenderedShape); + pRenderedShape.reset(new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject())); + static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.release() ); } - static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTextObj ); + static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTextObj.release() ); } else - pRenderedShape = pTextObj; + pRenderedShape = std::move(pTextObj); } // force group if ( pRenderedShape ) { - if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape) == nullptr ) + if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape.get() ) == nullptr ) { - SdrObject* pTmp = pRenderedShape; - pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject()); - static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp ); + auto pTmp = std::move(pRenderedShape); + pRenderedShape.reset(new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject())); + static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.release() ); } } } @@ -361,9 +361,9 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render() if ( mbForceGroupWithText ) { - xRenderedShape.reset(ImplForceGroupWithText( + xRenderedShape = ImplForceGroupWithText( rSdrObjCustomShape, - xRenderedShape.release())); + std::move(xRenderedShape)); } Reference< drawing::XShape > xShape; |