[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Nov 23 21:02:27 UTC 2016
sw/qa/extras/ooxmlexport/data/tdf103982.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 ++++++++++
sw/source/filter/ww8/docxsdrexport.cxx | 13 +++++++++----
3 files changed, 19 insertions(+), 4 deletions(-)
New commits:
commit 3cf2b5e0e8edc9d6044f8bc29ca9374f75b498a5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Nov 22 09:23:28 2016 +0100
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 at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf103982.docx b/sw/qa/extras/ooxmlexport/data/tdf103982.docx
new file mode 100644
index 0000000..13e6453
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103982.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 90cef9f..3d9d749 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 1eecce9..a8160a3 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");
More information about the Libreoffice-commits
mailing list