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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Dec 1 08:30:03 UTC 2018


 chart2/qa/extras/chart2export.cxx         |   15 +++++++++++++++
 chart2/qa/extras/data/docx/tdf121744.docx |binary
 include/oox/export/chartexport.hxx        |    2 +-
 oox/source/export/chartexport.cxx         |   26 ++++++++++++++++++--------
 4 files changed, 34 insertions(+), 9 deletions(-)

New commits:
commit 21399c7378be020e5e43fc07575f46e87e2d607b
Author:     Jozsef Szakacs <zmx3 at citromail.hu>
AuthorDate: Wed Nov 28 09:13:03 2018 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Sat Dec 1 09:29:43 2018 +0100

    tdf#121744 XLSX Export Combinated Chart (Column and Line)
    
    Each of the Column and Line Chart creates it's own x and y Axes.
    So now the LineChart Exporter Method uses the same Axes as the BarChart.
    
    Thanks for the help:
    - Balazs Varga
    - Adam Kovacs
    
    Change-Id: Ie763cf831c2ce63ef204d1fdcbff634e7ca8fad5
    Reviewed-on: https://gerrit.libreoffice.org/64146
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index e34f81a96daa..7ed7e6afaee9 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -123,6 +123,7 @@ public:
     void testTdf116163();
     void testTdf119029();
     void testTdf108022();
+    void testTdf121744();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(testErrorBarXLSX);
@@ -208,6 +209,7 @@ public:
     CPPUNIT_TEST(testTdf116163);
     CPPUNIT_TEST(testTdf119029);
     CPPUNIT_TEST(testTdf108022);
+    CPPUNIT_TEST(testTdf121744);
     CPPUNIT_TEST_SUITE_END();
 
 protected:
@@ -1951,6 +1953,19 @@ void Chart2ExportTest::testTdf108022()
     CPPUNIT_ASSERT(xChartDoc2.is());
 }
 
+void Chart2ExportTest::testTdf121744()
+{
+    load("/chart2/qa/extras/data/docx/", "tdf121744.docx");
+    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    OUString XValueId = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val");
+    OUString YValueId = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[2]", "val");
+
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[1]", "val", XValueId );
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[2]", "val", YValueId );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/tdf121744.docx b/chart2/qa/extras/data/docx/tdf121744.docx
new file mode 100644
index 000000000000..b5ff10098c6a
Binary files /dev/null and b/chart2/qa/extras/data/docx/tdf121744.docx differ
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index b974fc4c1ac7..c5f9e6ebd188 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -200,7 +200,7 @@ private:
         sal_Int32 nAxisType,
         const char* sAxisPos,
         const AxisIdPair& rAxisIdPair );
-    void exportAxesId(bool bPrimaryAxes);
+    void exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes = false);
     void exportView3D();
     bool isDeep3dChart();
 
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 08b296f57cb6..ce3c6984ad40 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1662,7 +1662,7 @@ void ChartExport::exportLineChart( const Reference< chart2::XChartType >& xChart
                     FSEND );
         }
 
-        exportAxesId(bPrimaryAxes);
+        exportAxesId(bPrimaryAxes, true);
 
         pFS->endElement( FSNS( XML_c, nTypeId ) );
     }
@@ -3369,14 +3369,24 @@ void ChartExport::exportDataPoints(
     }
 }
 
-void ChartExport::exportAxesId(bool bPrimaryAxes)
+void ChartExport::exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes)
 {
-    sal_Int32 nAxisIdx = lcl_generateRandomValue();
-    sal_Int32 nAxisIdy = lcl_generateRandomValue();
-    AxesType eXAxis = bPrimaryAxes ? AXIS_PRIMARY_X : AXIS_SECONDARY_X;
-    AxesType eYAxis = bPrimaryAxes ? AXIS_PRIMARY_Y : AXIS_SECONDARY_Y;
-    maAxes.emplace_back( eXAxis, nAxisIdx, nAxisIdy );
-    maAxes.emplace_back( eYAxis, nAxisIdy, nAxisIdx );
+    sal_Int32 nAxisIdx, nAxisIdy;
+    // tdf#114181 keep axes of combined charts
+    if ( bCheckCombinedAxes && bPrimaryAxes && maAxes.size() == 2 )
+    {
+        nAxisIdx = maAxes[0].nAxisId;
+        nAxisIdy = maAxes[1].nAxisId;
+    }
+    else
+    {
+        nAxisIdx = lcl_generateRandomValue();
+        nAxisIdy = lcl_generateRandomValue();
+        AxesType eXAxis = bPrimaryAxes ? AXIS_PRIMARY_X : AXIS_SECONDARY_X;
+        AxesType eYAxis = bPrimaryAxes ? AXIS_PRIMARY_Y : AXIS_SECONDARY_Y;
+        maAxes.emplace_back( eXAxis, nAxisIdx, nAxisIdy );
+        maAxes.emplace_back( eYAxis, nAxisIdy, nAxisIdx );
+    }
     FSHelperPtr pFS = GetFS();
     pFS->singleElement( FSNS( XML_c, XML_axId ),
             XML_val, I32S( nAxisIdx ),


More information about the Libreoffice-commits mailing list