sw/inc/pam.hxx | 2 +- sw/source/core/crsr/findtxt.cxx | 7 +++---- sw/source/core/crsr/pam.cxx | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-)
New commits: commit b6ddcc0ddf8e1a7ac49175fed92998750b80ec35 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Sep 10 12:30:51 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 11 09:40:32 2018 +0200 loplugin:useuniqueptr in SwPaM::MakeRegion Change-Id: Ie069da6336d8d73c41c47a32308de751de438b31 Reviewed-on: https://gerrit.libreoffice.org/60253 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits