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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Mon Apr 12 11:40:43 UTC 2021


 chart2/qa/extras/chart2import.cxx                |   35 +++++++++++++++++++++++
 chart2/qa/extras/data/xlsx/tdf140489.xlsx        |binary
 oox/source/drawingml/chart/plotareaconverter.cxx |    8 +++--
 3 files changed, 41 insertions(+), 2 deletions(-)

New commits:
commit be82f6313f298c13a2f040b218c6f2a33705ff8c
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Apr 8 15:08:38 2021 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon Apr 12 13:39:57 2021 +0200

    tdf#140489 fix chart display in xlsx
    
    Commit 1147383:
    tdf#114181 XLSX combined chart: fix swapped primary and secondary axes etc.
    
    introduced regression by applying axis swaping not only
    for combined charts.
    
    Change-Id: I764399579ff922ddd495540fdd2a39675f2a8da5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113836
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 93596eebc2a0..3a8b77f48cdd 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -119,6 +119,7 @@ public:
     void testAxisTitleRotationXLSX();
     void testAxisTitlePositionDOCX();
     void testCombinedChartAttachedAxisXLSX();
+    void testTdf140489MultiSeriesChartAxisXLSX();
 
     void testTdf90510(); // Pie chart label placement settings(XLS)
     void testTdf109858(); // Pie chart label placement settings(XLSX)
@@ -243,6 +244,7 @@ public:
     CPPUNIT_TEST(testAxisTitleRotationXLSX);
     CPPUNIT_TEST(testAxisTitlePositionDOCX);
     CPPUNIT_TEST(testCombinedChartAttachedAxisXLSX);
+    CPPUNIT_TEST(testTdf140489MultiSeriesChartAxisXLSX);
     CPPUNIT_TEST(testTdf90510);
     CPPUNIT_TEST(testTdf109858);
     CPPUNIT_TEST(testTdf130105);
@@ -1759,6 +1761,39 @@ void Chart2ImportTest::testCombinedChartAttachedAxisXLSX()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
 }
 
+void Chart2ImportTest::testTdf140489MultiSeriesChartAxisXLSX()
+{
+    load(u"/chart2/qa/extras/data/xlsx/", "tdf140489.xlsx");
+    Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+    // First series
+    Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xChartDoc, 0);
+    CPPUNIT_ASSERT(xSeries.is());
+
+    Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
+    sal_Int32 nAxisIndex = -1;
+    uno::Any aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
+    CPPUNIT_ASSERT(aAny >>= nAxisIndex);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
+
+    // Second series
+    xSeries = getDataSeriesFromDoc(xChartDoc, 0, 1);
+    CPPUNIT_ASSERT(xSeries.is());
+
+    xPropSet.set(xSeries, uno::UNO_QUERY_THROW);
+    aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
+    CPPUNIT_ASSERT(aAny >>= nAxisIndex);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
+
+    // Third series
+    xSeries = getDataSeriesFromDoc(xChartDoc, 0, 2);
+    CPPUNIT_ASSERT(xSeries.is());
+
+    xPropSet.set(xSeries, uno::UNO_QUERY_THROW);
+    aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
+    CPPUNIT_ASSERT(aAny >>= nAxisIndex);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nAxisIndex);
+}
+
 void Chart2ImportTest::testInternalDataProvider() {
     uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromImpress(u"/chart2/qa/extras/data/odp/", "chart.odp"), uno::UNO_QUERY_THROW);
     const uno::Reference< chart2::data::XDataProvider >& rxDataProvider = xChartDoc->getDataProvider();
diff --git a/chart2/qa/extras/data/xlsx/tdf140489.xlsx b/chart2/qa/extras/data/xlsx/tdf140489.xlsx
new file mode 100644
index 000000000000..bd24f40be7b5
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/tdf140489.xlsx differ
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
index 80ea37c57d30..9a0f9d337c8a 100644
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
@@ -420,9 +420,13 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel )
     // varying point colors only for single series in single chart type
     bool bSupportsVaryColorsByPoint = mrModel.maTypeGroups.size() == 1;
 
+    bool bIsCombinedChart = mrModel.maTypeGroups.size() == 2 &&
+        mrModel.maTypeGroups[0]->mnTypeId != mrModel.maTypeGroups[1]->mnTypeId;
+
     // convert all axes sets, and check which axis is attached to the first maTypeGroups
-    sal_Int32 nStartAxesSetIdx = (rValAxisIds.size() > 1 && aAxesSets.size() > 0 && aAxesSets[0]->maAxes.count( API_Y_AXIS )
-            && aAxesSets[0]->maAxes[ API_Y_AXIS ]->mnAxisId != rValAxisIds[0] ) ? 1 : 0;
+    sal_Int32 nStartAxesSetIdx = bIsCombinedChart ? ((rValAxisIds.size() > 1 && aAxesSets.size() > 0 && aAxesSets[0]->maAxes.count( API_Y_AXIS )
+            && aAxesSets[0]->maAxes[ API_Y_AXIS ]->mnAxisId != rValAxisIds[0] ) ? 1 : 0)
+            : 0;
     sal_Int32 nAxesSetIdx = nStartAxesSetIdx;
 
     bool bUseFixedInnerSize = false;


More information about the Libreoffice-commits mailing list