diff options
-rw-r--r-- | sw/inc/pam.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/crsr/findtxt.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/crsr/pam.cxx | 8 |
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 |