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 /sw/source | |
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>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
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"); |