summaryrefslogtreecommitdiff
path: root/sw/source/core/crsr/findtxt.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-08-08 19:43:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-12 19:55:24 +0200
commit8fa80d743945ef7ae84e63e463ad50abd7d5a2be (patch)
tree9eda84999eeba84cacf20427e7f0d0a5f9aba9c1 /sw/source/core/crsr/findtxt.cxx
parentb0ec87af1be24f8bc7ac2a989cda3e40bb842aee (diff)
unique_ptr->optional in MakeRegion
Change-Id: I7295e337ca45761dc986c2dc660ea9a7432280b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138151 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/crsr/findtxt.cxx')
-rw-r--r--sw/source/core/crsr/findtxt.cxx23
1 files changed, 12 insertions, 11 deletions
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 0ae04af5017b..be23fe43a18c 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -376,10 +376,11 @@ bool FindTextImpl(SwPaM & rSearchPam,
if( rSearchOpt.searchString.isEmpty() )
return false;
- std::unique_ptr<SwPaM> pPam = sw::MakeRegion(fnMove, rRegion);
+ std::optional<SwPaM> oPam;
+ sw::MakeRegion(fnMove, rRegion, oPam);
const bool bSrchForward = &fnMove == &fnMoveForward;
- SwNodeIndex& rNdIdx = pPam->GetPoint()->nNode;
- SwContentIndex& rContentIdx = pPam->GetPoint()->nContent;
+ SwNodeIndex& rNdIdx = oPam->GetPoint()->nNode;
+ SwContentIndex& rContentIdx = oPam->GetPoint()->nContent;
// If bFound is true then the string was found and is between nStart and nEnd
bool bFound = false;
@@ -401,7 +402,7 @@ bool FindTextImpl(SwPaM & rSearchPam,
}
// LanguageType eLastLang = 0;
- while (nullptr != (pNode = ::GetNode(*pPam, bFirst, fnMove, bInReadOnly, pLayout)))
+ while (nullptr != (pNode = ::GetNode(*oPam, bFirst, fnMove, bInReadOnly, pLayout)))
{
if( pNode->IsTextNode() )
{
@@ -421,16 +422,16 @@ bool FindTextImpl(SwPaM & rSearchPam,
}
AmbiguousIndex nEnd;
if (pLayout
- ? FrameContainsNode(*pFrame, pPam->GetMark()->GetNodeIndex())
- : rNdIdx == pPam->GetMark()->nNode)
+ ? FrameContainsNode(*pFrame, oPam->GetMark()->GetNodeIndex())
+ : rNdIdx == oPam->GetMark()->nNode)
{
if (pLayout)
{
- nEnd.SetFrameIndex(pFrame->MapModelToViewPos(*pPam->GetMark()));
+ nEnd.SetFrameIndex(pFrame->MapModelToViewPos(*oPam->GetMark()));
}
else
{
- nEnd.SetModelIndex(pPam->GetMark()->GetContentIndex());
+ nEnd.SetModelIndex(oPam->GetMark()->GetContentIndex());
}
}
else
@@ -454,7 +455,7 @@ bool FindTextImpl(SwPaM & rSearchPam,
AmbiguousIndex nStart;
if (pLayout)
{
- nStart.SetFrameIndex(pFrame->MapModelToViewPos(*pPam->GetPoint()));
+ nStart.SetFrameIndex(pFrame->MapModelToViewPos(*oPam->GetPoint()));
}
else
{
@@ -679,7 +680,7 @@ bool FindTextImpl(SwPaM & rSearchPam,
bRegSearch, bChkEmptyPara, bChkParaEnd,
nStartInside, nEndInside, nTextLen,
pNode->GetTextNode(), pFrame, pLayout,
- pPam.get() );
+ oPam ? &*oPam : nullptr );
if ( bFound )
break;
else
@@ -712,7 +713,7 @@ bool FindTextImpl(SwPaM & rSearchPam,
bRegSearch, bChkEmptyPara, bChkParaEnd,
nStart, nEnd, nTextLen,
pNode->GetTextNode(), pFrame, pLayout,
- pPam.get() );
+ oPam ? &*oPam : nullptr );
}
if (bFound)
break;