From 9cbde4be33d82fc822b11394e713b8d2492bcac8 Mon Sep 17 00:00:00 2001 From: Tünde Tóth Date: Tue, 19 May 2020 10:46:01 +0200 Subject: tdf#125812 Chart: fix OOXML export of gradient center MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See also: commit 898e4ae1364e76af8be22183ac64d73b6a6d8d90 (tdf#128794 Chart: Fix OOXML import/export of Radial gradient) Change-Id: I9486c5b1dfcfd25bbf00d5f11b90c3c02459f634 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94486 Reviewed-by: Balazs Varga Reviewed-by: László Németh Tested-by: László Németh --- oox/source/export/drawingml.cxx | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'oox') diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 0be37c8748f0..21825902f1a0 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -176,9 +176,9 @@ static css::uno::Any getLineDash( const css::uno::Reference& namespace { -void WriteRadialGradientPath(const awt::Gradient& rGradient, const FSHelperPtr& pFS) +void WriteGradientPath(const awt::Gradient& rGradient, const FSHelperPtr& pFS, const bool bCircle) { - pFS->startElementNS(XML_a, XML_path, XML_path, "circle"); + pFS->startElementNS(XML_a, XML_path, XML_path, bCircle ? "circle" : "rect"); // Write the focus rectangle. Work with the focus point, and assume // that it extends 50% in all directions. The below @@ -186,13 +186,13 @@ void WriteRadialGradientPath(const awt::Gradient& rGradient, const FSHelperPtr& // edge of the tile rectangle and 100% means the center of it. rtl::Reference pAttributeList( sax_fastparser::FastSerializerHelper::createAttrList()); - sal_Int32 nLeftPercent = rGradient.XOffset * 2 - 50; + sal_Int32 nLeftPercent = rGradient.XOffset; pAttributeList->add(XML_l, OString::number(nLeftPercent * PER_PERCENT)); - sal_Int32 nTopPercent = rGradient.YOffset * 2 - 50; + sal_Int32 nTopPercent = rGradient.YOffset; pAttributeList->add(XML_t, OString::number(nTopPercent * PER_PERCENT)); - sal_Int32 nRightPercent = (100 - rGradient.XOffset) * 2 - 50; + sal_Int32 nRightPercent = 100 - rGradient.XOffset; pAttributeList->add(XML_r, OString::number(nRightPercent * PER_PERCENT)); - sal_Int32 nBottomPercent = (100 - rGradient.YOffset) * 2 - 50; + sal_Int32 nBottomPercent = 100 - rGradient.YOffset; pAttributeList->add(XML_b, OString::number(nBottomPercent * PER_PERCENT)); sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList.get()); pFS->singleElementNS(XML_a, XML_fillToRect, xAttributeList); @@ -570,7 +570,7 @@ void DrawingML::WriteGrabBagGradientFill( const Sequence< PropertyValue >& aGrad OString::number((((3600 - rGradient.Angle + 900) * 6000) % 21600000))); break; case awt::GradientStyle_RADIAL: - WriteRadialGradientPath(rGradient, mpFS); + WriteGradientPath(rGradient, mpFS, true); break; } } @@ -638,6 +638,9 @@ void DrawingML::WriteGradientFill(awt::Gradient rGradient, awt::Gradient rTransp } case awt::GradientStyle_RADIAL: + case awt::GradientStyle_ELLIPTICAL: + case awt::GradientStyle_RECT: + case awt::GradientStyle_SQUARE: { mpFS->startElementNS(XML_a, XML_gsLst); WriteGradientStop(0, ColorWithIntensity(rGradient.EndColor, rGradient.EndIntensity)); @@ -651,22 +654,9 @@ void DrawingML::WriteGradientFill(awt::Gradient rGradient, awt::Gradient rTransp ColorWithIntensity(rGradient.StartColor, rGradient.StartIntensity)); mpFS->endElementNS(XML_a, XML_gsLst); - WriteRadialGradientPath(rGradient, mpFS); + WriteGradientPath(rGradient, mpFS, rGradient.Style == awt::GradientStyle_RADIAL || rGradient.Style == awt::GradientStyle_ELLIPTICAL); break; } - /* I don't see how to apply transformation to gradients, so - * elliptical will end as radial and square as - * rectangular. also position offsets are not applied */ - case awt::GradientStyle_ELLIPTICAL: - case awt::GradientStyle_RECT: - case awt::GradientStyle_SQUARE: - mpFS->startElementNS(XML_a, XML_gsLst); - WriteGradientStop( 0, ColorWithIntensity( rGradient.EndColor, rGradient.EndIntensity ) ); - WriteGradientStop( 100, ColorWithIntensity( rGradient.StartColor, rGradient.StartIntensity ) ); - mpFS->endElementNS( XML_a, XML_gsLst ); - mpFS->singleElementNS( XML_a, XML_path, - XML_path, ( rGradient.Style == awt::GradientStyle_RADIAL || rGradient.Style == awt::GradientStyle_ELLIPTICAL ) ? "circle" : "rect" ); - break; } } -- cgit v1.2.3