summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-11-22 09:23:28 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-11-23 21:01:58 +0000
commit3cf2b5e0e8edc9d6044f8bc29ca9374f75b498a5 (patch)
tree4f320155e1668686cdf3f07d1f77140e93e62910
parente7145b142d21af4d23a21a8490dcbbd0fb42685a (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. (cherry picked from commit f9f7a4ddaed85427522834597271967ee494b436) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport9.cxx Change-Id: I82b3c1ba0e3a14f7c585b0d389264a2c12e454e7 Reviewed-on: https://gerrit.libreoffice.org/31115 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf103982.docxbin0 -> 12085 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx10
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx13
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
new file mode 100644
index 000000000000..13e645356bf5
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf103982.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 90cef9f800f8..3d9d749ed458 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -832,6 +832,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf44986, "tdf44986.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
}
+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 1eecce9301ca..a8160a3f68c1 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -364,10 +364,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");