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

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 21 08:22:13 UTC 2020


 chart2/qa/extras/chart2import.cxx            |   17 +++++++++++++++++
 chart2/qa/extras/data/xlsx/tdf130657.xlsx    |binary
 oox/source/drawingml/chart/axisconverter.cxx |    4 +++-
 3 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 8163f4ad81487ae187d00d3ce86214e520cb8b69
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Fri Feb 14 14:06:04 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Feb 21 09:21:39 2020 +0100

    tdf#130657 OOXML chart import: fix charts without CrossBetween
    
    by using default values for ShiftedCategoryPosition.
    
    Regression from commit 111c260ab2883b7906f1a66e222dbf4dc3c58c4f
    (tdf#127777 OOXML chart export: fix "CrossBetween" for not imported charts)
    
    Change-Id: Idd48a8343e7d6609b487daf7182e9716f2f5e01f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88709
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 93be02e70160..4850f33ee76c 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -141,6 +141,7 @@ public:
     void testTdf128432();
     void testTdf128627();
     void testTdf128634();
+    void testTdf130657();
     void testDeletedDataLabel();
     void testDataPointInheritedColorDOCX();
     void testExternalStrRefsXLSX();
@@ -244,6 +245,7 @@ public:
     CPPUNIT_TEST(testTdf128432);
     CPPUNIT_TEST(testTdf128627);
     CPPUNIT_TEST(testTdf128634);
+    CPPUNIT_TEST(testTdf130657);
     CPPUNIT_TEST(testDeletedDataLabel);
     CPPUNIT_TEST(testDataPointInheritedColorDOCX);
     CPPUNIT_TEST(testExternalStrRefsXLSX);
@@ -2127,6 +2129,21 @@ void Chart2ImportTest::testTdf128634()
     CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition);
 }
 
+void Chart2ImportTest::testTdf130657()
+{
+    load("/chart2/qa/extras/data/xlsx/", "tdf130657.xlsx");
+    // Test ShiftedCategoryPosition for charts which is not contain a "crossbetween" OOXML tag.
+    uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+    CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
+
+    Reference<chart2::XAxis> xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
+    CPPUNIT_ASSERT(xAxis.is());
+
+    chart2::ScaleData aScaleData = xAxis->getScaleData();
+    CPPUNIT_ASSERT(aScaleData.Categories.is());
+    CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition);
+}
+
 namespace {
 
 void checkDataLabelProperties(const Reference<chart2::XDataSeries>& xDataSeries, sal_Int32 nDataPointIndex, bool bValueVisible)
diff --git a/chart2/qa/extras/data/xlsx/tdf130657.xlsx b/chart2/qa/extras/data/xlsx/tdf130657.xlsx
new file mode 100644
index 000000000000..036da200ab9b
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/tdf130657.xlsx differ
diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx
index b79620081a70..5d1c94b875ba 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -217,8 +217,10 @@ void AxisConverter::convertFromModel(
                         aScaleData.ShiftedCategoryPosition = true;
                     else if( rTypeInfo.meTypeId == TYPEID_RADARLINE || rTypeInfo.meTypeId == TYPEID_RADARAREA )
                         aScaleData.ShiftedCategoryPosition = false;
-                    else
+                    else if( pCrossingAxis->mnCrossBetween != -1 ) /*because of backwards compatibility*/
                         aScaleData.ShiftedCategoryPosition = pCrossingAxis->mnCrossBetween == XML_between;
+                    else if( rTypeInfo.meTypeCategory == TYPECATEGORY_BAR || rTypeInfo.meTypeId == TYPEID_LINE || rTypeInfo.meTypeId == TYPEID_STOCK )
+                        aScaleData.ShiftedCategoryPosition = true;
                 }
                 else
                 {


More information about the Libreoffice-commits mailing list