diff options
author | Tünde Tóth <tundeth@gmail.com> | 2020-05-19 10:46:01 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-05-25 11:18:59 +0200 |
commit | 9cbde4be33d82fc822b11394e713b8d2492bcac8 (patch) | |
tree | c31890a67cc9c3beaef32b8033a90cef5d4f650e /oox | |
parent | 5e975fe97ec9d4c28f7a18e471e1f6cef185d857 (diff) |
tdf#125812 Chart: fix OOXML export of gradient center
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 <balazs.varga991@gmail.com>
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 32 |
1 files changed, 11 insertions, 21 deletions
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<css::frame::XModel>& 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<sax_fastparser::FastAttributeList> 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; } } |