[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 12 10:34:58 UTC 2018
sw/source/core/inc/objectformatter.hxx | 2 +-
sw/source/core/layout/objectformatter.cxx | 10 ++++------
sw/source/core/layout/objectformatterlayfrm.cxx | 8 ++++----
sw/source/core/layout/objectformatterlayfrm.hxx | 2 +-
sw/source/core/layout/objectformattertxtfrm.cxx | 8 ++++----
sw/source/core/layout/objectformattertxtfrm.hxx | 2 +-
6 files changed, 15 insertions(+), 17 deletions(-)
New commits:
commit 99e3703a845c643f17b589cf8174677ef88bb89a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 12 10:32:42 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 12 12:34:34 2018 +0200
loplugin:useuniqueptr in SwObjectFormatter
Change-Id: I549173b942de19eb3ff1e74fdee6e72de720988f
Reviewed-on: https://gerrit.libreoffice.org/60373
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/inc/objectformatter.hxx b/sw/source/core/inc/objectformatter.hxx
index 1cee180afbfe..99d8644f2c29 100644
--- a/sw/source/core/inc/objectformatter.hxx
+++ b/sw/source/core/inc/objectformatter.hxx
@@ -77,7 +77,7 @@ class SwObjectFormatter
SwLayAction* _pLayAction,
const bool _bCollectPgNumOfAnchors = false );
- static SwObjectFormatter* CreateObjFormatter( SwFrame& _rAnchorFrame,
+ static std::unique_ptr<SwObjectFormatter> CreateObjFormatter( SwFrame& _rAnchorFrame,
const SwPageFrame& _rPageFrame,
SwLayAction* _pLayAction );
diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx
index 892ac6a99693..393c182b9e40 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -117,12 +117,12 @@ SwObjectFormatter::~SwObjectFormatter()
{
}
-SwObjectFormatter* SwObjectFormatter::CreateObjFormatter(
+std::unique_ptr<SwObjectFormatter> SwObjectFormatter::CreateObjFormatter(
SwFrame& _rAnchorFrame,
const SwPageFrame& _rPageFrame,
SwLayAction* _pLayAction )
{
- SwObjectFormatter* pObjFormatter = nullptr;
+ std::unique_ptr<SwObjectFormatter> pObjFormatter;
if ( _rAnchorFrame.IsTextFrame() )
{
pObjFormatter = SwObjectFormatterTextFrame::CreateObjFormatter(
@@ -152,7 +152,7 @@ bool SwObjectFormatter::FormatObjsAtFrame( SwFrame& _rAnchorFrame,
bool bSuccess( true );
// create corresponding object formatter
- SwObjectFormatter* pObjFormatter =
+ std::unique_ptr<SwObjectFormatter> pObjFormatter =
SwObjectFormatter::CreateObjFormatter( _rAnchorFrame, _rPageFrame, _pLayAction );
if ( pObjFormatter )
@@ -160,7 +160,6 @@ bool SwObjectFormatter::FormatObjsAtFrame( SwFrame& _rAnchorFrame,
// format anchored floating screen objects
bSuccess = pObjFormatter->DoFormatObjs();
}
- delete pObjFormatter;
return bSuccess;
}
@@ -182,7 +181,7 @@ bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj,
const SwPageFrame& rPageFrame = _pPageFrame ? *_pPageFrame : *(rAnchorFrame.FindPageFrame());
// create corresponding object formatter
- SwObjectFormatter* pObjFormatter =
+ std::unique_ptr<SwObjectFormatter> pObjFormatter =
SwObjectFormatter::CreateObjFormatter( rAnchorFrame, rPageFrame, nullptr/*_pLayAction*/ );
if ( pObjFormatter )
@@ -191,7 +190,6 @@ bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj,
// --> #i40147# - check for moved forward anchor frame
bSuccess = pObjFormatter->DoFormatObj( _rAnchoredObj, true );
}
- delete pObjFormatter;
return bSuccess;
}
diff --git a/sw/source/core/layout/objectformatterlayfrm.cxx b/sw/source/core/layout/objectformatterlayfrm.cxx
index 4c5516c90c48..fa017f7b765e 100644
--- a/sw/source/core/layout/objectformatterlayfrm.cxx
+++ b/sw/source/core/layout/objectformatterlayfrm.cxx
@@ -36,7 +36,7 @@ SwObjectFormatterLayFrame::~SwObjectFormatterLayFrame()
{
}
-SwObjectFormatterLayFrame* SwObjectFormatterLayFrame::CreateObjFormatter(
+std::unique_ptr<SwObjectFormatterLayFrame> SwObjectFormatterLayFrame::CreateObjFormatter(
SwLayoutFrame& _rAnchorLayFrame,
const SwPageFrame& _rPageFrame,
SwLayAction* _pLayAction )
@@ -48,7 +48,7 @@ SwObjectFormatterLayFrame* SwObjectFormatterLayFrame::CreateObjFormatter(
return nullptr;
}
- SwObjectFormatterLayFrame* pObjFormatter = nullptr;
+ std::unique_ptr<SwObjectFormatterLayFrame> pObjFormatter;
// create object formatter, if floating screen objects are registered at
// given anchor layout frame.
@@ -56,8 +56,8 @@ SwObjectFormatterLayFrame* SwObjectFormatterLayFrame::CreateObjFormatter(
( _rAnchorLayFrame.IsPageFrame() &&
static_cast<SwPageFrame&>(_rAnchorLayFrame).GetSortedObjs() ) )
{
- pObjFormatter =
- new SwObjectFormatterLayFrame( _rAnchorLayFrame, _rPageFrame, _pLayAction );
+ pObjFormatter.reset(
+ new SwObjectFormatterLayFrame( _rAnchorLayFrame, _rPageFrame, _pLayAction ));
}
return pObjFormatter;
diff --git a/sw/source/core/layout/objectformatterlayfrm.hxx b/sw/source/core/layout/objectformatterlayfrm.hxx
index 31a605a31f96..9ece6f2816f3 100644
--- a/sw/source/core/layout/objectformatterlayfrm.hxx
+++ b/sw/source/core/layout/objectformatterlayfrm.hxx
@@ -59,7 +59,7 @@ class SwObjectFormatterLayFrame : public SwObjectFormatter
const bool _bCheckForMovedFwd = false ) override;
virtual bool DoFormatObjs() override;
- static SwObjectFormatterLayFrame* CreateObjFormatter(
+ static std::unique_ptr<SwObjectFormatterLayFrame> CreateObjFormatter(
SwLayoutFrame& _rAnchorLayFrame,
const SwPageFrame& _rPageFrame,
SwLayAction* _pLayAction );
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx
index 1af4476d4946..341c7845a10e 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -71,12 +71,12 @@ SwObjectFormatterTextFrame::~SwObjectFormatterTextFrame()
{
}
-SwObjectFormatterTextFrame* SwObjectFormatterTextFrame::CreateObjFormatter(
+std::unique_ptr<SwObjectFormatterTextFrame> SwObjectFormatterTextFrame::CreateObjFormatter(
SwTextFrame& _rAnchorTextFrame,
const SwPageFrame& _rPageFrame,
SwLayAction* _pLayAction )
{
- SwObjectFormatterTextFrame* pObjFormatter = nullptr;
+ std::unique_ptr<SwObjectFormatterTextFrame> pObjFormatter;
// determine 'master' of <_rAnchorTextFrame>, if anchor frame is a follow text frame.
SwTextFrame* pMasterOfAnchorFrame = nullptr;
@@ -94,9 +94,9 @@ SwObjectFormatterTextFrame* SwObjectFormatterTextFrame::CreateObjFormatter(
if ( _rAnchorTextFrame.GetDrawObjs() ||
( pMasterOfAnchorFrame && pMasterOfAnchorFrame->GetDrawObjs() ) )
{
- pObjFormatter =
+ pObjFormatter.reset(
new SwObjectFormatterTextFrame( _rAnchorTextFrame, _rPageFrame,
- pMasterOfAnchorFrame, _pLayAction );
+ pMasterOfAnchorFrame, _pLayAction ));
}
return pObjFormatter;
diff --git a/sw/source/core/layout/objectformattertxtfrm.hxx b/sw/source/core/layout/objectformattertxtfrm.hxx
index 68640fe9e0de..15667b9ead60 100644
--- a/sw/source/core/layout/objectformattertxtfrm.hxx
+++ b/sw/source/core/layout/objectformattertxtfrm.hxx
@@ -124,7 +124,7 @@ class SwObjectFormatterTextFrame : public SwObjectFormatter
/** method to create an instance of <SwObjectFormatterTextFrame> is
necessary.
*/
- static SwObjectFormatterTextFrame* CreateObjFormatter(
+ static std::unique_ptr<SwObjectFormatterTextFrame> CreateObjFormatter(
SwTextFrame& _rAnchorTextFrame,
const SwPageFrame& _rPageFrame,
SwLayAction* _pLayAction );
More information about the Libreoffice-commits
mailing list