[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sw/qa sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 24 06:33:33 UTC 2020


 sw/qa/extras/uiwriter/uiwriter.cxx |   25 +++++++++++++++++++++++++
 sw/source/core/edit/acorrect.cxx   |    7 +++----
 2 files changed, 28 insertions(+), 4 deletions(-)

New commits:
commit 28ddbaabf895234fb9cfa121ae74e56bef158b5c
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Feb 20 18:28:45 2020 +0100
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Mon Feb 24 07:33:02 2020 +0100

    tdf#130274 sw_redlinehide: fix ChgAutoCorrWord() if replaced text ...
    
    ... is fully deleted.
    
    This crashes on English text with 'i'->'I' substitution.
    
    The assumption that there's some part of the found text that is not
    deleted is only correct for the case where tracked changes are hidden,
    but not when they are shown.
    
    (regression from 9926ea7dd07f1f3d012ddf97941a42bb7fa5717d)
    
    Change-Id: I0e81494659ea7e187101a703f64483dd68c73d70
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89151
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit b7922b56e2dcf1dc1abbf5574bcb672068fa8dbd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89136
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c73e7f30cbca..2a874457d83b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -193,6 +193,7 @@ public:
     void testFdo85554();
     void testAutoCorr();
     void testTdf83260();
+    void testTdf130274();
     void testMergeDoc();
     void testCreatePortions();
     void testBookmarkUndo();
@@ -403,6 +404,7 @@ public:
     CPPUNIT_TEST(testFdo85554);
     CPPUNIT_TEST(testAutoCorr);
     CPPUNIT_TEST(testTdf83260);
+    CPPUNIT_TEST(testTdf130274);
     CPPUNIT_TEST(testMergeDoc);
     CPPUNIT_TEST(testCreatePortions);
     CPPUNIT_TEST(testBookmarkUndo);
@@ -1608,6 +1610,29 @@ void SwUiWriterTest::testTdf83260()
     }
 }
 
+void SwUiWriterTest::testTdf130274()
+{
+    SwDoc *const pDoc(createDoc());
+    SwWrtShell *const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
+
+    CPPUNIT_ASSERT(!pWrtShell->GetLayout()->IsHideRedlines());
+    CPPUNIT_ASSERT(!IDocumentRedlineAccess::IsRedlineOn(
+            pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+    // "tset" may be replaced by the AutoCorrect in the test profile
+    pWrtShell->Insert("tset");
+    // select from left to right
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 4, /*bBasicCall=*/false);
+    pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 4, /*bBasicCall=*/false);
+
+    pWrtShell->SetRedlineFlags(pWrtShell->GetRedlineFlags() | RedlineFlags::On);
+    // this would crash in AutoCorrect
+    pWrtShell->AutoCorrect(corr, '.');
+
+    CPPUNIT_ASSERT(!pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty());
+}
+
 void SwUiWriterTest::testMergeDoc()
 {
     SwDoc* const pDoc1(createDoc("merge-change1.odt"));
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 8f54e69f1b46..a4a4ccf71de6 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -406,10 +406,10 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
                 if (sw::GetRanges(ranges, *rEditSh.GetDoc(), aPam))
                 {
                     pDoc->getIDocumentContentOperations().ReplaceRange(aPam, pFnd->GetLong(), false);
+                    bRet = true;
                 }
-                else
+                else if (!ranges.empty())
                 {
-                    assert(!ranges.empty());
                     assert(ranges.front()->GetPoint()->nNode == ranges.front()->GetMark()->nNode);
                     pDoc->getIDocumentContentOperations().ReplaceRange(
                             *ranges.front(), pFnd->GetLong(), false);
@@ -417,6 +417,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
                     {
                         DeleteSelImpl(**it);
                     }
+                    bRet = true;
                 }
 
                 // tdf#83260 After calling sw::DocumentContentOperationsManager::ReplaceRange
@@ -424,8 +425,6 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
                 // ReplaceRange shows changes, this moves deleted nodes from special section to document.
                 // Then Show mode is disabled again. As a result pTextNd may be invalidated.
                 pTextNd = rCursor.GetNode().GetTextNode();
-
-                bRet = true;
             }
         }
         else


More information about the Libreoffice-commits mailing list