summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/qa/extras/chart2export.cxx13
-rw-r--r--chart2/qa/extras/data/docx/tdf128794.docxbin0 -> 31616 bytes
-rw-r--r--oox/source/drawingml/fillproperties.cxx36
3 files changed, 37 insertions, 12 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 571a0da80132..5909bfd2c5db 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -96,6 +96,7 @@ public:
void testColorGradientWithTransparancyDOCX();
void testColorGradientWithTransparancyODS();
void testColorGradientStopXLSX();
+ void testRadialColorGradientDOCX();
void testBarChartDataPointPropDOCX();
void testFdo83058dlblPos();
void testAutoTitleDelXLSX();
@@ -225,6 +226,7 @@ public:
CPPUNIT_TEST(testColorGradientWithTransparancyDOCX);
CPPUNIT_TEST(testColorGradientWithTransparancyODS);
CPPUNIT_TEST(testColorGradientStopXLSX);
+ CPPUNIT_TEST(testRadialColorGradientDOCX);
CPPUNIT_TEST(testBarChartDataPointPropDOCX);
CPPUNIT_TEST(testFdo83058dlblPos);
CPPUNIT_TEST(testAutoTitleDelXLSX);
@@ -1347,6 +1349,17 @@ void Chart2ExportTest::testColorGradientStopXLSX()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[2]", "pos", "100000");
}
+void Chart2ExportTest::testRadialColorGradientDOCX()
+{
+ load("/chart2/qa/extras/data/docx/", "tdf128794.docx");
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+ // Test the gradeint style (if there is no 'a:path' attribute, it is a linear gradient)
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path", 0);
+ // Test the linear gradeint angle
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:lin", "ang", "13500000");
+}
+
void Chart2ExportTest::testBarChartDataPointPropDOCX()
{
load("/chart2/qa/extras/data/docx/", "testBarChartDataPointPropDOCX.docx");
diff --git a/chart2/qa/extras/data/docx/tdf128794.docx b/chart2/qa/extras/data/docx/tdf128794.docx
new file mode 100644
index 000000000000..098c0a00e3cc
--- /dev/null
+++ b/chart2/qa/extras/data/docx/tdf128794.docx
Binary files differ
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 );