summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml/xmlimpit.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-21 15:32:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-22 20:11:50 +0200
commit200ca388246e525f6e8f909766977f534c0c897e (patch)
treea1ddcd356bddada68d1510eb409721b6b2564562 /sw/source/filter/xml/xmlimpit.cxx
parentac9db25da2d78f8ecc2ce68ad622cc6012972494 (diff)
teach useuniqueptr loplugin about calling delete on a param
which is often a useful indicator that the callers can be made to use std::unique_ptr Change-Id: Idb1745d1f58dbcf389c9f60f1a5728d7d092ade5 Reviewed-on: https://gerrit.libreoffice.org/56238 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/filter/xml/xmlimpit.cxx')
-rw-r--r--sw/source/filter/xml/xmlimpit.cxx40
1 files changed, 16 insertions, 24 deletions
diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx
index 0c9566012c26..d6b1ea06ad44 100644
--- a/sw/source/filter/xml/xmlimpit.cxx
+++ b/sw/source/filter/xml/xmlimpit.cxx
@@ -224,32 +224,24 @@ SvXMLImportItemMapper::finished(SfxItemSet &, SvXMLUnitConverter const&) const
struct BoxHolder
{
- SvxBorderLine* pTop;
- SvxBorderLine* pBottom;
- SvxBorderLine* pLeft;
- SvxBorderLine* pRight;
+ std::unique_ptr<SvxBorderLine> pTop;
+ std::unique_ptr<SvxBorderLine> pBottom;
+ std::unique_ptr<SvxBorderLine> pLeft;
+ std::unique_ptr<SvxBorderLine> pRight;
BoxHolder(BoxHolder const&) = delete;
BoxHolder& operator=(BoxHolder const&) = delete;
explicit BoxHolder(SvxBoxItem const & rBox)
{
- pTop = rBox.GetTop() == nullptr ?
- nullptr : new SvxBorderLine( *rBox.GetTop() );
- pBottom = rBox.GetBottom() == nullptr ?
- nullptr : new SvxBorderLine( *rBox.GetBottom() );
- pLeft = rBox.GetLeft() == nullptr ?
- nullptr : new SvxBorderLine( *rBox.GetLeft() );
- pRight = rBox.GetRight() == nullptr ?
- nullptr : new SvxBorderLine( *rBox.GetRight() );
- }
-
- ~BoxHolder()
- {
- delete pTop;
- delete pBottom;
- delete pLeft;
- delete pRight;
+ if (rBox.GetTop())
+ pTop.reset(new SvxBorderLine( *rBox.GetTop() ));
+ if (rBox.GetBottom())
+ pBottom.reset(new SvxBorderLine( *rBox.GetBottom() ));
+ if (rBox.GetLeft())
+ pLeft.reset(new SvxBorderLine( *rBox.GetLeft() ));
+ if (rBox.GetRight())
+ pRight.reset(new SvxBorderLine( *rBox.GetRight() ));
}
};
@@ -576,10 +568,10 @@ bool SvXMLImportItemMapper::PutXMLValue(
break;
}
- rBox.SetLine( aBoxes.pTop, SvxBoxItemLine::TOP );
- rBox.SetLine( aBoxes.pBottom, SvxBoxItemLine::BOTTOM );
- rBox.SetLine( aBoxes.pLeft, SvxBoxItemLine::LEFT );
- rBox.SetLine( aBoxes.pRight, SvxBoxItemLine::RIGHT );
+ rBox.SetLine( aBoxes.pTop.get(), SvxBoxItemLine::TOP );
+ rBox.SetLine( aBoxes.pBottom.get(), SvxBoxItemLine::BOTTOM );
+ rBox.SetLine( aBoxes.pLeft.get(), SvxBoxItemLine::LEFT );
+ rBox.SetLine( aBoxes.pRight.get(), SvxBoxItemLine::RIGHT );
bOk = true;
}