From cae5dd9363b68dbabbeb2069f4aee7d057f6b5a8 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Tue, 25 Jul 2017 16:58:28 +0300 Subject: tdf#109524: use 100% table width when there's no explicit width available According to ECMA-376-1:2016 17.4.63, 17.18.87, etc, all table widths are considered preferred, and actual table layout should be determined using an algorithm described in 17.18.87. When w:tblLayout element is omitted, or there is no explicit width information given, it is assumed that AutoFit Table Layout should be used, i.e. using cells content to determine final widths of table grid. In the description of the AutoFit Table Layout algorithm, it is stated that the table width grows to hold data, but no more than page width. As a first approach, this commit just sets table width to 100% when there's no width data available. TODO is to implement the AutoFit Table Layout algorithm properly. Change-Id: I000c548eb152c70d2c6e053f4d2b1d16e8976c27 Reviewed-on: https://gerrit.libreoffice.org/40500 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sw/qa/extras/ooxmlimport/data/tdf109524.docx | Bin 0 -> 1291 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 ++++++++++++ 2 files changed, 12 insertions(+) create mode 100644 sw/qa/extras/ooxmlimport/data/tdf109524.docx (limited to 'sw/qa') diff --git a/sw/qa/extras/ooxmlimport/data/tdf109524.docx b/sw/qa/extras/ooxmlimport/data/tdf109524.docx new file mode 100644 index 000000000000..534245b8f907 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf109524.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 6b4dc9a81216..fef6d06d0038 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1418,6 +1418,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf109306, "tdf109306.docx") CPPUNIT_ASSERT_EQUAL(sal_Int16(80), getProperty(xTables->getByIndex(1), "RelativeWidth")); } +DECLARE_OOXMLIMPORT_TEST(testTdf109524, "tdf109524.docx") +{ + uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); + // The table should have a small width (just to hold the short text in its single cell). + // Until it's correctly implemented, we assign it 100% relative width. + // Previously, the table (without explicitly set width) had huge actual width + // and extended far outside of page's right border. + CPPUNIT_ASSERT_EQUAL(true, bool(getProperty(xTables->getByIndex(0), "IsWidthRelative"))); + CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty(xTables->getByIndex(0), "RelativeWidth")); +} + // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit