[Libreoffice-commits] core.git: oox/source sw/qa
Regényi Balázs (via logerrit)
logerrit at kemper.freedesktop.org
Wed May 20 15:01:42 UTC 2020
oox/source/drawingml/shape.cxx | 1 +
oox/source/export/drawingml.cxx | 8 +++++++-
sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 10 ++++++++++
4 files changed, 18 insertions(+), 1 deletion(-)
New commits:
commit c28d6b99599eaeb923804547c3ac849b6feec044
Author: Regényi Balázs <regenyi.balazs+gerrit at gmail.com>
AuthorDate: Mon May 11 16:16:59 2020 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Wed May 20 17:01:05 2020 +0200
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 at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
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 )
{
diff --git a/sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx b/sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx
new file mode 100644
index 000000000000..180383ec6842
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index a591a3caa8fe..dd6544eb3173 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -971,6 +971,16 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf131539, "tdf131539.odt")
CPPUNIT_ASSERT(aXmlVal.indexOf("margin-left:139.95")>-1);
}
+DECLARE_OOXMLEXPORT_TEST(testLineWidthRounding, "tdf126363_LineWidthRounding.docx")
+{
+ // tdf#126363: check if line with stays the same after export
+ xmlDocUniquePtr pXml = parseExport("word/document.xml");
+ if (!pXml)
+ return;
+ // this was 57240 (it differs from the original 57150, losing the preset line width)
+ assertXPath(pXml, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln", "w", "57150");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list