[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 25 11:19:17 UTC 2020


 sw/source/core/crsr/findtxt.cxx |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 4f19b5b55d592621826e9904d3f4c5d48f52ee0f
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Feb 19 17:14:54 2020 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Feb 25 12:18:44 2020 +0100

    tdf#129553 sw_redlinehide: fix replace of paragraph breaks with $
    
    The problem is that in the special selections that replace paragraph
    breaks, the start and end node are actually different, hence have
    different text frames.
    
    (regression from 5e81b966778d82692b4763d892b457186a7f269d)
    
    Practically the end content index is going to be 0 typically which
    doesn't need mapping, but not sure if that's guaranteed anywhere.
    
    Change-Id: I77c95c2f3e55edcc7aca6f4540cae90b3be5d79b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89050
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 83122add64ecbf0fd3ba30368d5d87bde3dac278)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88959
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 988383d3dce56536082a639d5a8b0cc0a23da7c4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89429
    Tested-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 53b345c25759..4d44a6d41838 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -1092,8 +1092,10 @@ OUString *ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
     if( pPam && pPam->HasMark() &&
         SearchAlgorithms2::REGEXP == rSearchOpt.AlgorithmType2 )
     {
-        const SwContentNode* pTextNode = pPam->GetContentNode();
-        if (!pTextNode || !pTextNode->IsTextNode())
+        SwContentNode const*const pTextNode = pPam->GetContentNode();
+        SwContentNode const*const pMarkTextNode = pPam->GetContentNode(false);
+        if (!pTextNode || !pTextNode->IsTextNode()
+            || !pMarkTextNode || !pMarkTextNode->IsTextNode())
         {
             return pRet;
         }
@@ -1103,7 +1105,7 @@ OUString *ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
         const bool bParaEnd = rSearchOpt.searchString == "$" || rSearchOpt.searchString == "^$" || rSearchOpt.searchString == "$^";
         if (bParaEnd || (pLayout
                 ? sw::FrameContainsNode(*pFrame, pPam->GetMark()->nNode.GetIndex())
-                : pTextNode == pPam->GetContentNode(false)))
+                : pTextNode == pMarkTextNode))
         {
             utl::TextSearch aSText( utl::TextSearch::UpgradeToSearchOptions2( rSearchOpt) );
             OUString rStr = pLayout
@@ -1113,8 +1115,16 @@ OUString *ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
             AmbiguousIndex nEnd;
             if (pLayout)
             {
-                nStart.SetFrameIndex(pFrame->MapModelToViewPos(*pPam->Start()));
-                nEnd.SetFrameIndex(pFrame->MapModelToViewPos(*pPam->End()));
+                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()));
             }
             else
             {


More information about the Libreoffice-commits mailing list