diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-07-13 09:08:56 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-08-10 06:19:22 +0200 |
commit | 67a61e54531801645d51ad89aac30064b8c4b4e8 (patch) | |
tree | caebee6370fc392206294cf94ade4f0519b2f7e0 /sw | |
parent | 368b583b992f2e9cad46c2362c9529a07c36d7a9 (diff) |
tdf#111550: A workaround for out-of-order (in-paragraph) tbl on OOXML
Word allows <w:tbl> to be direct child of <w:p>, which is illegal
according to ECMA-376-1:2016.
This allows for import the data in such tables (previously, this text
was simply dropped, causing dataloss) - bug-to-bug compatibility
with Word.
Change-Id: I19c17ab19915ea46685727c635476fe5df593212
Reviewed-on: https://gerrit.libreoffice.org/40909
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf111550.docx | bin | 0 -> 1362 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 66 |
2 files changed, 66 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf111550.docx b/sw/qa/extras/ooxmlimport/data/tdf111550.docx Binary files differnew file mode 100644 index 000000000000..6e13df351906 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf111550.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index bea70605fdae..689c00a6fc3e 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1470,6 +1470,72 @@ DECLARE_OOXMLIMPORT_TEST( testActiveXCheckbox, "activex_checkbox.docx" ) CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType")); } +DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx") +{ + // The test document has following ill-formed structure: + // + // <w:tbl> + // ... + // <w:tr> + // <w:tc> + // <w:p> + // <w:r> + // <w:t>[outer:A2]</w:t> + // <w:br w:type="textWrapping"/> + // </w:r> + // <w:tbl> + // <w:tr> + // <w:tc> + // <w:p> + // <w:r> + // <w:t>[inner:A1]</w:t> + // </w:r> + // </w:p> + // </w:tc> + // </w:tr> + // </w:tbl> + // </w:p> + // </w:tc> + // </w:tr> + // </w:tbl> + // + // i.e., a <w:tbl> as direct child of <w:p> inside another table. + // Word accepts that illegal OOXML, and treats it as equal to + // + // <w:tbl> + // ... + // <w:tr> + // <w:tc> + // <w:tbl> + // <w:tr> + // <w:tc> + // <w:p> + // <w:r> + // <w:t>[outer:A2]</w:t> + // <w:br w:type="textWrapping"/> + // </w:r> + // <w:r> + // <w:t>[inner:A1]</w:t> + // </w:r> + // </w:p> + // </w:tc> + // </w:tr> + // </w:tbl> + // </w:tc> + // </w:tr> + // </w:tbl> + // + // i.e., moves all contents of the outer paragraph into the inner table's first paragraph. + + CPPUNIT_ASSERT_EQUAL(2, getParagraphs()); + + uno::Reference<text::XTextContent> outerTable = getParagraphOrTable(1); + getCell(outerTable, "A1", "[outer:A1]"); + uno::Reference<text::XText> cellA2(getCell(outerTable, "A2"), uno::UNO_QUERY_THROW); + uno::Reference<text::XTextContent> innerTable = getParagraphOrTable(1, cellA2); + getCell(innerTable, "A1", "[outer:A2]\n[inner:A1]"); +} + // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT CPPUNIT_PLUGIN_IMPLEMENT(); |