[Libreoffice-commits] core.git: sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Feb 20 13:13:02 UTC 2020
sw/source/core/crsr/findtxt.cxx | 62 ++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 33 deletions(-)
New commits:
commit 796aeeb0f4c26824f3477b45e0d3bae9cf2c4648
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Feb 20 13:22:12 2020 +0100
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Feb 20 14:12:29 2020 +0100
tdf#129553 sw_redlinehide follow-up: simplify ReplaceBackReferences()
In the special case of bParaEnd the nStart/nEnd aren't actually used so
it's pointless go to to all this trouble; refactor this so it's more
obvious.
Change-Id: I0328950e11d86a2313be64f6c662afd1898185e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89092
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 817091462d51..cda6ef6161b3 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -1117,45 +1117,41 @@ o3tl::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& r
: pTextNode == pMarkTextNode))
{
utl::TextSearch aSText( utl::TextSearch::UpgradeToSearchOptions2( rSearchOpt) );
- OUString rStr = pLayout
- ? pFrame->GetText()
- : pTextNode->GetTextNode()->GetText();
- AmbiguousIndex nStart;
- AmbiguousIndex nEnd;
- if (pLayout)
+ SearchResult aResult;
+ OUString aReplaceStr( rSearchOpt.replaceString );
+ if (bParaEnd)
{
- SwTextFrame const*const pStartFrame(
- bParaEnd && *pPam->GetMark() < *pPam->GetPoint()
- ? static_cast<SwTextFrame const*>(pMarkTextNode->getLayoutFrame(pLayout))
- : pFrame);
- SwTextFrame const*const pEndFrame(
- bParaEnd && *pPam->GetPoint() <= *pPam->GetMark()
- ? static_cast<SwTextFrame const*>(pMarkTextNode->getLayoutFrame(pLayout))
- : pFrame);
- nStart.SetFrameIndex(pStartFrame->MapModelToViewPos(*pPam->Start()));
- nEnd.SetFrameIndex(pEndFrame->MapModelToViewPos(*pPam->End()));
+ OUString const aStr("\\n");
+ aResult.subRegExpressions = 1;
+ aResult.startOffset.realloc(1);
+ aResult.endOffset.realloc(1);
+ aResult.startOffset[0] = 0;
+ aResult.endOffset[0] = aStr.getLength();
+ aSText.ReplaceBackReferences( aReplaceStr, aStr, aResult );
+ xRet = aReplaceStr;
}
else
{
- nStart.SetModelIndex(pPam->Start()->nContent.GetIndex());
- nEnd.SetModelIndex(pPam->End()->nContent.GetIndex());
- }
- SearchResult aResult;
- if (bParaEnd ||
- aSText.SearchForward(rStr, &nStart.GetAnyIndex(), &nEnd.GetAnyIndex(), &aResult))
- {
- if ( bParaEnd )
+ OUString const aStr(pLayout
+ ? pFrame->GetText()
+ : pTextNode->GetTextNode()->GetText());
+ AmbiguousIndex nStart;
+ AmbiguousIndex nEnd;
+ if (pLayout)
{
- rStr = "\\n";
- aResult.subRegExpressions = 1;
- aResult.startOffset.realloc(1);
- aResult.endOffset.realloc(1);
- aResult.startOffset[0] = 0;
- aResult.endOffset[0] = rStr.getLength();
+ nStart.SetFrameIndex(pFrame->MapModelToViewPos(*pPam->Start()));
+ nEnd.SetFrameIndex(pFrame->MapModelToViewPos(*pPam->End()));
+ }
+ else
+ {
+ nStart.SetModelIndex(pPam->Start()->nContent.GetIndex());
+ nEnd.SetModelIndex(pPam->End()->nContent.GetIndex());
+ }
+ if (aSText.SearchForward(aStr, &nStart.GetAnyIndex(), &nEnd.GetAnyIndex(), &aResult))
+ {
+ aSText.ReplaceBackReferences( aReplaceStr, aStr, aResult );
+ xRet = aReplaceStr;
}
- OUString aReplaceStr( rSearchOpt.replaceString );
- aSText.ReplaceBackReferences( aReplaceStr, rStr, aResult );
- xRet = aReplaceStr;
}
}
}
More information about the Libreoffice-commits
mailing list