summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-10 12:30:51 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-11 09:40:32 +0200
commitb6ddcc0ddf8e1a7ac49175fed92998750b80ec35 (patch)
treecca4b3d0117b9d34b0ffbaa9071a4c1694412d6f
parent0e8e5c196bd8eeda37da0db17bb617f5e97f4ddb (diff)
loplugin:useuniqueptr in SwPaM::MakeRegion
Change-Id: Ie069da6336d8d73c41c47a32308de751de438b31 Reviewed-on: https://gerrit.libreoffice.org/60253 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/inc/pam.hxx2
-rw-r--r--sw/source/core/crsr/findtxt.cxx7
-rw-r--r--sw/source/core/crsr/pam.cxx8
3 files changed, 8 insertions, 9 deletions
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 2149bc6b14f9..c71667e30f50 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -150,7 +150,7 @@ class SAL_WARN_UNUSED SW_DLLPUBLIC SwPaM : public sw::Ring<SwPaM>
SwPosition * m_pMark; ///< points at either m_Bound1 or m_Bound2
bool m_bIsInFrontOfLabel;
- SwPaM* MakeRegion( SwMoveFnCollection const & fnMove, const SwPaM * pOrigRg );
+ std::unique_ptr<SwPaM> MakeRegion( SwMoveFnCollection const & fnMove, const SwPaM * pOrigRg );
SwPaM(SwPaM const& rPaM) = delete;
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index feb164612d32..8d97635b4b93 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -233,7 +233,7 @@ bool SwPaM::Find( const i18nutil::SearchOptions2& rSearchOpt, bool bSearchInNote
if( rSearchOpt.searchString.isEmpty() )
return false;
- SwPaM* pPam = MakeRegion( fnMove, pRegion );
+ std::unique_ptr<SwPaM> pPam = MakeRegion( fnMove, pRegion );
const bool bSrchForward = &fnMove == &fnMoveForward;
SwNodeIndex& rNdIdx = pPam->GetPoint()->nNode;
SwIndex& rContentIdx = pPam->GetPoint()->nContent;
@@ -436,7 +436,7 @@ bool SwPaM::Find( const i18nutil::SearchOptions2& rSearchOpt, bool bSearchInNote
bFound = DoSearch( rSearchOpt, rSText, fnMove, bSrchForward,
bRegSearch, bChkEmptyPara, bChkParaEnd,
nStartInside, nEndInside, nTextLen, pNode,
- pPam );
+ pPam.get() );
if ( bFound )
break;
else
@@ -464,13 +464,12 @@ bool SwPaM::Find( const i18nutil::SearchOptions2& rSearchOpt, bool bSearchInNote
// is disabled, we search the whole length just like before
bFound = DoSearch( rSearchOpt, rSText, fnMove, bSrchForward,
bRegSearch, bChkEmptyPara, bChkParaEnd,
- nStart, nEnd, nTextLen, pNode, pPam );
+ nStart, nEnd, nTextLen, pNode, pPam.get() );
}
if (bFound)
break;
}
}
- delete pPam;
return bFound;
}
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 469e0e41b5db..9f5fc230841a 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -491,12 +491,12 @@ bool SwPaM::Move( SwMoveFnCollection const & fnMove, SwGoInDoc fnGo )
@return Newly created range, in Ring with parameter pOrigRg.
*/
-SwPaM* SwPaM::MakeRegion( SwMoveFnCollection const & fnMove, const SwPaM * pOrigRg )
+std::unique_ptr<SwPaM> SwPaM::MakeRegion( SwMoveFnCollection const & fnMove, const SwPaM * pOrigRg )
{
- SwPaM* pPam;
+ std::unique_ptr<SwPaM> pPam;
if( pOrigRg == nullptr )
{
- pPam = new SwPaM( *m_pPoint );
+ pPam.reset(new SwPaM( *m_pPoint ));
pPam->SetMark(); // set beginning
pPam->Move( fnMove, GoInSection); // to beginning or end of a node
@@ -505,7 +505,7 @@ SwPaM* SwPaM::MakeRegion( SwMoveFnCollection const & fnMove, const SwPaM * pOrig
}
else
{
- pPam = new SwPaM(*pOrigRg, const_cast<SwPaM*>(pOrigRg)); // given search range
+ pPam.reset(new SwPaM(*pOrigRg, const_cast<SwPaM*>(pOrigRg))); // given search range
// make sure that SPoint is on the "real" start position
// FORWARD: SPoint always smaller than GetMark
// BACKWARD: SPoint always bigger than GetMark