sw/qa/extras/ooxmlexport/data/tdf129452_BottomBorders.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 13 +++++++++ writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 17 ++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-)
New commits: commit 63518134fc0a148dcce75bebaba43dc5ae761da8 Author: Szabolcs Toth <szabolcs...@gmail.com> AuthorDate: Mon Dec 30 10:09:34 2019 +0100 Commit: Xisco Faulí <xiscofa...@libreoffice.org> CommitDate: Mon Jan 20 09:18:57 2020 +0100 tdf#129452 DOCX import: fix bottom border of merged column Bottom border of a vertically merged column of a table was missing if the inside borders were turned off and the merge included the last cell of the column. This happened because the first cell (topmost) in a set of vertically merged cells determines the borders of the new merged cell, and the turned off inside borders were at the bottom in this case. Change-Id: I3d3defad18a1315117a554a36ad599eb46daffe9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85988 Reviewed-by: László Németh <nem...@numbertext.org> Tested-by: László Németh <nem...@numbertext.org> (cherry picked from commit 0f4dd820ee433932d9d9237b676292d31c4ba913) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86430 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf129452_BottomBorders.docx b/sw/qa/extras/ooxmlexport/data/tdf129452_BottomBorders.docx new file mode 100644 index 000000000000..0e8ddd6d3833 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf129452_BottomBorders.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index 4511509e69cd..55ac7efb2718 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -1048,6 +1048,19 @@ DECLARE_OOXMLEXPORT_TEST(testBottomBorder, "tdf129450_BottomBorder.docx") assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:tcPr/w:tcBorders/w:bottom [@w:val = 'nil']", 0); } +DECLARE_OOXMLEXPORT_TEST(testBottomBorders, "tdf129452_BottomBorders.docx") +{ + // tdf#129452: Do not omit bottom borders when a column in a table is vertically merged and + // the inside borders are turned off. + + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + if (!pXmlDocument) + return; + + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom [@w:val = 'nil']", 0); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[2]/w:tcPr/w:tcBorders/w:bottom [@w:val = 'nil']", 0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index b3bd18de4931..820408638a8d 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -98,7 +98,7 @@ static void lcl_mergeBorder( PropertyIds nId, const PropertyMapPtr& pOrig, const } static void lcl_computeCellBorders( const PropertyMapPtr& pTableBorders, const PropertyMapPtr& pCellProps, - sal_Int32 nCell, sal_Int32 nRow, bool bIsEndCol, bool bIsEndRow ) + sal_Int32 nCell, sal_Int32 nRow, bool bIsEndCol, bool bIsEndRow, bool bMergedVertically ) { boost::optional<PropertyMap::Property> pVerticalVal = pCellProps->getProperty(META_PROP_VERTICAL_BORDER); boost::optional<PropertyMap::Property> pHorizontalVal = pCellProps->getProperty(META_PROP_HORIZONTAL_BORDER); @@ -157,10 +157,13 @@ static void lcl_computeCellBorders( const PropertyMapPtr& pTableBorders, const P if ( nRow == 0 ) { lcl_mergeBorder( PROP_TOP_BORDER, pTableBorders, pCellProps ); - if ( pHorizontalVal ) + if ( pHorizontalVal && !bMergedVertically ) pCellProps->Insert( PROP_BOTTOM_BORDER, aHorizProp, false ); } + if ( bMergedVertically ) + lcl_mergeBorder( PROP_BOTTOM_BORDER, pTableBorders, pCellProps ); + if ( bIsEndRow ) { lcl_mergeBorder( PROP_BOTTOM_BORDER, pTableBorders, pCellProps ); @@ -841,7 +844,15 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl rInfo.pTableBorders->Erase(META_PROP_HORIZONTAL_BORDER); } - lcl_computeCellBorders( rInfo.pTableBorders, *aCellIterator, nCell, nRow, bIsEndCol, bIsEndRow ); + // tdf#129452 Checking if current cell is vertically merged with all the other cells below to the bottom. + // This must be done in order to apply the bottom border of the table to the first cell in a vertical merge. + bool bMergedVertically = bool(m_aCellProperties[nRow][nCell]->getProperty(PROP_VERTICAL_MERGE)); + + for (size_t i = nRow + 1; bMergedVertically && i < m_aCellProperties.size(); i++) + if ( m_aCellProperties[i].size() > sal::static_int_cast<std::size_t>(nCell) ) + bMergedVertically = bool(m_aCellProperties[i][nCell]->getProperty(PROP_VERTICAL_MERGE)); + + lcl_computeCellBorders( rInfo.pTableBorders, *aCellIterator, nCell, nRow, bIsEndCol, bIsEndRow, bMergedVertically ); //now set the default left+right border distance TODO: there's an sprm containing the default distance! aCellIterator->get()->Insert( PROP_LEFT_BORDER_DISTANCE, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits