summaryrefslogtreecommitdiff
path: root/sw/source/core/layout/hffrm.cxx
diff options
context:
space:
mode:
authorAshod Nakashian <ashodnakashian@yahoo.com>2015-10-30 22:12:24 -0400
committerCaolán McNamara <caolanm@redhat.com>2015-11-03 09:59:51 +0000
commit48cc54ec2ad5ca7e17ac1f705895d373917a37cb (patch)
tree236ed9f484a0fe2831668515c0d33b52dc9ea50d /sw/source/core/layout/hffrm.cxx
parentb1704274d3214405aa154a4b52c2ebe1901e5fa3 (diff)
Smart pointers for SwBorderAttrAccess
The short-lived SwBorderAttrAccess is manually deleted which is not exception safe and can potentially leak. This wraps it in unique_ptr. Change-Id: Ib45c1c36214583e0bf205231f9f793e023d106c7 Reviewed-on: https://gerrit.libreoffice.org/19701 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/core/layout/hffrm.cxx')
-rw-r--r--sw/source/core/layout/hffrm.cxx14
1 files changed, 4 insertions, 10 deletions
diff --git a/sw/source/core/layout/hffrm.cxx b/sw/source/core/layout/hffrm.cxx
index 98fb929baef1..626c8f35e474 100644
--- a/sw/source/core/layout/hffrm.cxx
+++ b/sw/source/core/layout/hffrm.cxx
@@ -31,6 +31,7 @@
#include "hfspacingitem.hxx"
#include <sortedobjs.hxx>
#include <objectformatter.hxx>
+#include <o3tl/make_unique.hxx>
extern bool bObjsDirect; //frmtool.cxx
@@ -434,8 +435,7 @@ SwTwips SwHeadFootFrm::GrowFrm( SwTwips nDist, bool bTst, bool bInfo )
{
nResult = 0;
- SwBorderAttrAccess * pAccess =
- new SwBorderAttrAccess( SwFrm::GetCache(), this );
+ auto pAccess = o3tl::make_unique<SwBorderAttrAccess>(SwFrm::GetCache(), this);
OSL_ENSURE(pAccess, "no border attributes");
SwBorderAttrs * pAttrs = pAccess->Get();
@@ -451,8 +451,6 @@ SwTwips SwHeadFootFrm::GrowFrm( SwTwips nDist, bool bTst, bool bInfo )
else
nMaxEat = maPrt.Top() - pAttrs->CalcTopLine();
- delete pAccess;
-
if (nMaxEat < 0)
nMaxEat = 0;
@@ -497,7 +495,7 @@ SwTwips SwHeadFootFrm::GrowFrm( SwTwips nDist, bool bTst, bool bInfo )
if (nDist - nEat > 0)
{
- SwTwips nFrmGrow =
+ const SwTwips nFrmGrow =
SwLayoutFrm::GrowFrm( nDist - nEat, bTst, bInfo );
nResult += nFrmGrow;
@@ -566,9 +564,7 @@ SwTwips SwHeadFootFrm::ShrinkFrm( SwTwips nDist, bool bTst, bool bInfo )
bool bNotifyFlys = false;
if (nRest > 0)
{
-
- SwBorderAttrAccess * pAccess =
- new SwBorderAttrAccess( SwFrm::GetCache(), this );
+ auto pAccess = o3tl::make_unique<SwBorderAttrAccess>(SwFrm::GetCache(), this);
OSL_ENSURE(pAccess, "no border attributes");
SwBorderAttrs * pAttrs = pAccess->Get();
@@ -581,8 +577,6 @@ SwTwips SwHeadFootFrm::ShrinkFrm( SwTwips nDist, bool bTst, bool bInfo )
if (nMinPrtHeight < 0)
nMinPrtHeight = 0;
- delete pAccess;
-
/* assume all shrinking can be provided */
SwTwips nShrink = nRest;