summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-28 14:01:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-29 08:41:39 +0200
commit99147c8303016498f4bfcef3d5c1fe126ad43076 (patch)
tree9200058d3b1d510cc8923141369f2eb6dde24b19
parent95486bac7090d163d19fe8d35521ac0ef4473a93 (diff)
loplugin:useuniqueptr in SwGrfNode
Change-Id: I9f0993f7fbbdaf7552fe0b0c19d3fca691471fa8 Reviewed-on: https://gerrit.libreoffice.org/56626 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/inc/ndgrf.hxx2
-rw-r--r--sw/source/core/graphic/ndgrf.cxx15
2 files changed, 7 insertions, 10 deletions
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();