sw/qa/extras/ooxmlexport/data/tdf103982.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx    |   10 ++++++++++
 sw/source/filter/ww8/docxsdrexport.cxx       |   13 +++++++++----
 3 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit f9f7a4ddaed85427522834597271967ee494b436
Author: Miklos Vajna <vmik...@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.
    
    Change-Id: I82b3c1ba0e3a14f7c585b0d389264a2c12e454e7
    Reviewed-on: https://gerrit.libreoffice.org/31064
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Jenkins <c...@libreoffice.org>

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/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index a445ea2..2182cbc1 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 0cb5604..5af66a1 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");
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to