summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsushil_shinde <sushil.shinde@synerzip.com>2014-01-29 14:34:35 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-02-11 23:24:00 +0000
commit1d497297ec9bc2ed00bbc8f586a67c76eaa7013d (patch)
treeff289db4cd77cabcccb4c957da3939938e520381
parent83055835b1425b0a9d2fe5dce2f4db2d7a61919d (diff)
fdo#74112 Write Chart Displayunits information back to XML.
During export access properties stored during import and write back those. Currently we just support basic chart display unit information such as builtinunit, there are more properties ex. custUnit, dispUnitsLbl, extLst. which are pending. Conflicts: chart2/qa/extras/chart2export.cxx Change-Id: I87e0a8322fc0b0c3df2b8053b7f29fffea611040 Reviewed-on: https://gerrit.libreoffice.org/7722 Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--chart2/qa/extras/chart2export.cxx10
-rw-r--r--chart2/qa/extras/data/docx/DisplayUnits.docxbin0 -> 18137 bytes
-rw-r--r--oox/source/export/chartexport.cxx25
3 files changed, 35 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index e1642962517a..399c0bbf9f8b 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -42,6 +42,7 @@ public:
void testAreaChartLoad();
void testUpDownBars();
void testDoughnutChart();
+ void testDisplayUnits();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(test);
@@ -56,6 +57,7 @@ public:
CPPUNIT_TEST(testAreaChartLoad);
CPPUNIT_TEST(testUpDownBars);
CPPUNIT_TEST(testDoughnutChart);
+ CPPUNIT_TEST(testDisplayUnits);
CPPUNIT_TEST_SUITE_END();
protected:
@@ -533,6 +535,14 @@ void Chart2ExportTest::testDoughnutChart()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart", "1");
}
+void Chart2ExportTest::testDisplayUnits()
+{
+ load("/chart2/qa/extras/data/docx/", "DisplayUnits.docx");
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:dispUnits/c:builtInUnit", "val", "billions");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/DisplayUnits.docx b/chart2/qa/extras/data/docx/DisplayUnits.docx
new file mode 100644
index 000000000000..97092a3ed64d
--- /dev/null
+++ b/chart2/qa/extras/data/docx/DisplayUnits.docx
Binary files differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 1c8281630241..dbbeb07bcb7c 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2389,6 +2389,31 @@ void ChartExport::_exportAxis(
FSEND );
}
+ sal_Bool bDisplayUnits = sal_False;
+ if(GetProperty( xAxisProp, "DisplayUnits" ) )
+ {
+ mAny >>= bDisplayUnits;
+ if(bDisplayUnits)
+ {
+ OUString aVal;
+ pFS->startElement( FSNS( XML_c, XML_dispUnits ),
+ FSEND );
+ if(GetProperty( xAxisProp, "BuiltInUnit" ))
+ {
+ mAny >>= aVal;
+ if(!aVal.isEmpty())
+ {
+ OString aBuiltInUnit = OUStringToOString(aVal, RTL_TEXTENCODING_UTF8);
+ pFS->singleElement( FSNS( XML_c, XML_builtInUnit ),
+ XML_val, aBuiltInUnit.getStr(),
+ FSEND );
+ }
+ }
+ pFS->singleElement(FSNS( XML_c, XML_dispUnitsLbl ),FSEND);
+ pFS->endElement( FSNS( XML_c, XML_dispUnits ) );
+
+ }
+ }
// TODO: text properties
pFS->endElement( FSNS( XML_c, nAxisType ) );