[Libreoffice-commits] core.git: chart2/qa oox/source

sushil_shinde sushil.shinde at synerzip.com
Tue Feb 11 15:24:25 PST 2014


 chart2/qa/extras/chart2export.cxx            |   10 ++++++++++
 chart2/qa/extras/data/docx/DisplayUnits.docx |binary
 oox/source/export/chartexport.cxx            |   25 +++++++++++++++++++++++++
 3 files changed, 35 insertions(+)

New commits:
commit 1d497297ec9bc2ed00bbc8f586a67c76eaa7013d
Author: sushil_shinde <sushil.shinde at synerzip.com>
Date:   Wed Jan 29 14:34:35 2014 +0530

    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 at googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index e164296..399c0bb 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 0000000..97092a3
Binary files /dev/null and b/chart2/qa/extras/data/docx/DisplayUnits.docx differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 1c82816..dbbeb07 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 ) );


More information about the Libreoffice-commits mailing list