summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorRegényi Balázs <regenyi.balazs+gerrit@gmail.com>2020-05-11 16:16:59 +0200
committerLászló Németh <nemeth@numbertext.org>2020-05-20 17:01:05 +0200
commitc28d6b99599eaeb923804547c3ac849b6feec044 (patch)
treed8d0808b6d18ff210a67fa000f70f9430a76f43f /oox
parent7daab7859f3b5b4297c45ac1631c68387192a962 (diff)
tdf#126363 DOCX shape round-trip: keep original line width
to avoid of rounding error of EMU -> 1/100 mm -> EMU conversions, which messed up recognition of preset line widths in MSO. Co-authored-by: Szabolcs Tóth Change-Id: Ide0e393e667848683f00f9ba7a73ff8a45a908b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94043 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/shape.cxx1
-rw-r--r--oox/source/export/drawingml.cxx8
2 files changed, 8 insertions, 1 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 202e2927e80c..cd7c289e9efa 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1251,6 +1251,7 @@ Reference< XShape > const & Shape::createAndInsert(
// Store original fill and line colors of the shape and the theme color name to InteropGrabBag
std::vector<beans::PropertyValue> aProperties;
+ aProperties.push_back(comphelper::makePropertyValue("EmuLineWidth", aLineProperties.moLineWidth.get(0)));
aProperties.push_back(comphelper::makePropertyValue("OriginalSolidFillClr", aShapeProps.getProperty(PROP_FillColor)));
aProperties.push_back(comphelper::makePropertyValue("OriginalLnSolidFillClr", aShapeProps.getProperty(PROP_LineColor)));
OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeName();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c925819dd9f8..2d44aec64465 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -748,6 +748,7 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
mAny >>= aLineStyle;
sal_uInt32 nLineWidth = 0;
+ sal_uInt32 nEmuLineWidth = 0;
::Color nColor;
sal_Int32 nColorAlpha = MAX_PERCENT;
bool bColorSet = false;
@@ -784,6 +785,8 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
rProp.Value >>= aStyleProperties;
else if( rProp.Name == "SpPrLnSolidFillSchemeClrTransformations" )
rProp.Value >>= aTransformations;
+ else if( rProp.Name == "EmuLineWidth" )
+ rProp.Value >>= nEmuLineWidth;
}
for (const auto& rStyleProp : std::as_const(aStyleProperties))
{
@@ -864,10 +867,13 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
break;
}
+ // if the line-width was not modified after importing then the original EMU value will be exported to avoid unexpected conversion (rounding) error
+ if (nEmuLineWidth == 0 || static_cast<sal_uInt32>(oox::drawingml::convertEmuToHmm(nEmuLineWidth)) != nLineWidth)
+ nEmuLineWidth = oox::drawingml::convertHmmToEmu(nLineWidth);
mpFS->startElementNS( XML_a, XML_ln,
XML_cap, cap,
XML_w, nLineWidth == 0 || (nLineWidth > 1 && nStyleLineWidth != nLineWidth) ?
- OString::number(oox::drawingml::convertHmmToEmu(nLineWidth)).getStr() : nullptr );
+ OString::number(nEmuLineWidth).getStr() : nullptr );
if( bColorSet )
{