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

Gülşah Köse (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 18 16:55:58 UTC 2020


 chart2/qa/extras/chart2export.cxx                      |   17 +++++++++
 chart2/qa/extras/data/xlsx/data_labels_fill_color.xlsx |binary
 oox/source/export/chartexport.cxx                      |   31 +++++++++++++----
 3 files changed, 42 insertions(+), 6 deletions(-)

New commits:
commit a11bb74d4f464e9639ddb5b8d87dc4770663fea8
Author:     Gülşah Köse <gulsah.kose at collabora.com>
AuthorDate: Fri Sep 18 13:20:30 2020 +0300
Commit:     Gülşah Köse <gulsah.kose at collabora.com>
CommitDate: Fri Sep 18 18:55:17 2020 +0200

    tdf#136247 OOXML export data label background color.
    
    Change-Id: Ie3e00e8195239e6570bfe76c2451bae11c209145
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102999
    Tested-by: Jenkins
    Reviewed-by: Gülşah Köse <gulsah.kose at collabora.com>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 8916208f8bde..49edb53991fe 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -107,6 +107,7 @@ public:
     void testAxisNumberFormatXLSX();
     void testDataPointLabelNumberFormatXLSX();
     void testDataLabelDefaultValuesXLSX();
+    void testDataLabelFillColor();
     void testTitleOverlayXLSX();
     void testInvertIfNegativeXLSX();
     void testBubble3DXLSX();
@@ -248,6 +249,7 @@ public:
     CPPUNIT_TEST(testAxisNumberFormatXLSX);
     CPPUNIT_TEST(testDataPointLabelNumberFormatXLSX);
     CPPUNIT_TEST(testDataLabelDefaultValuesXLSX);
+    CPPUNIT_TEST(testDataLabelFillColor);
     CPPUNIT_TEST(testTitleOverlayXLSX);
     CPPUNIT_TEST(testInvertIfNegativeXLSX);
     CPPUNIT_TEST(testBubble3DXLSX);
@@ -1739,6 +1741,21 @@ void Chart2ExportTest::testDataLabelDefaultValuesXLSX()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLblPos", "val", "outEnd");
 }
 
+void Chart2ExportTest::testDataLabelFillColor()
+{
+    load("/chart2/qa/extras/data/xlsx/", "data_labels_fill_color.xlsx");
+    Reference< chart2::XChartDocument> xDoc = getChartDocFromSheet(0, mxComponent);
+    Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xDoc, 0);
+    Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
+    uno::Any aAny = xPropSet->getPropertyValue("LabelFillColor");
+    sal_Int32 nLabelFillColor;
+    CPPUNIT_ASSERT(aAny >>= nLabelFillColor);
+
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    CPPUNIT_ASSERT(pXmlDoc);
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:spPr/a:solidFill/a:srgbClr", "val", "F79646");
+}
+
 void Chart2ExportTest::testTitleOverlayXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "chart_title.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/data_labels_fill_color.xlsx b/chart2/qa/extras/data/xlsx/data_labels_fill_color.xlsx
new file mode 100644
index 000000000000..1a55f5b86836
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/data_labels_fill_color.xlsx differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 12b3aba485ab..4d830f37c6ba 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3407,27 +3407,46 @@ void writeLabelProperties( const FSHelperPtr& pFS, ChartExport* pChartExport,
     Sequence<Reference<chart2::XDataPointCustomLabelField>> aCustomLabelFields;
     sal_Int32 nLabelBorderWidth = 0;
     sal_Int32 nLabelBorderColor = 0x00FFFFFF;
+    sal_Int32 nLabelFillColor = -1;
 
     xPropSet->getPropertyValue("Label") >>= aLabel;
     xPropSet->getPropertyValue("CustomLabelFields") >>= aCustomLabelFields;
     xPropSet->getPropertyValue("LabelBorderWidth") >>= nLabelBorderWidth;
     xPropSet->getPropertyValue("LabelBorderColor") >>= nLabelBorderColor;
+    xPropSet->getPropertyValue("LabelFillColor") >>= nLabelFillColor;
 
-    if (nLabelBorderWidth > 0)
+    if (nLabelBorderWidth > 0 || nLabelFillColor != -1)
     {
         pFS->startElement(FSNS(XML_c, XML_spPr));
-        pFS->startElement(FSNS(XML_a, XML_ln), XML_w,
-                          OString::number(convertHmmToEmu(nLabelBorderWidth)));
-        if (nLabelBorderColor != -1)
+
+        if (nLabelFillColor != -1)
         {
             pFS->startElement(FSNS(XML_a, XML_solidFill));
 
-            OString aStr = OString::number(nLabelBorderColor, 16).toAsciiUpperCase();
+            OString aStr = OString::number(nLabelFillColor, 16).toAsciiUpperCase();
             pFS->singleElement(FSNS(XML_a, XML_srgbClr), XML_val, aStr);
 
             pFS->endElement(FSNS(XML_a, XML_solidFill));
         }
-        pFS->endElement(FSNS(XML_a, XML_ln));
+
+        if (nLabelBorderWidth > 0)
+        {
+            pFS->startElement(FSNS(XML_a, XML_ln), XML_w,
+                              OString::number(convertHmmToEmu(nLabelBorderWidth)));
+
+            if (nLabelBorderColor != -1)
+            {
+                pFS->startElement(FSNS(XML_a, XML_solidFill));
+
+                OString aStr = OString::number(nLabelBorderColor, 16).toAsciiUpperCase();
+                pFS->singleElement(FSNS(XML_a, XML_srgbClr), XML_val, aStr);
+
+                pFS->endElement(FSNS(XML_a, XML_solidFill));
+            }
+
+            pFS->endElement(FSNS(XML_a, XML_ln));
+        }
+
         pFS->endElement(FSNS(XML_c, XML_spPr));
     }
 


More information about the Libreoffice-commits mailing list