summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-02-13 08:40:55 +0100
committerLászló Németh <nemeth@numbertext.org>2019-02-13 10:06:29 +0100
commite32e5e61b509dcae0462419acfc556d445895840 (patch)
treecf979ed66cd9741832bfeb316662759526f4e7e8
parentbbab991c70e2a1867493d701168f49a0d0dcbd48 (diff)
tdf#123400 OOXML Chart: Export Data Label Separator
Export the data label separator XML tag and the separated character to OOXML. Change-Id: I9b3bcb588e42a42494107ebde70f4a72492cfac4 Reviewed-on: https://gerrit.libreoffice.org/67753 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--chart2/qa/extras/chart2export.cxx20
-rwxr-xr-xchart2/qa/extras/data/docx/testLabelSeparator.docxbin0 -> 25333 bytes
-rw-r--r--oox/source/export/chartexport.cxx11
3 files changed, 31 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index dc36c3ad3c29..b16e773ab776 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -117,6 +117,7 @@ public:
void testCustomDataLabel();
void testCustomDataLabelMultipleSeries();
void testNumberFormatExportPPTX();
+ void testLabelSeparatorExportDOCX();
void testChartTitlePropertiesColorFillPPTX();
void testChartTitlePropertiesGradientFillPPTX();
void testChartTitlePropertiesBitmapFillPPTX();
@@ -206,6 +207,7 @@ public:
CPPUNIT_TEST(testCustomDataLabel);
CPPUNIT_TEST(testCustomDataLabelMultipleSeries);
CPPUNIT_TEST(testNumberFormatExportPPTX);
+ CPPUNIT_TEST(testLabelSeparatorExportDOCX);
CPPUNIT_TEST(testChartTitlePropertiesColorFillPPTX);
CPPUNIT_TEST(testChartTitlePropertiesGradientFillPPTX);
CPPUNIT_TEST(testChartTitlePropertiesBitmapFillPPTX);
@@ -1909,6 +1911,24 @@ void Chart2ExportTest::testNumberFormatExportPPTX()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", "sourceLinked", "0");
}
+void Chart2ExportTest::testLabelSeparatorExportDOCX()
+{
+ load("/chart2/qa/extras/data/docx/", "testLabelSeparator.docx");
+
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // The text separator should be a new line
+ assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:separator", "\n");
+ // The text separator should be a comma
+ assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:dLbls/c:separator", ", ");
+ // The text separator should be a semicolon
+ assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:dLbls/c:separator", "; ");
+}
+
void Chart2ExportTest::testChartTitlePropertiesColorFillPPTX()
{
load("/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesColorFill.pptx");
diff --git a/chart2/qa/extras/data/docx/testLabelSeparator.docx b/chart2/qa/extras/data/docx/testLabelSeparator.docx
new file mode 100755
index 000000000000..452fdccc9403
--- /dev/null
+++ b/chart2/qa/extras/data/docx/testLabelSeparator.docx
Binary files differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 624d1922a35a..b1c437b53dfe 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3135,6 +3135,17 @@ void writeLabelProperties( const FSHelperPtr& pFS, ChartExport* pChartExport,
pFS->singleElement(FSNS(XML_c, XML_showCatName), XML_val, ToPsz10(aLabel.ShowCategoryName), FSEND);
pFS->singleElement(FSNS(XML_c, XML_showSerName), XML_val, ToPsz10(false), FSEND);
pFS->singleElement(FSNS(XML_c, XML_showPercent), XML_val, ToPsz10(aLabel.ShowNumberInPercent), FSEND);
+
+ // Export the text "separator" if exists
+ uno::Any aAny = xPropSet->getPropertyValue("LabelSeparator");
+ if( aAny.hasValue() )
+ {
+ OUString nLabelSeparator;
+ aAny >>= nLabelSeparator;
+ pFS->startElement( FSNS( XML_c, XML_separator ), FSEND );
+ pFS->writeEscaped( nLabelSeparator );
+ pFS->endElement( FSNS( XML_c, XML_separator ) );
+ }
}
}