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

Miklos Vajna vmiklos at collabora.co.uk
Mon Sep 15 03:40:15 PDT 2014


 chart2/qa/extras/chart2export.cxx                          |   16 +++++++++++++
 chart2/qa/extras/data/docx/clustered-bar-chart-labels.docx |binary
 include/oox/export/chartexport.hxx                         |    1 
 oox/source/export/chartexport.cxx                          |    6 ++++
 4 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit ba37fb02c298aa79fd0418b82d7b44930d047b8c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 15 12:12:12 2014 +0200

    Ensure we export correct label placement value for clustered bar charts
    
    This is similar to 7b8073906adca8dae24c04a23708a3f3d582218f (Ensure we
    export correct labal placement value for percent/stacked charts.,
    2014-08-07), in case a clustered bar chart has a top placement ("t" in
    OOXML), then MSO complains as well.
    
    Change-Id: Iffd991127784e0e732f6ae55de956a328a3a53e5

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 280d2fc..38bd92f 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -72,6 +72,7 @@ public:
     void testDataLabelBordersDOCX();
     void testDataLabel3DChartDOCX();
     void testDataLabelBarChartDOCX();
+    void testDataLabelClusteredBarChartDOCX();
     void testDataLabelRadarChartDOCX();
     void testDataLabelDoughnutChartDOCX();
     void testDataLabelAreaChartDOCX();
@@ -113,6 +114,7 @@ public:
     CPPUNIT_TEST(testDataLabelBordersDOCX);
     CPPUNIT_TEST(testDataLabel3DChartDOCX);
     CPPUNIT_TEST(testDataLabelBarChartDOCX);
+    CPPUNIT_TEST(testDataLabelClusteredBarChartDOCX);
     CPPUNIT_TEST(testDataLabelRadarChartDOCX);
     CPPUNIT_TEST(testDataLabelDoughnutChartDOCX);
     CPPUNIT_TEST(testDataLabelAreaChartDOCX);
@@ -845,6 +847,20 @@ void Chart2ExportTest::testDataLabelBarChartDOCX()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:dLbls/c:dLblPos", "val", "inBase");
 }
 
+void Chart2ExportTest::testDataLabelClusteredBarChartDOCX()
+{
+    load("/chart2/qa/extras/data/docx/", "clustered-bar-chart-labels.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);
+
+    // This was "t", should be one of the allowed values.
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl[2]/c:dLblPos", "val", "ctr");
+}
+
 void Chart2ExportTest::testDataLabelRadarChartDOCX()
 {
     load("/chart2/qa/extras/data/docx/", "radar-chart-labels.docx");
diff --git a/chart2/qa/extras/data/docx/clustered-bar-chart-labels.docx b/chart2/qa/extras/data/docx/clustered-bar-chart-labels.docx
new file mode 100644
index 0000000..3b9941c
Binary files /dev/null and b/chart2/qa/extras/data/docx/clustered-bar-chart-labels.docx differ
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index 8f86aa9..02ee8f1 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -102,6 +102,7 @@ private:
     bool                mbIs3DChart;
     bool                mbStacked;
     bool                mbPercent;
+    bool                mbClustered;
 
 private:
     sal_Int32 getChartType();
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 8fe0a87..4629005 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -446,6 +446,7 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< f
     , mbIs3DChart( false )
     , mbStacked(false)
     , mbPercent(false)
+    , mbClustered(false)
 {
 }
 
@@ -2670,7 +2671,7 @@ void ChartExport::exportDataLabels(
             aParam.mbExport = false;
         break;
         case chart::TYPEID_BAR:
-            if (mbStacked || mbPercent)
+            if (mbStacked || mbPercent || mbClustered)
             {
                 aParam.maAllowedValues.clear();
                 aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::CENTER);
@@ -2816,7 +2817,10 @@ void ChartExport::exportGrouping( bool isBar )
     else
     {
         if( isBar && !isDeep3dChart() )
+        {
             grouping = "clustered";
+            mbClustered = true;
+        }
         else
             grouping = "standard";
     }


More information about the Libreoffice-commits mailing list