sw/inc/ndgrf.hxx | 2 +- sw/source/core/graphic/ndgrf.cxx | 15 ++++++--------- sw/source/core/inc/dbg_lay.hxx | 20 ++++---------------- sw/source/core/layout/dbg_lay.cxx | 25 +++++++++++-------------- 4 files changed, 22 insertions(+), 40 deletions(-)
New commits: commit 99147c8303016498f4bfcef3d5c1fe126ad43076 Author: Noel Grandin <[email protected]> Date: Thu Jun 28 14:01:29 2018 +0200 loplugin:useuniqueptr in SwGrfNode Change-Id: I9f0993f7fbbdaf7552fe0b0c19d3fca691471fa8 Reviewed-on: https://gerrit.libreoffice.org/56626 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx index e44c72e69309..a5e4e0cc2969 100644 --- a/sw/inc/ndgrf.hxx +++ b/sw/inc/ndgrf.hxx @@ -37,7 +37,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTextNode friend class SwNodes; GraphicObject maGrfObj; - GraphicObject *mpReplacementGraphic; + std::unique_ptr<GraphicObject> mpReplacementGraphic; tools::SvRef<sfx2::SvBaseLink> refLink; ///< If graphics only as link then pointer is set. Size nGrfSize; bool bInSwapIn :1; diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 00e63f64a918..63a0c43d946c 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -138,8 +138,7 @@ bool SwGrfNode::ReRead( { bool bReadGrf = false; bool bSetTwipSize = true; - delete mpReplacementGraphic; - mpReplacementGraphic = nullptr; + mpReplacementGraphic.reset(); OSL_ENSURE( pGraphic || !rGrfName.isEmpty(), "GraphicNode without a name, Graphic or GraphicObject" ); @@ -281,8 +280,7 @@ bool SwGrfNode::ReRead( SwGrfNode::~SwGrfNode() { - delete mpReplacementGraphic; - mpReplacementGraphic = nullptr; + mpReplacementGraphic.reset(); // #i73788# mpThreadConsumer.reset(); @@ -390,17 +388,17 @@ const GraphicObject* SwGrfNode::GetReplacementGrfObj() const if(rVectorGraphicDataPtr.get()) { - const_cast< SwGrfNode* >(this)->mpReplacementGraphic = new GraphicObject(rVectorGraphicDataPtr->getReplacement()); + const_cast< SwGrfNode* >(this)->mpReplacementGraphic.reset( new GraphicObject(rVectorGraphicDataPtr->getReplacement()) ); } else if (GetGrfObj().GetGraphic().hasPdfData() || GetGrfObj().GetGraphic().GetType() == GraphicType::GdiMetafile) { // Replacement graphic for PDF and metafiles is just the bitmap. - const_cast<SwGrfNode*>(this)->mpReplacementGraphic = new GraphicObject(GetGrfObj().GetGraphic().GetBitmapEx()); + const_cast<SwGrfNode*>(this)->mpReplacementGraphic.reset( new GraphicObject(GetGrfObj().GetGraphic().GetBitmapEx()) ); } } - return mpReplacementGraphic; + return mpReplacementGraphic.get(); } SwContentNode *SwGrfNode::SplitContentNode( const SwPosition & ) @@ -470,8 +468,7 @@ bool SwGrfNode::SwapIn(bool bWaitForData) else if( GraphicType::Default == maGrfObj.GetType() ) { // no default bitmap anymore, thus re-paint - delete mpReplacementGraphic; - mpReplacementGraphic = nullptr; + mpReplacementGraphic.reset(); maGrfObj.SetGraphic( Graphic() ); onGraphicChanged(); commit 95486bac7090d163d19fe8d35521ac0ef4473a93 Author: Noel Grandin <[email protected]> Date: Thu Jun 28 13:57:43 2018 +0200 loplugin:useuniqueptr in SwEnterLeave Change-Id: I948c146f675675c1902c158be4d97b6d19679a51 Reviewed-on: https://gerrit.libreoffice.org/56625 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/source/core/inc/dbg_lay.hxx b/sw/source/core/inc/dbg_lay.hxx index 95e491782ff6..5c46809f88ae 100644 --- a/sw/source/core/inc/dbg_lay.hxx +++ b/sw/source/core/inc/dbg_lay.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SW_SOURCE_CORE_INC_DBG_LAY_HXX #include <o3tl/typed_flags_set.hxx> +#include <memory> enum class PROT { FileInit = 0x00000000, @@ -84,23 +85,10 @@ public: class SwEnterLeave { - SwImplEnterLeave* pImpl; - void Ctor( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ); - void Dtor(); - + std::unique_ptr<SwImplEnterLeave> pImpl; public: - SwEnterLeave( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ) - { - if( SwProtocol::Record( nFunc ) ) - Ctor( pFrame, nFunc, nAct, pPar ); - else - pImpl = nullptr; - } - ~SwEnterLeave() - { - if( pImpl ) - Dtor(); - } + SwEnterLeave( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ); + ~SwEnterLeave(); }; #define PROTOCOL( pFrame, nFunc, nAct, pPar ) { if( SwProtocol::Record( nFunc ) )\ diff --git a/sw/source/core/layout/dbg_lay.cxx b/sw/source/core/layout/dbg_lay.cxx index 203f07893296..8db7a0d79a22 100644 --- a/sw/source/core/layout/dbg_lay.cxx +++ b/sw/source/core/layout/dbg_lay.cxx @@ -860,37 +860,34 @@ void SwImplProtocol::DeleteFrame( sal_uInt16 nId ) pFrameIds->erase(nId); } -/* SwEnterLeave::Ctor(..) is called from the (inline-)CTor if the function should - * be logged. +/* * The task here is to find the right SwImplEnterLeave object based on the * function; everything else is then done in his Ctor/Dtor. */ -void SwEnterLeave::Ctor( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ) +SwEnterLeave::SwEnterLeave( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ) { + if( !SwProtocol::Record( nFunc ) ) + return; switch( nFunc ) { case PROT::AdjustN : case PROT::Grow: - case PROT::Shrink : pImpl = new SwSizeEnterLeave( pFrame, nFunc, nAct, pPar ); break; + case PROT::Shrink : pImpl.reset( new SwSizeEnterLeave( pFrame, nFunc, nAct, pPar ) ); break; case PROT::MoveFwd: - case PROT::MoveBack : pImpl = new SwUpperEnterLeave( pFrame, nFunc, nAct, pPar ); break; - case PROT::FrmChanges : pImpl = new SwFrameChangesLeave( pFrame, nFunc, nAct, pPar ); break; - default: pImpl = new SwImplEnterLeave( pFrame, nFunc, nAct, pPar ); break; + case PROT::MoveBack : pImpl.reset( new SwUpperEnterLeave( pFrame, nFunc, nAct, pPar ) ); break; + case PROT::FrmChanges : pImpl.reset( new SwFrameChangesLeave( pFrame, nFunc, nAct, pPar ) ); break; + default: pImpl.reset( new SwImplEnterLeave( pFrame, nFunc, nAct, pPar ) ); break; } pImpl->Enter(); } -/* SwEnterLeave::Dtor() only calls the Dtor of the SwImplEnterLeave object. It's - * just no inline because we don't want the SwImplEnterLeave definition inside +/* This is not inline because we don't want the SwImplEnterLeave definition inside * dbg_lay.hxx. */ -void SwEnterLeave::Dtor() +SwEnterLeave::~SwEnterLeave() { - if( pImpl ) - { + if (pImpl) pImpl->Leave(); - delete pImpl; - } } void SwImplEnterLeave::Enter() _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
