diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2018-02-19 18:18:20 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-02-28 20:16:55 +0100 |
commit | 235fcab47a8dc1e9b0e06a95a77a8c1d440aa619 (patch) | |
tree | d9a2b359bae473ebe57644d0312891b36f3d85e2 | |
parent | 1ad7f9d0c3cbcf9063b21bbc68f91f4f512e54d5 (diff) |
tdf#115859 Export number format for chart series
Change-Id: I65d30c6b92a530eadbd6fabe87fa8bd3416fee20
Reviewed-on: https://gerrit.libreoffice.org/50385
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 12 | ||||
-rw-r--r-- | chart2/qa/extras/data/pptx/tdf115859.pptx | bin | 0 -> 49120 bytes | |||
-rw-r--r-- | oox/source/export/chartexport.cxx | 18 |
3 files changed, 30 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 618a5b877af7..9f5efb140036 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -106,6 +106,7 @@ public: void testPieChartDataPointExplosionXLSX(); void testCustomDataLabel(); void testCustomDataLabelMultipleSeries(); + void testNumberFormatExportPPTX(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(testErrorBarXLSX); @@ -174,6 +175,7 @@ public: CPPUNIT_TEST(testPieChartDataPointExplosionXLSX); CPPUNIT_TEST(testCustomDataLabel); CPPUNIT_TEST(testCustomDataLabelMultipleSeries); + CPPUNIT_TEST(testNumberFormatExportPPTX); CPPUNIT_TEST_SUITE_END(); protected: @@ -1731,6 +1733,16 @@ void Chart2ExportTest::testCustomDataLabelMultipleSeries() } +void Chart2ExportTest::testNumberFormatExportPPTX() +{ + load("/chart2/qa/extras/data/pptx/", "tdf115859.pptx"); + xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", "formatCode", "#,##0.00,\\K"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", "sourceLinked", "0"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/pptx/tdf115859.pptx b/chart2/qa/extras/data/pptx/tdf115859.pptx Binary files differnew file mode 100644 index 000000000000..07943041bed8 --- /dev/null +++ b/chart2/qa/extras/data/pptx/tdf115859.pptx diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 19d2908edebe..81ed22c57996 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -3093,6 +3093,24 @@ void ChartExport::exportDataLabels( FSHelperPtr pFS = GetFS(); pFS->startElement(FSNS(XML_c, XML_dLbls), FSEND); + bool bLinkedNumFmt = true; + if (GetProperty(xPropSet, "LinkNumberFormatToSource")) + mAny >>= bLinkedNumFmt; + + if (GetProperty(xPropSet, "NumberFormat")) + { + sal_Int32 nKey = 0; + mAny >>= nKey; + + OUString aNumberFormatString = getNumberFormatCode(nKey); + OString sNumberFormatString = OUStringToOString(aNumberFormatString, RTL_TEXTENCODING_UTF8); + + pFS->singleElement(FSNS(XML_c, XML_numFmt), + XML_formatCode, sNumberFormatString.getStr(), + XML_sourceLinked, bLinkedNumFmt ? "1" : "0", + FSEND); + } + uno::Sequence<sal_Int32> aAttrLabelIndices; xPropSet->getPropertyValue("AttributedDataPoints") >>= aAttrLabelIndices; |