sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx                      |   15 
++++++++++
 sw/source/core/table/swtable.cxx                                |   10 ++++++
 3 files changed, 25 insertions(+)

New commits:
commit 4697d2bda1b37f9cf8b301f5bf044c2390f56333
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Wed Sep 6 18:01:28 2023 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Wed Sep 6 20:33:16 2023 +0200

    tdf#157011 sw tracked table column: fix DOCX import of empty cell
    
    OOXML w:std elements are imported with 0x01 characters in text
    content of tracked table columns (as a regression in LO 7.3?),
    losing change tracking data. Fix this temporarily by completing
    SwTableBox::IsEmpty() handling the bad 0x01 characters of the
    imported tracked empty cells.
    
    See also commit a483a44ca00f43a64ae51d62b8fbb4129a413f6d
    "tdf#143215 DOCX import: fix tracked empty row insertion/deletion".
    
    Change-Id: I4895754e540cca6ba2cb3442f24a8affcedd51fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156626
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx 
b/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx
new file mode 100644
index 000000000000..5ebb98fda0d7
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index e406d546aea6..e5a585f01d68 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1323,6 +1323,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf150824, "tdf150824.fodt")
     }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf157011, "tdf157011_ins_del_empty_cols.docx")
+{
+    // check tracked table column insertions and deletions with empty cells
+    if (isExported())
+    {
+        xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+
+        // This was 1 (missing tracked table cell insertions)
+        assertXPath(pXmlDoc, "//w:ins", 3);
+
+        // This was 4 (missing tracked table cell deletions)
+        assertXPath(pXmlDoc, "//w:del", 6);
+    }
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf150824_regression, "ooo30436-1-minimized.sxw")
 {
     // There should be no crash during loading of the document
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index f42b9ad95ce5..ca360e324081 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2264,6 +2264,16 @@ bool SwTableBox::IsEmpty( bool bWithRemainingNestedTable 
) const
         const SwContentNode *pCNd = pFirstNode->GetContentNode();
         if ( pCNd && !pCNd->Len() )
             return true;
+
+        // tdf#157011 OOXML w:std cell content is imported with terminating 
0x01 characters,
+        // i.e. an empty box can contain double 0x01: handle it to avoid 
losing change tracking
+        // FIXME regression since LibreOffice 7.3?
+        if ( pCNd && pCNd->Len() == 2 && pCNd->GetTextNode() )
+        {
+            const OUString &rText = pCNd->GetTextNode()->GetText();
+            if ( rText[0] == 0x01 && rText[1] == 0x01 )
+                return true;
+        }
     }
     else if ( bWithRemainingNestedTable )
     {

Reply via email to