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

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 13 07:35:07 UTC 2019


 chart2/qa/extras/chart2import.cxx         |   27 +++++++++++++++++++++++++++
 chart2/qa/extras/data/xlsx/tdf128732.xlsx |binary
 oox/source/drawingml/color.cxx            |    2 +-
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 124db1f2e3008493254e5d710221dbdd40a526db
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Tue Nov 12 12:21:20 2019 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Nov 13 08:34:23 2019 +0100

    tdf#128732 Chart OOXML import: fix rounding error of color transparency
    
    Change-Id: I52efb541d62a9536c2eb5f99453dc2cb594e6fe4
    Reviewed-on: https://gerrit.libreoffice.org/82500
    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/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index f04b42d2db6f..665b9f96e62d 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -33,6 +33,8 @@
 #include <iterator>
 
 #include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 
 class Chart2ImportTest : public ChartTest
 {
@@ -63,6 +65,7 @@ public:
     void testODPChartSeries();
     void testBnc864396();
     void testBnc882383();
+    void testTransparancyGradientValue();
     void testBnc889755();
     void testSimpleStrictXLSX();
     void testDelayedCellImport(); // chart range referencing content on later sheets
@@ -167,6 +170,7 @@ public:
     CPPUNIT_TEST(testODPChartSeries);
     CPPUNIT_TEST(testBnc864396);
     CPPUNIT_TEST(testBnc882383);
+    CPPUNIT_TEST(testTransparancyGradientValue);
     CPPUNIT_TEST(testBnc889755);
     CPPUNIT_TEST(testSimpleStrictXLSX);
     CPPUNIT_TEST(testDelayedCellImport);
@@ -814,6 +818,29 @@ void Chart2ImportTest::testBnc882383()
     CPPUNIT_ASSERT(!sGradientName.isEmpty());
 }
 
+void Chart2ImportTest::testTransparancyGradientValue()
+{
+    load("/chart2/qa/extras/data/xlsx/", "tdf128732.xlsx");
+    uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent);
+    CPPUNIT_ASSERT(xChartDoc.is());
+    uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+    CPPUNIT_ASSERT(xDataSeries.is());
+
+    uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
+    OUString sTranspGradientName;
+    xPropertySet->getPropertyValue("FillTransparenceGradientName") >>= sTranspGradientName;
+    CPPUNIT_ASSERT(!sTranspGradientName.isEmpty());
+
+    awt::Gradient aTransparenceGradient;
+    uno::Reference< lang::XMultiServiceFactory > xFact(xChartDoc, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xFact.is());
+    uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
+    uno::Any rTransparenceValue = xTransparenceGradient->getByName(sTranspGradientName);
+    CPPUNIT_ASSERT(rTransparenceValue >>= aTransparenceGradient);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3355443), aTransparenceGradient.EndColor);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5000268), aTransparenceGradient.StartColor);
+}
+
 void Chart2ImportTest::testSimpleStrictXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "strict_chart.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/tdf128732.xlsx b/chart2/qa/extras/data/xlsx/tdf128732.xlsx
new file mode 100644
index 000000000000..b92afb1ed6c5
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/tdf128732.xlsx differ
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index 325b68227fe9..09b033352877 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -623,7 +623,7 @@ bool Color::hasTransparency() const
 
 sal_Int16 Color::getTransparency() const
 {
-    return static_cast< sal_Int16 >( (MAX_PERCENT - mnAlpha) / PER_PERCENT );
+    return sal_Int16(std::round( (1.0 * (MAX_PERCENT - mnAlpha)) / PER_PERCENT) );
 }
 
 // private --------------------------------------------------------------------


More information about the Libreoffice-commits mailing list