sw/qa/core/docnode/data/tdf150086.docx |binary
 sw/qa/core/docnode/docnode.cxx         |   15 +++++++++++++++
 sw/source/core/docnode/ndsect.cxx      |    3 ++-
 3 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 7335d912de04eaa279dc805ee0ed5be0fcac5326
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu Jul 21 17:56:34 2022 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Jul 22 10:57:29 2022 +0200

    tdf#150086 DOCX import: fix ToC redline with lost content
    
    Inserted Table of Contents lost its redline partially,
    e.g. the redline contained only "Conte" instead of "Content".
    
    Regression from commit 69edfcf789db1920273191d93fae0bc03f385b81
    "DOCX import: fix assertion failure when redline ends right before a ToC".
    
    Note: it seems, it's enough to limit the original fix for
    delete redlines, because that was the main target of the
    interoperability fix.
    
    Change-Id: I617fa855aa8e194a33caa419d2d73e76588f4bd5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137308
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/core/docnode/data/tdf150086.docx 
b/sw/qa/core/docnode/data/tdf150086.docx
new file mode 100644
index 000000000000..063e68df6857
Binary files /dev/null and b/sw/qa/core/docnode/data/tdf150086.docx differ
diff --git a/sw/qa/core/docnode/docnode.cxx b/sw/qa/core/docnode/docnode.cxx
index bcda50c8de7a..4dbf3630f3f4 100644
--- a/sw/qa/core/docnode/docnode.cxx
+++ b/sw/qa/core/docnode/docnode.cxx
@@ -10,6 +10,7 @@
 #include <swmodeltestbase.hxx>
 
 #include <IDocumentRedlineAccess.hxx>
+#include <redline.hxx>
 #include <doc.hxx>
 #include <docary.hxx>
 
@@ -29,6 +30,20 @@ CPPUNIT_TEST_FIXTURE(Test, testRedlineEndsBeforeToC)
     // Without the accompanying fix in place, this test would have resulted in 
an assertion failure
     // in InsertCnt_(), because the start of the section was hidden, but not 
its end.
     CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), 
rTable.size());
+
+    // The redline contained the newline, too
+    CPPUNIT_ASSERT_EQUAL(OUString("<add-table-of-content>"), 
rTable[0]->GetText());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf150086)
+{
+    // Load a document where an insert redline ends right before a ToC
+    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf150086.docx");
+    const SwRedlineTable& rTable = 
pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(9), 
rTable.size());
+
+    // This was "Conte" (stripped redline)
+    CPPUNIT_ASSERT_EQUAL(OUString("Content"), rTable[6]->GetText());
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index 6c7fb8b6ecec..76831ae61925 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -834,7 +834,8 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex 
const& rNdIdx,
         for (SwRedlineTable::size_type nIndex = 0; nIndex < rRedlines.size(); 
++nIndex)
         {
             SwRangeRedline* pRedline = rRedlines[nIndex];
-            if (!pRedline->HasMark() || pRedline->GetMark()->nNode != aInsPos)
+            if ( RedlineType::Delete != pRedline->GetType() ||
+                 !pRedline->HasMark() || pRedline->GetMark()->nNode != aInsPos 
)
             {
                 continue;
             }

Reply via email to