diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-11-22 09:23:28 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-11-22 09:26:37 +0000 |
commit | f9f7a4ddaed85427522834597271967ee494b436 (patch) | |
tree | 8007a43d1f534faf0617f649176b9e9311b246c8 | |
parent | 5c12939540fafb02de2f8c91a3022f9e16a1e38f (diff) |
tdf#103982 DOCX export: make sure SdrObject margin is non-negative
Regression from commit a5a836d8c43dc9cebbbf8af39bf0142de603a7c6 (DOCX
filter: effect extent should be part of the margin, 2014-12-04), the
effect extent is added to the nominal margin in DOCX, so we exclude that
from the margin in our document model. But it shouldn't be ever
negative, ST_WrapDistance is a restriction of the W3C XML Schema
unsignedInt datatype.
Change-Id: I82b3c1ba0e3a14f7c585b0d389264a2c12e454e7
Reviewed-on: https://gerrit.libreoffice.org/31064
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf103982.docx | bin | 0 -> 12085 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 13 |
3 files changed, 19 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf103982.docx b/sw/qa/extras/ooxmlexport/data/tdf103982.docx Binary files differnew file mode 100644 index 000000000000..13e645356bf5 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf103982.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index a445ea2439fd..2182cbc1daab 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -118,6 +118,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf79329, "tdf79329.docx") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xTables->getCount()); } +DECLARE_OOXMLEXPORT_TEST(testTdf103982, "tdf103982.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + sal_Int32 nDistB = getXPath(pXmlDoc, "//wp:anchor", "distB").toInt32(); + // This was -260350, which is not a valid value for an unsigned type. + CPPUNIT_ASSERT(nDistB >= 0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 0cb5604749c0..5af66a1a56d8 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -359,10 +359,15 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons lclMovePositionWithRotation(aPos, rSize, pObj->GetRotateAngle()); } attrList->add(XML_behindDoc, bOpaque ? "0" : "1"); - attrList->add(XML_distT, OString::number(TwipsToEMU(aULSpaceItem.GetUpper()) - nTopExt).getStr()); - attrList->add(XML_distB, OString::number(TwipsToEMU(aULSpaceItem.GetLower()) - nBottomExt).getStr()); - attrList->add(XML_distL, OString::number(TwipsToEMU(aLRSpaceItem.GetLeft()) - nLeftExt).getStr()); - attrList->add(XML_distR, OString::number(TwipsToEMU(aLRSpaceItem.GetRight()) - nRightExt).getStr()); + // The type of dist* attributes is unsigned, so make sure no negative value is written. + sal_Int64 nDistT = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aULSpaceItem.GetUpper()) - nTopExt); + attrList->add(XML_distT, OString::number(nDistT).getStr()); + sal_Int64 nDistB = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aULSpaceItem.GetLower()) - nBottomExt); + attrList->add(XML_distB, OString::number(nDistB).getStr()); + sal_Int64 nDistL = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aLRSpaceItem.GetLeft()) - nLeftExt); + attrList->add(XML_distL, OString::number(nDistL).getStr()); + sal_Int64 nDistR = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aLRSpaceItem.GetRight()) - nRightExt); + attrList->add(XML_distR, OString::number(nDistR).getStr()); attrList->add(XML_simplePos, "0"); attrList->add(XML_locked, "0"); attrList->add(XML_layoutInCell, "1"); |