sw/qa/extras/ooxmlexport/data/tdf119760_positionCellBorder.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 8 ++ writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 27 +++++++--- 3 files changed, 27 insertions(+), 8 deletions(-)
New commits: commit fe847dda1751bc2c96ef646baa4f16bcc431c1e3 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Fri Sep 14 22:11:50 2018 +0300 Commit: Justin Luth <justin_l...@sil.org> CommitDate: Fri Sep 28 05:52:33 2018 +0200 tdf#119760 writerfilter: cell border priority over tblBorder If the tblBorder does not exist, or if first row's left-border has a different sized border than the overall table settings, use the cell's lineWidth value to determine the the spacing needed. The potential regression here is the spacing given to the cells. However, the current calculation is totally wrong (it needs to be based on per-cell, not on some table-level default) and so it was "wrong" a different way before. The unit test shows this visually. Plus, MS Office version are inconsistent in handling this unit test. The latest versions base the position on the *last* row and not the first row. The key reason for making this change is to support a table that doesn't have a table default, needed to fix tdf#92026. Change-Id: I319513a2f5550c1527dc564fb8b3806d1251a0c2 Reviewed-on: https://gerrit.libreoffice.org/60988 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf119760_positionCellBorder.docx b/sw/qa/extras/ooxmlexport/data/tdf119760_positionCellBorder.docx new file mode 100644 index 000000000000..17a570e063f0 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf119760_positionCellBorder.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 7aa03eb79cc2..933bd58b1071 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -537,6 +537,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf82177_tblBorders, "tdf82177_tblBorders.docx") CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "LeftBorder").LineWidth); } +DECLARE_OOXMLEXPORT_TEST(testTdf119760_positionCellBorder, "tdf119760_positionCellBorder.docx") +{ + //inconsistent in Word even. 2016 positions on last row, 2003 positions on first cell. + sal_Int32 nRowLeft = parseDump("/root/page/body/tab[4]/row[1]/infos/bounds", "left").toInt32(); + sal_Int32 nTextLeft = parseDump("/root/page/body/tab[4]/row[1]/cell[1]/txt/infos/bounds", "left").toInt32(); + CPPUNIT_ASSERT( nRowLeft < nTextLeft ); +} + DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx") { // This was 0, relative size of shape after bitmap was ignored. diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index cf973bbaef9a..c0a8cbda54db 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -476,14 +476,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo { aTableBorder.LeftLine = aLeftBorder; aTableBorder.IsLeftLineValid = true; - // Only top level table position depends on border width - if (rInfo.nNestLevel == 1) - { - if (rFrameProperties.empty()) - rInfo.nLeftBorderDistance += aLeftBorder.LineWidth * 0.5; - else - lcl_DecrementHoriOrientPosition(rFrameProperties, aLeftBorder.LineWidth * 0.5); - } } if (lcl_extractTableBorderProperty(m_aTableProperties.get(), PROP_RIGHT_BORDER, rInfo, aBorderLine)) { @@ -515,6 +507,25 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo // so table's position depends on table's cells margin // - nested tables: the goal is to have left-most border starting at table_indent pos + // Only top level table position depends on border width of Column A. + // TODO: Position based on last row (at least in MSOffice 2016), but first row in Office 2003. + // Export code is also based on first cell, so using first row here... + if ( rInfo.nNestLevel == 1 && !m_aCellProperties.empty() && !m_aCellProperties[0].empty() ) + { + // aLeftBorder already contains tblBorder; overwrite if cell is different. + const boost::optional<PropertyMap::Property> aCellBorder + = m_aCellProperties[0][0]->getProperty(PROP_LEFT_BORDER); + if ( aCellBorder ) + aCellBorder->second >>= aLeftBorder; + } + if ( rInfo.nNestLevel == 1 && aLeftBorder.LineWidth ) + { + if (rFrameProperties.empty()) + rInfo.nLeftBorderDistance += aLeftBorder.LineWidth * 0.5; + else + lcl_DecrementHoriOrientPosition(rFrameProperties, aLeftBorder.LineWidth * 0.5); + } + // tdf#106742: since MS Word 2013 (compatibilityMode >= 15), top-level tables are handled the same as nested tables; // this is also the default behavior in LO when DOCX doesn't define "compatibilityMode" option sal_Int32 nMode = m_rDMapper_Impl.GetSettingsTable()->GetWordCompatibilityMode(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits