sw/qa/extras/ooxmlexport/data/tdf125657.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx   |   25 +++++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |    8 ++++----
 3 files changed, 29 insertions(+), 4 deletions(-)

New commits:
commit 166aafde5b716dfeb5325e7d1bee1c163ab56b12
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Jun 4 17:08:04 2019 +1000
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Jun 4 13:06:14 2019 +0200

    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.kagan...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf125657.docx 
b/sw/qa/extras/ooxmlexport/data/tdf125657.docx
new file mode 100755
index 000000000000..eeaad7a4bb3d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf125657.docx differ
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),
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to