summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2018-02-12 20:39:14 +0100
committerJan Holesovsky <kendy@collabora.com>2018-07-20 12:10:40 +0200
commit4807f573336dddfecd9b44b515aefa39ab26aa23 (patch)
tree9be0493b5fb2bc9f13ffd153b3aeda7617c658e3 /chart2
parent507e891c4ee889a6218fbf56ea535d0a8f3901ce (diff)
tdf#114821 import/export/place complex data labels in charts
Change-Id: Ia44abcebb4febcabb1704aef85e396730ac2cd6f Reviewed-on: https://gerrit.libreoffice.org/57530 Tested-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/inc/unonames.hxx1
-rwxr-xr-x[-rw-r--r--]chart2/qa/extras/chart2export.cxx159
-rw-r--r--chart2/qa/extras/chart2import.cxx153
-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
-rw-r--r--chart2/source/chartcore.component1
-rw-r--r--chart2/source/model/main/DataPointProperties.cxx10
-rw-r--r--chart2/source/model/main/DataPointProperties.hxx3
-rw-r--r--chart2/source/model/main/FormattedString.cxx40
-rw-r--r--chart2/source/model/main/FormattedString.hxx16
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx126
-rw-r--r--chart2/source/view/inc/AbstractShapeFactory.hxx7
-rw-r--r--chart2/source/view/inc/OpenglShapeFactory.hxx7
-rw-r--r--chart2/source/view/inc/ShapeFactory.hxx7
-rw-r--r--chart2/source/view/inc/VSeriesPlotter.hxx2
-rw-r--r--chart2/source/view/main/OpenglShapeFactory.cxx12
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx94
17 files changed, 620 insertions, 18 deletions
diff --git a/chart2/inc/unonames.hxx b/chart2/inc/unonames.hxx
index 867a155e14aa..44c3bf67d3cb 100644
--- a/chart2/inc/unonames.hxx
+++ b/chart2/inc/unonames.hxx
@@ -29,6 +29,7 @@
#define CHART_UNONAME_LABEL_BORDER_DASH "LabelBorderDash"
#define CHART_UNONAME_LABEL_BORDER_DASHNAME "LabelBorderDashName"
#define CHART_UNONAME_LABEL_BORDER_TRANS "LabelBorderTransparency"
+#define CHART_UNONAME_CUSTOM_LABEL_FIELDS "CustomLabelFields"
#endif
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 9b9e75c868c2..f7427b76e9b1 100644..100755
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -13,6 +13,8 @@
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelField.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelFieldType.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
@@ -103,6 +105,8 @@ public:
void testAxisCrossBetweenXSLX();
void testNumberFormatExportPPTX();
void testTdf116163();
+ void testCustomDataLabel();
+ void testCustomDataLabelMultipleSeries();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(testErrorBarXLSX);
@@ -170,6 +174,8 @@ public:
CPPUNIT_TEST(testAxisCrossBetweenXSLX);
CPPUNIT_TEST(testNumberFormatExportPPTX);
CPPUNIT_TEST(testTdf116163);
+ CPPUNIT_TEST(testCustomDataLabel);
+ CPPUNIT_TEST(testCustomDataLabelMultipleSeries);
CPPUNIT_TEST_SUITE_END();
protected:
@@ -1584,6 +1590,159 @@ void Chart2ExportTest::testTdf116163()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", "-5400000");
}
+void Chart2ExportTest::testCustomDataLabel()
+{
+ load("/chart2/qa/extras/data/pptx/", "tdf115107.pptx");
+ xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ 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());
+ CPPUNIT_ASSERT_EQUAL(OUString("{0C576297-5A9F-4B4E-A675-B6BA406B7D87}"), aFields[1]->getGuid());
+
+ // 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());
+ CPPUNIT_ASSERT_EQUAL(OUString("{0CCAAACD-B393-42CE-8DBD-82F9F9ADC852}"), aFields[2]->getGuid());
+ 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());
+ CPPUNIT_ASSERT_EQUAL(OUString("{C8F3EB90-8960-4F9A-A3AD-B4FAC4FE4566}"), aFields[0]->getGuid());
+
+ // 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 Chart2ExportTest::testCustomDataLabelMultipleSeries()
+{
+ load("/chart2/qa/extras/data/pptx/", "tdf115107-2.pptx");
+ xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ 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(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 8a67b4e4349b..1f73eea90977 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>
@@ -105,6 +107,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);
@@ -165,6 +170,9 @@ public:
CPPUNIT_TEST(testInternalDataProvider);
+ CPPUNIT_TEST(testTdf115107);
+ CPPUNIT_TEST(testTdf115107_2);
+
CPPUNIT_TEST_SUITE_END();
private:
@@ -1414,6 +1422,151 @@ void Chart2ImportTest::testTdf116163()
CPPUNIT_ASSERT_EQUAL(OUString("Dddd..."), xLabel3->getString());
}
+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
diff --git a/chart2/source/chartcore.component b/chart2/source/chartcore.component
index f7a1783eda68..45c87f93d633 100644
--- a/chart2/source/chartcore.component
+++ b/chart2/source/chartcore.component
@@ -158,6 +158,7 @@
constructor="com_sun_star_comp_chart_FormattedString_get_implementation">
<service name="com.sun.star.beans.PropertySet"/>
<service name="com.sun.star.chart2.FormattedString"/>
+ <service name="com.sun.star.chart2.DataPointCustomLabelField"/>
</implementation>
<implementation name="com.sun.star.comp.chart.LineChartType"
constructor="com_sun_star_comp_chart_LineChartType_get_implementation">
diff --git a/chart2/source/model/main/DataPointProperties.cxx b/chart2/source/model/main/DataPointProperties.cxx
index 66e0b88d1f5a..7c70c4b3a1fd 100644
--- a/chart2/source/model/main/DataPointProperties.cxx
+++ b/chart2/source/model/main/DataPointProperties.cxx
@@ -30,7 +30,7 @@
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/RectanglePoint.hpp>
-
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
@@ -406,6 +406,11 @@ void DataPointProperties::AddPropertiesToVector(
cppu::UnoType<sal_Int16>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_CUSTOM_LABEL_FIELDS,
+ PROP_DATAPOINT_CUSTOM_LABEL_FIELDS,
+ cppu::UnoType<uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>>>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
}
void DataPointProperties::AddDefaultsToMap(
@@ -486,6 +491,9 @@ void DataPointProperties::AddDefaultsToMap(
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH, drawing::LineDash());
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH_NAME);
PropertyHelper::setPropertyValueDefault<sal_Int16>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_TRANS, 0);
+
+ uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields(0);
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_CUSTOM_LABEL_FIELDS, aFields);
}
} // namespace chart
diff --git a/chart2/source/model/main/DataPointProperties.hxx b/chart2/source/model/main/DataPointProperties.hxx
index 3daf838e5da5..6490b5c8cfe5 100644
--- a/chart2/source/model/main/DataPointProperties.hxx
+++ b/chart2/source/model/main/DataPointProperties.hxx
@@ -80,7 +80,8 @@ namespace DataPointProperties
PROP_DATAPOINT_LABEL_BORDER_WIDTH,
PROP_DATAPOINT_LABEL_BORDER_DASH,
PROP_DATAPOINT_LABEL_BORDER_DASH_NAME,
- PROP_DATAPOINT_LABEL_BORDER_TRANS
+ PROP_DATAPOINT_LABEL_BORDER_TRANS,
+ PROP_DATAPOINT_CUSTOM_LABEL_FIELDS
// additionally some properites from ::chart::LineProperties
};
diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx
index 4f26acc95e3f..2dfcca2d35c5 100644
--- a/chart2/source/model/main/FormattedString.cxx
+++ b/chart2/source/model/main/FormattedString.cxx
@@ -95,6 +95,8 @@ namespace chart
FormattedString::FormattedString() :
::property::OPropertySet( m_aMutex ),
m_aString(),
+ m_aType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT),
+ m_aGuid(),
m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
{}
@@ -103,6 +105,8 @@ FormattedString::FormattedString( const FormattedString & rOther ) :
impl::FormattedString_Base(),
::property::OPropertySet( rOther, m_aMutex ),
m_aString( rOther.m_aString ),
+ m_aType(rOther.m_aType),
+ m_aGuid(rOther.m_aGuid),
m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
{}
@@ -133,6 +137,41 @@ void SAL_CALL FormattedString::setString( const OUString& String )
}
+// ____ XDataPointCustomLabelField ____
+css::chart2::DataPointCustomLabelFieldType SAL_CALL FormattedString::getFieldType()
+{
+ MutexGuard aGuard(GetMutex());
+ return m_aType;
+}
+
+void SAL_CALL
+FormattedString::setFieldType(const css::chart2::DataPointCustomLabelFieldType Type)
+{
+ {
+ MutexGuard aGuard(GetMutex());
+ m_aType = Type;
+ }
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+}
+
+OUString SAL_CALL FormattedString::getGuid()
+{
+ MutexGuard aGuard( GetMutex());
+ return m_aGuid;
+}
+
+void SAL_CALL FormattedString::setGuid( const OUString& guid )
+{
+ {
+ MutexGuard aGuard( GetMutex());
+ m_aGuid= guid;
+ }
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+
+}
+
// ____ XModifyBroadcaster ____
void SAL_CALL FormattedString::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
@@ -226,6 +265,7 @@ sal_Bool SAL_CALL FormattedString::supportsService( const OUString& rServiceName
css::uno::Sequence< OUString > SAL_CALL FormattedString::getSupportedServiceNames()
{
return {
+ "com.sun.star.chart2.DataPointCustomLabelField",
"com.sun.star.chart2.FormattedString",
"com.sun.star.beans.PropertySet" };
}
diff --git a/chart2/source/model/main/FormattedString.hxx b/chart2/source/model/main/FormattedString.hxx
index 16c73372ebcc..a74042ca0b09 100644
--- a/chart2/source/model/main/FormattedString.hxx
+++ b/chart2/source/model/main/FormattedString.hxx
@@ -26,6 +26,8 @@
#include <ModifyListenerHelper.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/chart2/XFormattedString2.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelFieldType.hpp>
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -35,7 +37,7 @@ namespace chart
namespace impl
{
typedef ::cppu::WeakImplHelper<
- css::chart2::XFormattedString2,
+ css::chart2::XDataPointCustomLabelField, // inherits from XFormattedString2
css::lang::XServiceInfo,
css::util::XCloneable,
css::util::XModifyBroadcaster,
@@ -82,6 +84,12 @@ private:
virtual OUString SAL_CALL getString() override;
virtual void SAL_CALL setString( const OUString& String ) override;
+ // ____ XDataPointCustomLabelField ____
+ virtual css::chart2::DataPointCustomLabelFieldType SAL_CALL getFieldType() override;
+ virtual void SAL_CALL setFieldType( const css::chart2::DataPointCustomLabelFieldType FieldType ) override;
+ virtual OUString SAL_CALL getGuid() override;
+ void SAL_CALL setGuid( const OUString& guid ) override;
+
// ____ OPropertySet ____
virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
@@ -115,8 +123,14 @@ private:
void fireModifyEvent();
+private:
+ // ____ XFormattedString ____
OUString m_aString;
+ // ____ XDataPointCustomLabelField ____
+ css::chart2::DataPointCustomLabelFieldType m_aType;
+ OUString m_aGuid;
+
css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
};
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index af1544b22815..6073aa126432 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -56,6 +56,7 @@
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart/TimeUnit.hpp>
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
@@ -413,9 +414,21 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
, sal_Int32 nTextWidth )
{
uno::Reference< drawing::XShape > xTextShape;
+ Sequence<uno::Reference<XDataPointCustomLabelField>> aCustomLabels;
try
{
+ const uno::Reference< css::beans::XPropertySet >& xPropertySet(
+ rDataSeries.getPropertiesOfPoint( nPointIndex ) );
+ if( xPropertySet.is() )
+ {
+ uno::Any aAny = xPropertySet->getPropertyValue( CHART_UNONAME_CUSTOM_LABEL_FIELDS );
+ if( aAny.hasValue() )
+ {
+ aAny >>= aCustomLabels;
+ }
+ }
+
awt::Point aScreenPosition2D(rScreenPosition2D);
if(eAlignment==LABEL_ALIGN_LEFT)
aScreenPosition2D.X -= nOffset;
@@ -495,26 +508,75 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
}
sal_Int32 nLineCountForSymbolsize = 0;
- Sequence< OUString > aTextList(3);
+ sal_uInt32 nTextListLength = 3;
+ sal_uInt32 nCustomLabelsCount = aCustomLabels.getLength();
+ bool bUseCustomLabel = false;
+ Sequence< OUString > aTextList( nTextListLength );
+
+ bUseCustomLabel = nCustomLabelsCount > 0;
+ if( bUseCustomLabel )
{
- if(pLabel->ShowCategoryName)
+ nTextListLength = ( nCustomLabelsCount > 3 ) ? nCustomLabelsCount : 3;
+ aSeparator = "";
+ aTextList = Sequence< OUString >( nTextListLength );
+ for( sal_uInt32 i = 0; i < nCustomLabelsCount; ++i )
{
- if( m_pExplicitCategoriesProvider )
+ switch( aCustomLabels[i]->getFieldType() )
{
- Sequence< OUString > aCategories( m_pExplicitCategoriesProvider->getSimpleCategories() );
- if( nPointIndex >= 0 && nPointIndex < aCategories.getLength() )
+ case DataPointCustomLabelFieldType_VALUE:
+ {
+ aTextList[i] = getLabelTextForValue( rDataSeries, nPointIndex, fValue, false );
+ break;
+ }
+ case DataPointCustomLabelFieldType_CATEGORYNAME:
+ {
+ aTextList[i] = getCategoryName( nPointIndex );
+ break;
+ }
+ case DataPointCustomLabelFieldType_SERIESNAME:
{
- aTextList[0] = aCategories[nPointIndex];
+ OUString aRole;
+ if ( m_xChartTypeModel.is() )
+ aRole = m_xChartTypeModel->getRoleOfSequenceForSeriesLabel();
+ uno::Reference< XDataSeries > xSeries( rDataSeries.getModel() );
+ aTextList[i] = DataSeriesHelper::getDataSeriesLabel( xSeries, aRole );
+ break;
}
+ case DataPointCustomLabelFieldType_CELLREF:
+ {
+ // TODO: for now doesn't show placeholder
+ aTextList[i] = OUString();
+ break;
+ }
+ case DataPointCustomLabelFieldType_TEXT:
+ {
+ aTextList[i] = aCustomLabels[i]->getString();
+ break;
+ }
+ case DataPointCustomLabelFieldType_NEWLINE:
+ {
+ aTextList[i] = "\n";
+ break;
+ }
+ default:
+ break;
}
+ aCustomLabels[i]->setString( aTextList[i] );
+ }
+ }
+ else
+ {
+ if( pLabel->ShowCategoryName )
+ {
+ aTextList[0] = getCategoryName( nPointIndex );
}
- if(pLabel->ShowNumber)
+ if( pLabel->ShowNumber )
{
aTextList[1] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, false);
}
- if(pLabel->ShowNumberInPercent)
+ if( pLabel->ShowNumberInPercent )
{
if(fSumValue==0.0)
fSumValue=1.0;
@@ -524,13 +586,13 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
aTextList[2] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, true);
}
+ }
- for( sal_Int32 nN = 0; nN < 3; ++nN)
+ for( sal_Int32 nN = 0; nN < aTextList.getLength(); ++nN )
+ {
+ if( !aTextList[nN].isEmpty() )
{
- if( !aTextList[nN].isEmpty() )
- {
- ++nLineCountForSymbolsize;
- }
+ ++nLineCountForSymbolsize;
}
}
@@ -549,7 +611,28 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
// a multi-line label.
bool bMultiLineLabel = ( aSeparator == "\n" );
- if( bMultiLineLabel )
+ if( bUseCustomLabel )
+ {
+ Sequence< uno::Reference< XFormattedString > > aFormattedLabels( aCustomLabels.getLength() );
+ for( int i = 0; i < aFormattedLabels.getLength(); i++ )
+ {
+ uno::Reference< XFormattedString > xString( aCustomLabels[i], uno::UNO_QUERY );
+ aFormattedLabels[i] = xString;
+ }
+
+ // center the text
+ sal_uInt32 nProperties = pPropNames->getLength();
+ pPropNames->realloc( nProperties + 1 );
+ pPropValues->realloc( nProperties + 1 );
+ (*pPropNames)[ nProperties ] = UNO_NAME_EDIT_PARA_ADJUST;
+ (*pPropValues)[ nProperties ] <<= style::ParagraphAdjust_CENTER;
+
+ // create text shape
+ xTextShape = AbstractShapeFactory::getOrCreateShapeFactory( m_xShapeFactory )->
+ createText( xTarget_, aFormattedLabels, *pPropNames, *pPropValues,
+ AbstractShapeFactory::makeTransformation( aScreenPosition2D ) );
+ }
+ else if( bMultiLineLabel )
{
// prepare properties for each paragraph
// we want to have the value and percent value centered respect
@@ -575,7 +658,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
{
// join text list elements
OUStringBuffer aText;
- for( sal_Int32 nN = 0; nN < 3; ++nN)
+ for( sal_uInt32 nN = 0; nN < nTextListLength; ++nN)
{
if( !aTextList[nN].isEmpty() )
{
@@ -2050,6 +2133,19 @@ VDataSeries* VSeriesPlotter::getFirstSeries() const
return nullptr;
}
+OUString VSeriesPlotter::getCategoryName( sal_Int32 nPointIndex ) const
+{
+ if (m_pExplicitCategoriesProvider)
+ {
+ Sequence< OUString > aCategories(m_pExplicitCategoriesProvider->getSimpleCategories());
+ if (nPointIndex >= 0 && nPointIndex < aCategories.getLength())
+ {
+ return aCategories[nPointIndex];
+ }
+ }
+ return OUString();
+}
+
uno::Sequence< OUString > VSeriesPlotter::getSeriesNames() const
{
std::vector<OUString> aRetVector;
diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx
index 26512214341d..e281e6291ebf 100644
--- a/chart2/source/view/inc/AbstractShapeFactory.hxx
+++ b/chart2/source/view/inc/AbstractShapeFactory.hxx
@@ -200,6 +200,13 @@ public:
, const css::uno::Any& rATransformation ) = 0;
virtual css::uno::Reference< css::drawing::XShape >
+ createText(const css::uno::Reference< css::drawing::XShapes >& xTarget
+ , css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString
+ , const tNameSequence& rPropNames
+ , const tAnySequence& rPropValues
+ , const css::uno::Any& rATransformation) = 0;
+
+ virtual css::uno::Reference< css::drawing::XShape >
createText( const css::uno::Reference< css::drawing::XShapes >& xTarget2D,
const css::awt::Size& rSize,
const css::awt::Point& rPosition,
diff --git a/chart2/source/view/inc/OpenglShapeFactory.hxx b/chart2/source/view/inc/OpenglShapeFactory.hxx
index 01b2223cf59c..7963068ce79e 100644
--- a/chart2/source/view/inc/OpenglShapeFactory.hxx
+++ b/chart2/source/view/inc/OpenglShapeFactory.hxx
@@ -151,6 +151,13 @@ public:
, const css::uno::Any& rATransformation ) override;
virtual css::uno::Reference< css::drawing::XShape >
+ createText( const css::uno::Reference< css::drawing::XShapes >& xTarget
+ , css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString
+ , const tNameSequence& rPropNames
+ , const tAnySequence& rPropValues
+ , const css::uno::Any& rATransformation ) override;
+
+ virtual css::uno::Reference< css::drawing::XShape >
createText( const css::uno::Reference< css::drawing::XShapes >& xTarget2D,
const css::awt::Size& rSize,
const css::awt::Point& rPosition,
diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx
index 02a75d3a0764..ec1080732142 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -189,6 +189,13 @@ public:
, const css::uno::Any& rATransformation ) override;
virtual css::uno::Reference< css::drawing::XShape >
+ createText(const css::uno::Reference< css::drawing::XShapes >& xTarget
+ , css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString
+ , const tNameSequence& rPropNames
+ , const tAnySequence& rPropValues
+ , const css::uno::Any& rATransformation) override;
+
+ virtual css::uno::Reference< css::drawing::XShape >
createText( const css::uno::Reference< css::drawing::XShapes >& xTarget2D,
const css::awt::Size& rSize,
const css::awt::Point& rPosition,
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
index 54f3f7733d63..d8b1cf05eb2b 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -389,6 +389,8 @@ protected:
VDataSeries* getFirstSeries() const;
+ OUString getCategoryName( sal_Int32 nPointIndex ) const;
+
protected:
PlottingPositionHelper* m_pMainPosHelper;
diff --git a/chart2/source/view/main/OpenglShapeFactory.cxx b/chart2/source/view/main/OpenglShapeFactory.cxx
index 9cb3318f7fa2..e6c4980b8017 100644
--- a/chart2/source/view/main/OpenglShapeFactory.cxx
+++ b/chart2/source/view/main/OpenglShapeFactory.cxx
@@ -408,6 +408,18 @@ uno::Reference< drawing::XShape >
}
uno::Reference< drawing::XShape >
+ OpenglShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget
+ , uno::Sequence< uno::Reference< chart2::XFormattedString > >& rFormattedString
+ , const tNameSequence& rPropNames
+ , const tAnySequence& rPropValues
+ , const uno::Any& rATransformation )
+{
+ dummy::DummyText* pText = new dummy::DummyText( rFormattedString[0]->getString(), rPropNames, rPropValues,
+ rATransformation, xTarget, 0 );
+ return pText;
+}
+
+uno::Reference< drawing::XShape >
OpenglShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget,
const awt::Size& , const awt::Point& rPos,
uno::Sequence< uno::Reference< chart2::XFormattedString > >& rFormattedString,
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 53a10b922276..2f75aef5c1cf 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -2266,6 +2266,100 @@ uno::Reference< drawing::XShape >
}
uno::Reference< drawing::XShape >
+ ShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget
+ , uno::Sequence< uno::Reference< chart2::XFormattedString > >& xFormattedString
+ , const tNameSequence& rPropNames
+ , const tAnySequence& rPropValues
+ , const uno::Any& rATransformation )
+{
+ if( !xTarget.is() )
+ return nullptr;
+
+ if( !xFormattedString.hasElements() )
+ return nullptr;
+
+ sal_Int32 nNumberOfParagraphs = xFormattedString.getLength();
+
+ bool bNotEmpty = false;
+ for( sal_Int32 nN = 0; nN < nNumberOfParagraphs; ++nN )
+ {
+ if( !xFormattedString[nN]->getString().isEmpty() )
+ {
+ bNotEmpty = true;
+ break;
+ }
+ }
+ if( !bNotEmpty )
+ return nullptr;
+
+ //create shape and add to page
+ uno::Reference< drawing::XShape > xShape(
+ m_xShapeFactory->createInstance(
+ "com.sun.star.drawing.TextShape" ), uno::UNO_QUERY );
+ xTarget->add(xShape);
+
+ //set paragraph properties
+ bNotEmpty = false;
+ Reference< text::XText > xText( xShape, uno::UNO_QUERY );
+ if( xText.is() )
+ {
+ // the first cursor is used for appending the next paragraph,
+ // after a new string has been inserted the cursor is moved at the end
+ // of the inserted string
+ // the second cursor is used for selecting the paragraph and apply the
+ // passed text properties
+ Reference< text::XTextCursor > xInsertCursor = xText->createTextCursor();
+ Reference< text::XTextCursor > xSelectionCursor = xText->createTextCursor();
+ if( xInsertCursor.is() && xSelectionCursor.is() )
+ {
+ uno::Reference< beans::XPropertySet > xSelectionProp( xSelectionCursor, uno::UNO_QUERY );
+ if( xSelectionProp.is() )
+ {
+ for( sal_Int32 nN = 0; nN < nNumberOfParagraphs; ++nN )
+ {
+ if( !xFormattedString[nN]->getString().isEmpty() )
+ {
+ xInsertCursor->gotoEnd( false );
+ xSelectionCursor->gotoEnd( false );
+ xText->insertString( xInsertCursor, xFormattedString[nN]->getString(), false );
+ bNotEmpty = true;
+ xSelectionCursor->gotoEnd( true ); // select current paragraph
+ uno::Reference< beans::XPropertySet > xStringProperties( xFormattedString[nN], uno::UNO_QUERY );
+ PropertyMapper::setMappedProperties( xSelectionProp, xStringProperties,
+ PropertyMapper::getPropertyNameMapForTextShapeProperties() );
+ }
+ }
+ }
+ }
+ }
+
+ if( !bNotEmpty )
+ return nullptr;
+
+ uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ //set whole text shape properties
+ PropertyMapper::setMultiProperties( rPropNames, rPropValues, xProp );
+
+ if( rATransformation.hasValue() )
+ {
+ //set position matrix
+ //the matrix needs to be set at the end behind autogrow and such position influencing properties
+ try
+ {
+ xProp->setPropertyValue( "Transformation", rATransformation );
+ }
+ catch( const uno::Exception& e )
+ {
+ SAL_WARN("chart2", "Exception caught. " << e );
+ }
+ }
+ }
+ return xShape;
+}
+
+uno::Reference< drawing::XShape >
ShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget,
const awt::Size& rSize,
const awt::Point& rPos,