diff options
author | Justin Luth <justin.luth@collabora.com> | 2020-04-02 10:22:45 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-04-07 11:29:27 +0200 |
commit | d2db4bc9507653a46fdea282d41b9683910a072f (patch) | |
tree | ad926d7198edac7c8c0d5068e7b5fd0eca0c180e /sw/qa | |
parent | a7f36ba45bf86ccd8f8a61c27f5b25d0999176b1 (diff) |
tdf#119760 docx: table starts at left, not mid-border
related to compatibilityMode = 15; the new export default.
In Word 2013+, it appears that the table starts immediately,
and then the border is added. In Writer, the table is
considered to start mid-border. So that difference needs
to be emulated by adjusting the table margin.
The same appears to be true for nested tables.
Negative margins appear to just be ignored for nested tables,
and Word's UI does not accept a negative value.
I modified the existing table-position-15.docx slightly (in Word 2016),
just to remove spacing between the caption and the table
so that it would be easy to visually compare the table position.
One slight difference is that WORD seems to add a small "margin"
to the the paragraph shading area - don't let that throw you off.
The existing unit test enforced settings that didn't match
how Word 2013 was showing the files, despite being written to
test exactly that. I assume the author was focusing more on
OLDER versions of Word and didn't care too much about the
NEW version. A man after my own heart.
MISC:
-I removed my earlier TODO which was just plain wrong.
-the ambiguous make::any caused me untold problems,
so I made it unambiguous by moving it into a variable.
Change-Id: I0685ab74777f1def2841c7d18ff1cdaf2753f47b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91608
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/table-position-15.docx | bin | 13683 -> 12264 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docx | bin | 0 -> 4698 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 26 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 3 |
4 files changed, 25 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/table-position-15.docx b/sw/qa/extras/ooxmlexport/data/table-position-15.docx Binary files differindex d3dcaec40e78..91fbdbef00a2 100644 --- a/sw/qa/extras/ooxmlexport/data/table-position-15.docx +++ b/sw/qa/extras/ooxmlexport/data/table-position-15.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docx b/sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docx Binary files differnew file mode 100644 index 000000000000..0456fe206edb --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 1057ab93485c..f19a95342714 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -1192,7 +1192,8 @@ DECLARE_OOXMLEXPORT_TEST(testTableMarginAdjustment, "table.fodt") // (old) Word: margin 0 means paragraph in table starts at 0 auto const xTable(getParagraphOrTable(1)); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTable, "LeftMargin")); + // shifted very slightly to account for half of the thin border width, so 4, not 0. + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), getProperty<sal_Int32>(xTable, "LeftMargin")); // Now that compatibilityMode is set to 2013's 15 (new), expect the new values, // since LO is exporting in the NEW way now instead of the OLD way. @@ -1204,6 +1205,24 @@ DECLARE_OOXMLEXPORT_TEST(testTableMarginAdjustment, "table.fodt") assertXPath(pXmlDoc, "//w:tbl[1]/w:tblPr[1]/w:tblInd[1]", "w", "0"); } +DECLARE_OOXMLEXPORT_TEST(testTdf119760_tableInTablePosition, "tdf119760_tableInTablePosition.docx") +{ + if ( mbExported ) + { + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + assertXPath(pXmlDoc, "//w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tblPr[1]/w:tblInd[1]", "type", "dxa"); + assertXPath(pXmlDoc, "//w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]//w:tblPr[1]/w:tblInd[1]", "w", "0"); + } + + uno::Reference< text::XTextTablesSupplier > xTablesSupplier( mxComponent, uno::UNO_QUERY ); + uno::Reference< container::XIndexAccess > xTables( xTablesSupplier->getTextTables(), uno::UNO_QUERY ); + uno::Reference< text::XTextTable > xTable( xTables->getByIndex(0), uno::UNO_QUERY ); + // For compatibilityMode 15: margin 0 means table border starts at 0, + // shifted to account for half of the thick border width, so 106, not 0. + CPPUNIT_ASSERT_EQUAL(sal_Int32(106), getProperty<sal_Int32>(xTable, "LeftMargin")); +} + DECLARE_OOXMLEXPORT_TEST( testTableCellMargin, "table-cell-margin.docx" ) { sal_Int32 const cellLeftMarginFromOffice[] = { 250, 100, 0, 0 }; @@ -1268,10 +1287,11 @@ DECLARE_OOXMLEXPORT_TEST( testTablePosition14, "table-position-14.docx" ) } } -// tdf#106742 for DOCX with compatibility level > 14 (MS Word since ver.2013), we should NOT use cell margins when calculating table left border position +// tdf#106742 for DOCX with compatibility level > 14 (MS Word since ver.2013), +// we should NOT use cell margins when calculating table left border position. But we do need to use border width. DECLARE_OOXMLEXPORT_TEST( testTablePosition15, "table-position-15.docx" ) { - sal_Int32 const aXCoordsFromOffice[] = { 2751, -899, 1, 106 }; + sal_Int32 const aXCoordsFromOffice[] = { 2751, -899, 1, 212 }; uno::Reference< text::XTextTablesSupplier > xTablesSupplier( mxComponent, uno::UNO_QUERY ); uno::Reference< frame::XModel > xModel( mxComponent, uno::UNO_QUERY ); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 5e758f642624..7369dac8f1a7 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -495,8 +495,9 @@ DECLARE_OOXMLIMPORT_TEST(testN779627, "n779627.docx") uno::Any aValue = xTableProperties->getPropertyValue("LeftMargin"); sal_Int32 nLeftMargin; aValue >>= nLeftMargin; + // only border width considered. CPPUNIT_ASSERT_EQUAL_MESSAGE( "Left margin shouldn't take tableCellMar into account in nested tables", - sal_Int32(0), nLeftMargin); + sal_Int32(9), nLeftMargin); /* * Another problem tested with this document is the unnecessary loading of the shapes |