[Libreoffice-commits] core.git: chart2/qa oox/source

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Mon May 25 09:19:34 UTC 2020


 chart2/qa/extras/chart2export.cxx                    |   14 ++++++++
 chart2/qa/extras/data/odp/ellipticalGradientFill.odp |binary
 oox/source/export/drawingml.cxx                      |   32 ++++++-------------
 3 files changed, 25 insertions(+), 21 deletions(-)

New commits:
commit 9cbde4be33d82fc822b11394e713b8d2492bcac8
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Tue May 19 10:46:01 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon May 25 11:18:59 2020 +0200

    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 at gmail.com>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

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
new file mode 100644
index 000000000000..754f439e5864
Binary files /dev/null and b/chart2/qa/extras/data/odp/ellipticalGradientFill.odp differ
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;
     }
 }
 


More information about the Libreoffice-commits mailing list