[Libreoffice-commits] core.git: sw/source
Justin Luth
justin_luth at sil.org
Fri Sep 1 17:24:00 UTC 2017
sw/source/core/crsr/findtxt.cxx | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
New commits:
commit 16db6243768ccde2cf0f78da0834fe4ff14f5c3c
Author: Justin Luth <justin_luth at sil.org>
Date: Tue Jun 27 10:55:20 2017 -0400
tdf#101936 sw: ignore comment anchors during search
Comments are anchored by unicode character U+fff9.
If the comment was anchored in the middle of a word, then a search
would not find that word. A comment anchor is not a word-breaking
character, so remove it instead of replacing it with 0x7f.
Change-Id: I4606dbfac74161029029d9807b74bd6ffa285126
Reviewed-on: https://gerrit.libreoffice.org/39361
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Justin Luth <justin_luth at sil.org>
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 65345fb3a4f5..fc360eea94af 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -56,7 +56,7 @@ using namespace util;
static OUString
lcl_CleanStr(const SwTextNode& rNd, sal_Int32 const nStart, sal_Int32& rEnd,
- std::vector<sal_Int32> &rArr, bool const bRemoveSoftHyphen)
+ std::vector<sal_Int32> &rArr, bool const bRemoveSoftHyphen, bool const bRemoveCommentAnchors)
{
OUStringBuffer buf(rNd.GetText());
rArr.clear();
@@ -127,7 +127,6 @@ lcl_CleanStr(const SwTextNode& rNd, sal_Int32 const nStart, sal_Int32& rEnd,
case RES_TXTATR_FLYCNT:
case RES_TXTATR_FTN:
case RES_TXTATR_FIELD:
- case RES_TXTATR_ANNOTATION:
case RES_TXTATR_REFMARK:
case RES_TXTATR_TOXMARK:
case RES_TXTATR_META:
@@ -140,9 +139,7 @@ lcl_CleanStr(const SwTextNode& rNd, sal_Int32 const nStart, sal_Int32& rEnd,
// simply removed if first. If at the end, we keep the
// replacement and remove afterwards all at a string's
// end (might be normal 0x7f).
- const bool bEmpty =
- ( pHt->Which() != RES_TXTATR_FIELD
- && pHt->Which() != RES_TXTATR_ANNOTATION )
+ const bool bEmpty = pHt->Which() != RES_TXTATR_FIELD
|| (static_txtattr_cast<SwTextField const*>(pHt)->GetFormatField().GetField()->ExpandField(true).isEmpty());
if ( bEmpty && nStart == nAkt )
{
@@ -158,6 +155,16 @@ lcl_CleanStr(const SwTextNode& rNd, sal_Int32 const nStart, sal_Int32& rEnd,
}
}
break;
+ case RES_TXTATR_ANNOTATION:
+ {
+ if( bRemoveCommentAnchors )
+ {
+ rArr.push_back( nAkt );
+ --rEnd;
+ buf.remove( nAkt, 1 );
+ }
+ }
+ break;
default:
OSL_FAIL( "unknown case in lcl_CleanStr" );
break;
@@ -483,6 +490,8 @@ bool SwPaM::DoSearch( const i18nutil::SearchOptions2& rSearchOpt, utl::TextSearc
// if the search string contains a soft hyphen,
// we don't strip them from the text:
bool bRemoveSoftHyphens = true;
+ // if the search string contains a comment, we don't strip them from the text
+ const bool bRemoveCommentAnchors = rSearchOpt.searchString.indexOf( CH_TXTATR_INWORD ) == -1;
if ( bRegSearch )
{
@@ -504,10 +513,10 @@ bool SwPaM::DoSearch( const i18nutil::SearchOptions2& rSearchOpt, utl::TextSearc
if( bSrchForward )
sCleanStr = lcl_CleanStr(*pNode->GetTextNode(), nStart, nEnd,
- aFltArr, bRemoveSoftHyphens);
+ aFltArr, bRemoveSoftHyphens, bRemoveCommentAnchors);
else
sCleanStr = lcl_CleanStr(*pNode->GetTextNode(), nEnd, nStart,
- aFltArr, bRemoveSoftHyphens);
+ aFltArr, bRemoveSoftHyphens, bRemoveCommentAnchors);
SwScriptIterator* pScriptIter = nullptr;
sal_uInt16 nSearchScript = 0;
More information about the Libreoffice-commits
mailing list