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@collabora.com>
This commit is contained in:
Gülşah Köse
2020-09-18 18:55:17 +02:00
parent 5cd04405c6
commit a11bb74d4f
3 changed files with 42 additions and 6 deletions
+17
View File
@@ -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");
+25 -6
View File
@@ -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));
}