summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-05-05 16:58:23 +0200
committerLászló Németh <nemeth@numbertext.org>2020-05-12 16:50:45 +0200
commit898e4ae1364e76af8be22183ac64d73b6a6d8d90 (patch)
treeca73d6cd6a622f5a456dc823366f02a758cb4044 /oox
parentfdf5bb5001422941e9d43e34ce88243e0e52109c (diff)
tdf#128794 Chart: Fix OOXML import/export of Radial gradient
Style should be radial at least when the horizontal/vertical center is not in the corner of a shape. Otherwise import as a linear gradient, because it is the most similar to the MSO radial style. Change-Id: I9bab7b787897bde51a06a950487de9843eb717a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93497 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: Tünde Tóth <tundeth@gmail.com> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/fillproperties.cxx36
1 files changed, 24 insertions, 12 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index acc13271ebc1..023af3bc613f 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -374,23 +374,35 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
if( maGradientProps.moGradientPath.has() )
{
- // position of gradient center (limited to [30%;100%], otherwise gradient is too hidden)
IntegerRectangle2D aFillToRect = maGradientProps.moFillToRect.get( IntegerRectangle2D( 0, 0, MAX_PERCENT, MAX_PERCENT ) );
sal_Int32 nCenterX = (MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
aGradient.XOffset = getLimitedValue<sal_Int16, sal_Int32>(
- nCenterX / PER_PERCENT, 30, 100);
-
- // Style should be radial at least when the horizontal center is at 50%.
- awt::GradientStyle eCircle = aGradient.XOffset == 50
- ? awt::GradientStyle_RADIAL
- : awt::GradientStyle_ELLIPTICAL;
- aGradient.Style = (maGradientProps.moGradientPath.get() == XML_circle)
- ? eCircle
- : awt::GradientStyle_RECT;
-
+ nCenterX / PER_PERCENT, 0, 100);
sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
aGradient.YOffset = getLimitedValue<sal_Int16, sal_Int32>(
- nCenterY / PER_PERCENT, 30, 100);
+ nCenterY / PER_PERCENT, 0, 100);
+
+ if( maGradientProps.moGradientPath.get() == XML_circle )
+ {
+ // Style should be radial at least when the horizontal center is at 50%.
+ // Otherwise import as a linear gradient, because it is the most similar to the MSO radial style.
+ aGradient.Style = awt::GradientStyle_LINEAR;
+ if( aGradient.XOffset == 100 && aGradient.YOffset == 100 )
+ aGradient.Angle = 450;
+ else if( aGradient.XOffset == 0 && aGradient.YOffset == 100 )
+ aGradient.Angle = 3150;
+ else if( aGradient.XOffset == 100 && aGradient.YOffset == 0 )
+ aGradient.Angle = 1350;
+ else if( aGradient.XOffset == 0 && aGradient.YOffset == 0 )
+ aGradient.Angle = 2250;
+ else
+ aGradient.Style = awt::GradientStyle_RADIAL;
+ }
+ else
+ {
+ aGradient.Style = awt::GradientStyle_RECT;
+ }
+
::std::swap( aGradient.StartColor, aGradient.EndColor );
::std::swap( nStartTrans, nEndTrans );