Kaydet (Commit) 166aafde authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#125657: restore conversion of a:srcRect attributes to integers

Regression from commit 1fe24bb1

Change-Id: I5597fe6a7f7c54ad9bf2634eba5245e2e4a1efbf
Reviewed-on: https://gerrit.libreoffice.org/73430
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 4e3e0c67
...@@ -323,6 +323,31 @@ DECLARE_OOXMLIMPORT_TEST(testTdf121784, "tdf121784.docx") ...@@ -323,6 +323,31 @@ DECLARE_OOXMLIMPORT_TEST(testTdf121784, "tdf121784.docx")
CPPUNIT_ASSERT_EQUAL( OUString( "i" ), getRun( getParagraph( 2 ), 3 )->getString()); 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(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -4668,10 +4668,10 @@ void DocxAttributeOutput::WriteSrcRect(const SdrObject* pSdrObj, const SwFrameFo ...@@ -4668,10 +4668,10 @@ void DocxAttributeOutput::WriteSrcRect(const SdrObject* pSdrObj, const SwFrameFo
double widthMultiplier = 100000.0/aOriginalSize.Width(); double widthMultiplier = 100000.0/aOriginalSize.Width();
double heightMultiplier = 100000.0/aOriginalSize.Height(); double heightMultiplier = 100000.0/aOriginalSize.Height();
double left = nCropL * widthMultiplier; sal_Int32 left = static_cast<sal_Int32>(rtl::math::round(nCropL * widthMultiplier));
double right = nCropR * widthMultiplier; sal_Int32 right = static_cast<sal_Int32>(rtl::math::round(nCropR * widthMultiplier));
double top = nCropT * heightMultiplier; sal_Int32 top = static_cast<sal_Int32>(rtl::math::round(nCropT * heightMultiplier));
double bottom = nCropB * heightMultiplier; sal_Int32 bottom = static_cast<sal_Int32>(rtl::math::round(nCropB * heightMultiplier));
m_pSerializer->singleElementNS( XML_a, XML_srcRect, m_pSerializer->singleElementNS( XML_a, XML_srcRect,
XML_l, OString::number(left), XML_l, OString::number(left),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment