sw/qa/extras/ooxmlexport/data/tdf136814.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 11 +++++++++++ sw/qa/extras/ww8export/data/tdf136814.odt |binary sw/qa/extras/ww8export/ww8export3.cxx | 12 ++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 2 +- sw/source/filter/ww8/ww8atr.cxx | 3 +-- 6 files changed, 25 insertions(+), 3 deletions(-)
New commits: commit 5cbdda84ff4c0b1b5e22bc8965fb5c4c275c365c Author: Sven Lüppken <s...@slueppken.de> AuthorDate: Sat Oct 31 19:42:50 2020 +0100 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Nov 1 14:07:04 2020 +0100 tdf#136814 Fix border padding in Word export While converting twips to points in the Word export filer, information is lost due to integer division. This patch tries to fix this by using floating-point division and (hopefully) proper rounding. The example document attached to the bug ticket works as expected now. Change-Id: I4b5b2163e42932b5e877726d16635d9f02a43cb2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105128 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf136814.odt b/sw/qa/extras/ooxmlexport/data/tdf136814.odt new file mode 100644 index 000000000000..2318de04b762 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf136814.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index c2466dc809e6..8d98ccd39487 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -844,6 +844,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135660, "tdf135660.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("Bottom wrap distance is wrong", static_cast<sal_Int32>(199), nWrapDistanceBottom); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf136814, "tdf136814.odt") +{ + xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); + + // Padding in this document is 0.10 cm which should translate to 3 pt (approx. 1.0583mm) + assertXPath(pXmlDocument, "/w:document/w:body/w:sectPr/w:pgBorders/w:top", "space", "3"); + assertXPath(pXmlDocument, "/w:document/w:body/w:sectPr/w:pgBorders/w:left", "space", "3"); + assertXPath(pXmlDocument, "/w:document/w:body/w:sectPr/w:pgBorders/w:bottom", "space", "3"); + assertXPath(pXmlDocument, "/w:document/w:body/w:sectPr/w:pgBorders/w:right", "space", "3"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ww8export/data/tdf136814.odt b/sw/qa/extras/ww8export/data/tdf136814.odt new file mode 100644 index 000000000000..2318de04b762 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf136814.odt differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 380463e96f2f..c32ff278cc7a 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -677,6 +677,18 @@ DECLARE_WW8EXPORT_TEST(testTdf134570, "tdf134570.doc") } } +DECLARE_WW8EXPORT_TEST(testTdf136814, "tdf136814.odt") +{ + uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + sal_Int32 nBorderDistance = static_cast<sal_Int32>(106); + + CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "TopBorderDistance")); + CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "RightBorderDistance")); + CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "BottomBorderDistance")); + CPPUNIT_ASSERT_EQUAL(nBorderDistance, getProperty<sal_Int32>(xStyle, "LeftBorderDistance")); +} + + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 53f7462de3a9..c2eeeec1bee6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3369,7 +3369,7 @@ static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementT pAttr->add( FSNS( XML_w, XML_sz ), OString::number( nWidth ) ); // Get the distance (in pt) - pAttr->add( FSNS( XML_w, XML_space ), OString::number( nDist / 20 ) ); + pAttr->add(FSNS(XML_w, XML_space), OString::number(rtl::math::round(nDist / 20.0))); // Get the color code as an RRGGBB hex value OString sColor( msfilter::util::ConvertColor( pBorderLine->GetColor( ) ) ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 9604d4237269..29bb0369ded2 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -4365,8 +4365,7 @@ WW8_BRCVer9 WW8Export::TranslateBorderLine(const SvxBorderLine& rLine, } // BRC.dptSpace - sal_uInt16 nLDist = nDist; - nLDist /= 20; // unit of measurement: pt + sal_uInt16 nLDist = rtl::math::round(nDist / 20.0); // unit of measurement: pt if( nLDist > 0x1f ) nLDist = 0x1f; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits