From f63a60f56156e4ac17887e6c96d15fb865a2a8eb Mon Sep 17 00:00:00 2001 From: László Németh Date: Mon, 17 Sep 2018 13:36:09 +0200 Subject: tdf#118691 DOCX import: fix table loss caused by MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the OOXML standard, (carriage return – Unicode character 000D) is equivalent to a break with null type and clear attributes, so we handle it as a , instead of endOfParagraph, fixing losing table paragraphs and tables containing . Note: It seems, MSO cannot handle carriage return characters in table cells correctly. It shows squares (unknown characters) without line break there. Copying this text to a non-table paragraph in MSO, we get the correct layout with line breaks. Copying this text with carriage return characters back to a table cell, we get squares again. With this LO fix, it will be possible to fix the bad tables edited by MS Word by using LO, because LibreOffice import/export converts all s to s (as before, but now without destroying the structure of the tables). Change-Id: Iee42f71e9a00531353582e7127c2c212ea0890d0 Reviewed-on: https://gerrit.libreoffice.org/60585 Tested-by: Jenkins Reviewed-by: László Németh --- sw/qa/extras/ooxmlexport/data/tdf118691.docx | Bin 0 -> 27096 bytes sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 12 ++++++++++++ writerfilter/source/ooxml/model.xml | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf118691.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf118691.docx b/sw/qa/extras/ooxmlexport/data/tdf118691.docx new file mode 100644 index 000000000000..ce6c6c5cf76d Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf118691.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 9d0c9fa829ee..1849d05cb008 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -731,6 +731,18 @@ DECLARE_OOXMLEXPORT_TEST(testTrackChangesEmptyParagraphsInADeletion, "testTrackC assertXPath(pXmlDoc, "/w:document/w:body/w:p[" + OString::number(i) + "]/w:pPr/w:rPr/w:del"); } +DECLARE_OOXMLEXPORT_TEST(testTdf118691, "tdf118691.docx") +{ + uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xTables(xTablesSupplier->getTextTables(), + uno::UNO_QUERY); + // Text "Before" stays in the first cell, not removed before the table because of + // bad handling of + uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Before\nAfter"), xCell->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 36328c035d75..e1640c44e54d 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -17942,8 +17942,8 @@ - - + + -- cgit v1.2.3