diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-08-25 22:22:55 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-31 17:58:52 +0200 |
commit | cecf71c18da5430c10daa8522d38d5144edefc14 (patch) | |
tree | e5598e6c79c880a6a81ad4944c7198c05d6a9be1 | |
parent | 347a86962bffeaf7420c390a733d2ddd1d78efeb (diff) |
tdf#82177 docx export: no inside borders on outside cells
Well, not on the bottom or right outside cells.
Obviously the presence of a bottom or a right in those
cases doesn't indicate an inside line.
Change-Id: I5d0661fd60f478a392b12fe9093c2e47e130631b
Reviewed-on: https://gerrit.libreoffice.org/59600
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx | bin | 0 -> 8990 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/WW8TableInfo.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/WW8TableInfo.hxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 17 |
5 files changed, 27 insertions, 5 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx b/sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx Binary files differnew file mode 100644 index 000000000000..75c9a656da06 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index e02d829b734f..e289d3a40dba 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -456,6 +456,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112118_DOCX, "tdf112118.docx") } } +DECLARE_OOXMLEXPORT_TEST(testTdf82177_outsideCellBorders, "tdf82177_outsideCellBorders.docx") +{ + 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 ); + uno::Reference< table::XCell > xCell = xTable->getCellByName( "E4" ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "TopBorder").LineWidth); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "LeftBorder").LineWidth); +} + DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx") { // This was 0, relative size of shape after bitmap was ignored. diff --git a/sw/source/filter/ww8/WW8TableInfo.cxx b/sw/source/filter/ww8/WW8TableInfo.cxx index 9713931d1e65..b41639243669 100644 --- a/sw/source/filter/ww8/WW8TableInfo.cxx +++ b/sw/source/filter/ww8/WW8TableInfo.cxx @@ -120,6 +120,10 @@ void WW8TableNodeInfoInner::setRect(const SwRect & rRect) maRect = rRect; } +bool WW8TableNodeInfoInner::isFinalRow() const +{ + return mpTable && mpTable->GetTabLines().size() - 1 == mnRow; +} const SwNode * WW8TableNodeInfoInner::getNode() const { diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx b/sw/source/filter/ww8/WW8TableInfo.hxx index a3b6df799180..f2a2db21806a 100644 --- a/sw/source/filter/ww8/WW8TableInfo.hxx +++ b/sw/source/filter/ww8/WW8TableInfo.hxx @@ -94,6 +94,7 @@ public: bool isEndOfCell() const { return mbEndOfCell;} bool isEndOfLine() const { return mbEndOfLine;} bool isFinalEndOfLine() const { return mbFinalEndOfLine;} + bool isFinalRow() const; bool isFirstInTable() const { return mbFirstInTable;} const SwTableBox * getTableBox() const { return mpTableBox;} const SwTable * getTable() const { return mpTable;} diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 77101984d429..adb5e65d913b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3063,8 +3063,13 @@ static OutputBorderOptions lcl_getBoxBorderOptions() return rOptions; } -static void impl_borders( FSHelperPtr const & pSerializer, const SvxBoxItem& rBox, const OutputBorderOptions& rOptions, - std::map<SvxBoxItemLine, css::table::BorderLine2> &rTableStyleConf ) +static void impl_borders( FSHelperPtr const & pSerializer, + const SvxBoxItem& rBox, + const OutputBorderOptions& rOptions, + std::map<SvxBoxItemLine, + css::table::BorderLine2> &rTableStyleConf, + const bool bIsLastColumn = false, + const bool bIsLastRow = false ) { static const SvxBoxItemLine aBorders[] = { @@ -3156,14 +3161,14 @@ static void impl_borders( FSHelperPtr const & pSerializer, const SvxBoxItem& rBo bWriteInsideV = true; } } - if (bWriteInsideH) + if (bWriteInsideH && !bIsLastRow) { const table::BorderLine2 *aStyleProps = nullptr; if( rTableStyleConf.find( SvxBoxItemLine::BOTTOM ) != rTableStyleConf.end() ) aStyleProps = &rTableStyleConf[ SvxBoxItemLine::BOTTOM ]; impl_borderLine( pSerializer, XML_insideH, rBox.GetLine(SvxBoxItemLine::BOTTOM), 0, false, aStyleProps ); } - if (bWriteInsideV) + if (bWriteInsideV && !bIsLastColumn) { const table::BorderLine2 *aStyleProps = nullptr; if( rTableStyleConf.find( SvxBoxItemLine::RIGHT ) != rTableStyleConf.end() ) @@ -3232,6 +3237,8 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox( ); bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT; + const bool bIsLastColumn = pTableTextNodeInfoInner->isEndOfLine(); + const bool bIsLastRow = pTableTextNodeInfoInner->isFinalRow(); // Output any table cell redlines if there are any attached to this specific cell TableCellRedline( pTableTextNodeInfoInner ); @@ -3291,7 +3298,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point const SvxBoxItem& rDefaultBox = (*tableFirstCells.rbegin())->getTableBox( )->GetFrameFormat( )->GetBox( ); { // The cell borders - impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma), m_aTableStyleConf ); + impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma), m_aTableStyleConf, bIsLastColumn, bIsLastRow ); } TableBackgrounds( pTableTextNodeInfoInner ); |