[Libreoffice-commits] core.git: sw/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 22 10:38:24 UTC 2021


 sw/source/core/crsr/findtxt.cxx |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 657ec7ff6863ebc79dcea228898b619d43543a6c
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Aug 27 10:18:05 2021 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Sep 22 12:37:49 2021 +0200

    tdf#137737: treat foot/endnote anchor as a "normal" (control) character
    
    The anchor uses Unicode codepoint U+0001 (START OF HEADING) internally.
    It was removed from start and end of the search string (but not from
    the middle) previously, and only when the character appeared inside the
    search range; before 0cd3b7926cafc01d06b589124215e9cb7c148f19, such
    anchors outside of the range were ignored in TextSearch::searchForward.
    The said change made search consider the data outside of the range for
    context (e.g., look-ahead/behind assertions), and then the asymmetry of
    removal when the range includes or excludes the character started to
    affect the "replace after find" case, when initial find searches the
    entire paragraph, and removes the anchor character, then finds '"$' and
    selects the quote before the anchor; then replace uses the selection as
    the range, does not remove the anchor, and it prevents the match.
    
    This change excludes the anchor from the set of removed characters. Now
    the foot/endnote anchors always stay in the string, and make the "find"
    consistent with the following "replace" by preventing the match when
    there's no [\p{Control}] (or [:control:]) in the regex explicitly for
    the anchor. This allows for more flexibility in search, and makes it
    more consistent in making this visible element participate in search.
    
    The other elements that are still removed:
      RES_TXTATR_FLYCNT,
      RES_TXTATR_FIELD,
      RES_TXTATR_REFMARK,
      RES_TXTATR_TOXMARK,
      RES_TXTATR_META,
      RES_TXTATR_METAFIELD
    need separate consideration. Some of them may be also excluded in
    follow-up commits; the other need more correct removal (both when they
    are inside and outside of the range; also in the middle) to create
    consistent results when searching/replacing.
    
    This change also makes sure that ReplaceBackReferences uses the same
    special preprocessing that DoSearch uses.
    
    Change-Id: I87195508695eef9fe379df369d6fef3ca1dffafb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121134
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index ccb3a650c86f..79405979143b 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -275,7 +275,6 @@ lcl_CleanStr(const SwTextNode& rNd,
                 switch (pNextHint->Which())
                 {
                 case RES_TXTATR_FLYCNT:
-                case RES_TXTATR_FTN:
                 case RES_TXTATR_FIELD:
                 case RES_TXTATR_REFMARK:
                 case RES_TXTATR_TOXMARK:
@@ -1153,9 +1152,6 @@ std::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rS
             }
             else
             {
-                OUString const aStr(pLayout
-                    ? pFrame->GetText()
-                    : pTextNode->GetTextNode()->GetText());
                 AmbiguousIndex nStart;
                 AmbiguousIndex nEnd;
                 if (pLayout)
@@ -1168,6 +1164,9 @@ std::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rS
                     nStart.SetModelIndex(pPam->Start()->nContent.GetIndex());
                     nEnd.SetModelIndex(pPam->End()->nContent.GetIndex());
                 }
+                std::vector<AmbiguousIndex> aFltArr;
+                OUString const aStr = lcl_CleanStr(*pTextNode->GetTextNode(), pFrame, pLayout,
+                                                   nStart, nEnd, aFltArr, false, false);
                 if (aSText.SearchForward(aStr, &nStart.GetAnyIndex(), &nEnd.GetAnyIndex(), &aResult))
                 {
                     aSText.ReplaceBackReferences( aReplaceStr, aStr, aResult );


More information about the Libreoffice-commits mailing list