diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-06-04 17:08:04 +1000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-06-04 13:06:14 +0200 |
commit | 166aafde5b716dfeb5325e7d1bee1c163ab56b12 (patch) | |
tree | 25f49cd330d24f52449202e86019c839a6300617 /sw | |
parent | 4e3e0c6744b3fc33c7f4da7bd48136b861e9ed58 (diff) |
tdf#125657: restore conversion of a:srcRect attributes to integers
Regression from commit 1fe24bb1e2fbe44a4bf2c03297e259b3a18b1235
Change-Id: I5597fe6a7f7c54ad9bf2634eba5245e2e4a1efbf
Reviewed-on: https://gerrit.libreoffice.org/73430
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/tdf125657.docx | bin | 0 -> 19731 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 25 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 8 |
3 files changed, 29 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf125657.docx b/sw/qa/extras/ooxmlexport/data/tdf125657.docx Binary files differnew file mode 100755 index 000000000000..eeaad7a4bb3d --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf125657.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index edbc0964685d..804d25b9612e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -323,6 +323,31 @@ DECLARE_OOXMLIMPORT_TEST(testTdf121784, "tdf121784.docx") CPPUNIT_ASSERT_EQUAL( OUString( "i" ), getRun( getParagraph( 2 ), 3 )->getString()); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf125657, "tdf125657.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + CPPUNIT_ASSERT(pXmlDoc); + auto checkAttrIsInt = [&](const OString& sAttrName) { + OUString sAttr = getXPath(pXmlDoc, + "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:inline/a:graphic/" + "a:graphicData/pic:pic/pic:blipFill/a:srcRect", + sAttrName); + OString sAssertMsg("Attribute " + sAttrName + " value " + sAttr.toUtf8() + + " is not a valid integer"); + CPPUNIT_ASSERT_MESSAGE(sAssertMsg.getStr(), !sAttr.isEmpty()); + // Only decimal characters allowed, optionally prepended with '-'; no '.' + CPPUNIT_ASSERT_MESSAGE(sAssertMsg.getStr(), + sAttr[0] == '-' || (sAttr[0] >= '0' && sAttr[0] <= '9')); + for (sal_Int32 i = 1; i < sAttr.getLength(); ++i) + CPPUNIT_ASSERT_MESSAGE(sAssertMsg.getStr(), sAttr[i] >= '0' && sAttr[i] <= '9'); + }; + // check that we export all coordinates of srcRect as integers + checkAttrIsInt("l"); + checkAttrIsInt("t"); + checkAttrIsInt("r"); + checkAttrIsInt("b"); +} + 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 6e7fa0632e0d..472649c7585a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4668,10 +4668,10 @@ void DocxAttributeOutput::WriteSrcRect(const SdrObject* pSdrObj, const SwFrameFo double widthMultiplier = 100000.0/aOriginalSize.Width(); double heightMultiplier = 100000.0/aOriginalSize.Height(); - double left = nCropL * widthMultiplier; - double right = nCropR * widthMultiplier; - double top = nCropT * heightMultiplier; - double bottom = nCropB * heightMultiplier; + sal_Int32 left = static_cast<sal_Int32>(rtl::math::round(nCropL * widthMultiplier)); + sal_Int32 right = static_cast<sal_Int32>(rtl::math::round(nCropR * widthMultiplier)); + sal_Int32 top = static_cast<sal_Int32>(rtl::math::round(nCropT * heightMultiplier)); + sal_Int32 bottom = static_cast<sal_Int32>(rtl::math::round(nCropB * heightMultiplier)); m_pSerializer->singleElementNS( XML_a, XML_srcRect, XML_l, OString::number(left), |