summaryrefslogtreecommitdiff
path: root/oox/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-07-15 09:36:23 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-07-15 10:53:17 +0200
commit8a43bfeffab9009c9f373e883fef87af1a7b3843 (patch)
treed1febd3f61307b21a91138a43175ffd8bdaa4d3f /oox/qa
parent7a2b5236cc73993d71ccf46f62d69c6a9fa5a3d1 (diff)
tdf#131175 oox chart import: fix char color of <dLbl>, inherited from <dLbls>
There were two problems here: 1) Our chart model expects the char formatting of a data label as direct formatting, so in case <c:dLbl> has no such formatting, but <c:dLbls> has, oox has to explicitly inherit. 2) The data label char formatting is represented using chart::FormattedString, but the char format of it is not (yet) exported to ODF. Given that the char format of the series and the individual data labels is the same, restore the same formatting on import to please rendering. With these, finally the chart labels in the bugdoc are white, not black (and have a dark background, so they are readable). Change-Id: Iebac5ce0be31a59bafb0f9fe7636330585e33822 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98770 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'oox/qa')
-rw-r--r--oox/qa/unit/data/chart-data-label-char-color.docxbin0 -> 26014 bytes
-rw-r--r--oox/qa/unit/drawingml.cxx43
2 files changed, 43 insertions, 0 deletions
diff --git a/oox/qa/unit/data/chart-data-label-char-color.docx b/oox/qa/unit/data/chart-data-label-char-color.docx
new file mode 100644
index 000000000000..0e389f9237c4
--- /dev/null
+++ b/oox/qa/unit/data/chart-data-label-char-color.docx
Binary files differ
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index e1400c7bfe0c..ee5ae764af70 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -17,6 +17,11 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <unotools/mediadescriptor.hxx>
#include <unotools/tempfile.hxx>
@@ -156,6 +161,44 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPresetAdjustValue)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11587), aAdjustmentSeq[0].Value.get<sal_Int32>());
}
+CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testChartDataLabelCharColor)
+{
+ OUString aURL
+ = m_directories.getURLFromSrc(DATA_DIRECTORY) + "chart-data-label-char-color.docx";
+ load(aURL);
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<chart2::XChartDocument> xModel(xShape->getPropertyValue("Model"),
+ uno::UNO_QUERY);
+ uno::Reference<chart2::XCoordinateSystemContainer> xDiagram(xModel->getFirstDiagram(),
+ uno::UNO_QUERY);
+
+ uno::Reference<chart2::XChartTypeContainer> xCoordinateSystem(
+ xDiagram->getCoordinateSystems()[0], uno::UNO_QUERY);
+
+ uno::Reference<chart2::XDataSeriesContainer> xChartType(xCoordinateSystem->getChartTypes()[0],
+ uno::UNO_QUERY);
+
+ uno::Reference<chart2::XDataSeries> xDataSeries = xChartType->getDataSeries()[0];
+
+ uno::Reference<beans::XPropertySet> xDataPoint = xDataSeries->getDataPointByIndex(0);
+
+ uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aLabels;
+ xDataPoint->getPropertyValue("CustomLabelFields") >>= aLabels;
+ uno::Reference<beans::XPropertySet> xLabel = aLabels[0];
+
+ sal_Int32 nCharColor = 0;
+ xLabel->getPropertyValue("CharColor") >>= nCharColor;
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 16777215
+ // - Actual : -1
+ // i.e. the data label had no explicit (white) color.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff), nCharColor);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */