chart2/qa/extras/chart2export.cxx                  |   11 +++++++++++
 chart2/qa/extras/data/xlsx/tdf134118.xlsx          |binary
 oox/source/drawingml/chart/chartspaceconverter.cxx |   11 ++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit f5977a2ac9a000b0fcef546a05f3ed6121906bbd
Author:     Balazs Varga <balazs.varga...@gmail.com>
AuthorDate: Wed Aug 12 08:34:42 2020 +0200
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Wed Oct 14 12:08:32 2020 +0200

    tdf#134118 Chart OOXML import: fix gaps in month based data
    
    Leave gaps instead of zeroes, like MSO does, if data ranges
    contain empty cells at month based time resolution.
    
    Change-Id: Ie934b56d9d5cb556bcca41e0e4ddce3ea65f7228
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100573
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 886c2e35fadc7813498da041fc4ea8a8ba2fb358)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104288
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index 58c2439d16e0..268e30d46d19 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -149,6 +149,7 @@ public:
     void testTdf121744();
     void testTdf122031();
     void testTdf115012();
+    void testTdf134118();
     void testTdf123206_customLabelText();
     void testCustomLabelText();
     void testTdf131979();
@@ -268,6 +269,7 @@ public:
     CPPUNIT_TEST(testTdf121744);
     CPPUNIT_TEST(testTdf122031);
     CPPUNIT_TEST(testTdf115012);
+    CPPUNIT_TEST(testTdf134118);
     CPPUNIT_TEST(testTdf123206_customLabelText);
     CPPUNIT_TEST(testCustomLabelText);
     CPPUNIT_TEST(testTdf131979);
@@ -2412,6 +2414,15 @@ void Chart2ExportTest::testTdf115012()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", 
"zero");
 }
 
+void Chart2ExportTest::testTdf134118()
+{
+    load("/chart2/qa/extras/data/xlsx/", "tdf134118.xlsx");
+    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    CPPUNIT_ASSERT(pXmlDoc);
+    // workaround: use leave-gap instead of zero to show the original line 
chart
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "gap");
+}
+
 void Chart2ExportTest::testTdf123206_customLabelText()
 {
     load("/chart2/qa/extras/data/docx/", "tdf123206.docx");
diff --git a/chart2/qa/extras/data/xlsx/tdf134118.xlsx 
b/chart2/qa/extras/data/xlsx/tdf134118.xlsx
new file mode 100644
index 000000000000..ca86fb8cf118
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/tdf134118.xlsx differ
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx 
b/oox/source/drawingml/chart/chartspaceconverter.cxx
index 997aa4d41fbe..c37457e9f0b6 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -208,7 +208,16 @@ void ChartSpaceConverter::convertFromModel( const 
Reference< XShapes >& rxExtern
     {
         using namespace ::com::sun::star::chart::MissingValueTreatment;
         sal_Int32 nMissingValues = LEAVE_GAP;
-        switch( mrModel.mnDispBlanksAs )
+
+        // tdf#134118 leave gap if the time unit is month
+        bool bIsMonthBasedTimeUnit = false;
+        if( mrModel.mxPlotArea.is() && mrModel.mxPlotArea->maAxes.size() > 0 &&
+            mrModel.mxPlotArea->maAxes[0]->monBaseTimeUnit.has() )
+        {
+            bIsMonthBasedTimeUnit = 
mrModel.mxPlotArea->maAxes[0]->monBaseTimeUnit.get() == XML_months;
+        }
+
+        if (!bIsMonthBasedTimeUnit) switch( mrModel.mnDispBlanksAs )
         {
             case XML_gap:   nMissingValues = LEAVE_GAP; break;
             case XML_zero:  nMissingValues = USE_ZERO;  break;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to