chart2/qa/extras/chart2export.cxx           |   10 ++++++++++
 chart2/qa/extras/data/xlsx/empty_chart.xlsx |binary
 oox/source/export/chartexport.cxx           |    5 +++++
 sc/source/filter/xcl97/xcl97rec.cxx         |   10 ++++++----
 4 files changed, 21 insertions(+), 4 deletions(-)

New commits:
commit a8950d08a33e7aded31d4591c98a03d1edf8c5a4
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Fri Aug 14 13:45:38 2020 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Wed Aug 19 10:31:51 2020 +0200

    tdf#123647 Chart XLSX export: fix missing empty chart
    
    Save empty chart as empty bar chart, because a chart without chart type
    is invalid.
    
    Change-Id: Ieb9cc4300070b5280565fe814ba0343640dfff0a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100844
    Tested-by: Jenkins
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index 754768880054..948aaec6700a 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -174,6 +174,7 @@ public:
     void testTdf132594();
     void testTdf134255();
     void testTdf134977();
+    void testTdf123647();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(testErrorBarXLSX);
@@ -311,6 +312,7 @@ public:
     CPPUNIT_TEST(testTdf132594);
     CPPUNIT_TEST(testTdf134255);
     CPPUNIT_TEST(testTdf134977);
+    CPPUNIT_TEST(testTdf123647);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2861,6 +2863,14 @@ void Chart2ExportTest::testTdf134977()
     assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:tx/c:rich/a:p/a:r/a:rPr",
 "sz", "900");
 }
 
+void Chart2ExportTest::testTdf123647()
+{
+    load("/chart2/qa/extras/data/xlsx/", "empty_chart.xlsx");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open 
XML");
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart", 1);
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/xlsx/empty_chart.xlsx 
b/chart2/qa/extras/data/xlsx/empty_chart.xlsx
new file mode 100644
index 000000000000..449902146af6
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/empty_chart.xlsx differ
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index ab8458d44b04..5ea054d83ca0 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1380,6 +1380,11 @@ void ChartExport::exportPlotArea( const Reference< 
css::chart::XChartDocument >&
     // chart type
     const Sequence< Reference< chart2::XCoordinateSystem > >
         aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
+
+    // tdf#123647 Save empty chart as empty bar chart.
+    if (!aCooSysSeq.hasElements())
+        exportBarChart(nullptr);
+
     for( const auto& rCS : aCooSysSeq )
     {
         Reference< chart2::XChartTypeContainer > xCTCnt( rCS, uno::UNO_QUERY );
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx 
b/sc/source/filter/xcl97/xcl97rec.cxx
index 213dfe77d4ae..0f9ba1288d33 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -202,9 +202,11 @@ bool IsValidObject( const XclObj& rObj )
         if (!xCooSysContainer.is())
             return false;
 
-        const uno::Sequence<uno::Reference<chart2::XCoordinateSystem> > 
xCooSysSeq = xCooSysContainer->getCoordinateSystems();
-        if (!xCooSysSeq.hasElements())
-            return false;
+        const uno::Sequence<uno::Reference<chart2::XCoordinateSystem>> 
xCooSysSeq = xCooSysContainer->getCoordinateSystems();
+
+        // tdf#123647 Save empty charts too.
+        // if (!xCooSysSeq.hasElements())
+        //     return false;
 
         for (const auto& rCooSys : xCooSysSeq)
         {
@@ -212,7 +214,7 @@ bool IsValidObject( const XclObj& rObj )
             if (!xChartTypeCont.is())
                 return false;
 
-            uno::Sequence<uno::Reference<chart2::XChartType> > xChartTypeSeq = 
xChartTypeCont->getChartTypes();
+            uno::Sequence<uno::Reference<chart2::XChartType>> xChartTypeSeq = 
xChartTypeCont->getChartTypes();
             if (!xChartTypeSeq.hasElements())
                 // No chart type.  Not good.
                 return false;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to