diff options
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 14 | ||||
-rw-r--r-- | chart2/qa/extras/data/odp/ellipticalGradientFill.odp | bin | 0 -> 17071 bytes | |||
-rw-r--r-- | oox/source/export/drawingml.cxx | 32 |
3 files changed, 25 insertions, 21 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 84a38b258733..08086d8ae2ab 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -167,6 +167,7 @@ public: void testTdf127792(); void testTdf131979(); void testTdf132076(); + void testTdf125812(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(testErrorBarXLSX); @@ -297,6 +298,7 @@ public: CPPUNIT_TEST(testTdf127792); CPPUNIT_TEST(testTdf131979); CPPUNIT_TEST(testTdf132076); + CPPUNIT_TEST(testTdf125812); CPPUNIT_TEST_SUITE_END(); @@ -2752,6 +2754,18 @@ void Chart2ExportTest::testTdf132076() } } +void Chart2ExportTest::testTdf125812() +{ + load("/chart2/qa/extras/data/odp/", "ellipticalGradientFill.odp"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path", "path", "circle"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "l", "50000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "t", "49000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "r", "50000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "b", "51000"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/odp/ellipticalGradientFill.odp b/chart2/qa/extras/data/odp/ellipticalGradientFill.odp Binary files differnew file mode 100644 index 000000000000..754f439e5864 --- /dev/null +++ b/chart2/qa/extras/data/odp/ellipticalGradientFill.odp 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; } } |