summaryrefslogtreecommitdiff
path: root/chart2/qa
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2018-01-04 22:15:32 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2018-01-29 23:49:42 +0100
commit790f9abeb1a1167ad5ab84c5fb855b36669c125b (patch)
treedea7c957b67be7518d2092614b82f18148817265 /chart2/qa
parenta1f933ee2b9e23a505d937035821e9571cf4119c (diff)
tdf#114821 import complex data labels in bar chart
* import static text & fields: VALUE, SERIESNAME, COLUMNNAME * text is formatted * DataPointCustomLabelField with field type (DataPointCustomLabelFieldType) was introduced. * text can have many portions & multiple lines * unit tests for import data labels with formatting Not implemented: CELLREF field support which needs importing some additional data from extLst Shows custom text as a label for data points. Change-Id: Iba8fd508eb16356b05586b93d7b8da32240d2b91 Reviewed-on: https://gerrit.libreoffice.org/48243 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'chart2/qa')
-rw-r--r--chart2/qa/extras/chart2import.cxx154
-rw-r--r--chart2/qa/extras/data/pptx/tdf115107-2.pptxbin0 -> 50519 bytes
-rw-r--r--chart2/qa/extras/data/pptx/tdf115107.pptxbin0 -> 50726 bytes
3 files changed, 154 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index b7e1bb79faec..dee428264d69 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -11,6 +11,8 @@
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/chart2/CurveStyle.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelField.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelFieldType.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -101,6 +103,9 @@ public:
void testInternalDataProvider();
+ void testTdf115107(); // import complex data point labels
+ void testTdf115107_2(); // import complex data point labels in cobo charts with multiple data series
+
CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083);
CPPUNIT_TEST(testSteppedLines);
@@ -160,6 +165,9 @@ public:
CPPUNIT_TEST(testInternalDataProvider);
+ CPPUNIT_TEST(testTdf115107);
+ CPPUNIT_TEST(testTdf115107_2);
+
CPPUNIT_TEST_SUITE_END();
private:
@@ -1317,6 +1325,152 @@ void Chart2ImportTest::testTdf111173()
CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart1Doc.is() );
}
+void Chart2ImportTest::testTdf115107()
+{
+ load("/chart2/qa/extras/data/pptx/", "tdf115107.pptx");
+
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+ CPPUNIT_ASSERT(xDataSeries.is());
+ float nFontSize;
+ sal_Int64 nFontColor;
+ sal_Int32 nCharUnderline;
+ uno::Reference<beans::XPropertySet> xPropertySet;
+ uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields;
+
+ // 1
+ xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aFields.getLength());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[0]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("90.0 = "), aFields[0]->getString());
+ aFields[0]->getPropertyValue("CharHeight") >>= nFontSize;
+ aFields[0]->getPropertyValue("CharColor") >>= nFontColor;
+ CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xed7d31), nFontColor);
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[1]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("90"), aFields[1]->getString());
+
+ // 2
+ xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(8), aFields.getLength());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[0]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("Text"), aFields[0]->getString());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString(" : "), aFields[1]->getString());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CATEGORYNAME, aFields[2]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("B"), aFields[2]->getString());
+ aFields[2]->getPropertyValue("CharHeight") >>= nFontSize;
+ aFields[2]->getPropertyValue("CharColor") >>= nFontColor;
+ CPPUNIT_ASSERT_EQUAL(static_cast<float>(16), nFontSize);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xed7d31), nFontColor);
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, aFields[3]->getFieldType());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[4]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("Multi"), aFields[4]->getString());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[5]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("line"), aFields[5]->getString());
+ aFields[5]->getPropertyValue("CharHeight") >>= nFontSize;
+ aFields[5]->getPropertyValue("CharColor") >>= nFontColor;
+ CPPUNIT_ASSERT_EQUAL(static_cast<float>(13), nFontSize);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xbf9000), nFontColor);
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, aFields[6]->getFieldType());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[7]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("Abc"), aFields[7]->getString());
+ aFields[7]->getPropertyValue("CharHeight") >>= nFontSize;
+ aFields[7]->getPropertyValue("CharColor") >>= nFontColor;
+ aFields[7]->getPropertyValue("CharUnderline") >>= nCharUnderline;
+ CPPUNIT_ASSERT_EQUAL(static_cast<float>(12), nFontSize);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xa9d18e), nFontColor);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nCharUnderline);
+
+ // 3
+ xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aFields.getLength());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[0]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("DATA"), aFields[0]->getString());
+
+ // 4
+ xPropertySet.set(xDataSeries->getDataPointByIndex(3), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aFields.getLength());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLREF, aFields[0]->getFieldType());
+ //CPPUNIT_ASSERT_EQUAL(OUString("70"), aFields[0]->getString()); TODO: Not implemented yet
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString(" <CELLREF"), aFields[1]->getString());
+}
+
+void Chart2ImportTest::testTdf115107_2()
+{
+ load("/chart2/qa/extras/data/pptx/", "tdf115107-2.pptx");
+
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+ CPPUNIT_ASSERT(xDataSeries.is());
+ float nFontSize;
+ sal_Int64 nFontColor;
+ uno::Reference<beans::XPropertySet> xPropertySet;
+ uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields;
+
+ // First series
+ xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), aFields.getLength());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[0]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("4.3"), aFields[0]->getString());
+ aFields[0]->getPropertyValue("CharHeight") >>= nFontSize;
+ aFields[0]->getPropertyValue("CharColor") >>= nFontColor;
+ CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xc00000), nFontColor);
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[2]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("Bars"), aFields[2]->getString());
+
+ // Second series
+ xDataSeries = uno::Reference<chart2::XDataSeries>(getDataSeriesFromDoc(xChartDoc, 0, 1));
+ CPPUNIT_ASSERT(xDataSeries.is());
+
+ xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), aFields.getLength());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[0]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("2"), aFields[0]->getString());
+ aFields[0]->getPropertyValue("CharHeight") >>= nFontSize;
+ aFields[0]->getPropertyValue("CharColor") >>= nFontColor;
+ CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xffd966), nFontColor);
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString());
+
+ CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[2]->getFieldType());
+ CPPUNIT_ASSERT_EQUAL(OUString("Line"), aFields[2]->getString());
+
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/pptx/tdf115107-2.pptx b/chart2/qa/extras/data/pptx/tdf115107-2.pptx
new file mode 100644
index 000000000000..629056ecc87a
--- /dev/null
+++ b/chart2/qa/extras/data/pptx/tdf115107-2.pptx
Binary files differ
diff --git a/chart2/qa/extras/data/pptx/tdf115107.pptx b/chart2/qa/extras/data/pptx/tdf115107.pptx
new file mode 100644
index 000000000000..2ec5c2cd223b
--- /dev/null
+++ b/chart2/qa/extras/data/pptx/tdf115107.pptx
Binary files differ