sc/qa/unit/data/ods/too-many-cols-rows.ods |binary
 sc/qa/unit/subsequent_filters_test2.cxx    |   14 ++++++++++++++
 sc/source/filter/xml/xmlcelli.cxx          |    6 ++++++
 3 files changed, 20 insertions(+)

New commits:
commit a0f616070f5a344038516d7225295733fd417283
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Mar 22 16:46:55 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Mar 22 17:59:28 2022 +0100

    warn on too many rows/column when loading ODS
    
    There's a warning when loading XLSX, but not when loading ODS.
    Now that 7.4 is going to support 16k columns, that would be a useful
    warning, either if we raise the limits again, or backported to
    7.2/7.3 .
    
    Change-Id: I204bca32e1ff37332b86361d3d81d3fee29c15ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131940
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/qa/unit/data/ods/too-many-cols-rows.ods 
b/sc/qa/unit/data/ods/too-many-cols-rows.ods
new file mode 100644
index 000000000000..fcf1a0bc9ea8
Binary files /dev/null and b/sc/qa/unit/data/ods/too-many-cols-rows.ods differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index 3f89b53e5412..e8164070fd47 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -48,6 +48,7 @@
 #include <stlpool.hxx>
 #include <hints.hxx>
 #include <detfunc.hxx>
+#include <scerrors.hxx>
 
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -180,6 +181,7 @@ public:
     void testTdf139763ShapeAnchor();
     void testAutofilterNamedRangesXLSX();
     void testInvalidBareBiff5();
+    void testTooManyColsRows();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest2);
 
@@ -290,6 +292,7 @@ public:
     CPPUNIT_TEST(testTdf139763ShapeAnchor);
     CPPUNIT_TEST(testAutofilterNamedRangesXLSX);
     CPPUNIT_TEST(testInvalidBareBiff5);
+    CPPUNIT_TEST(testTooManyColsRows);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -3041,6 +3044,17 @@ void ScFiltersTest2::testInvalidBareBiff5()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest2::testTooManyColsRows()
+{
+    // The intentionally doc has cells beyond our MAXROW/MAXCOL, so there
+    // should be a warning on load.
+    ScDocShellRef xDocSh = loadDoc(u"too-many-cols-rows.", FORMAT_ODS);
+    CPPUNIT_ASSERT(xDocSh.is());
+    CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW
+                   || xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW);
+    xDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 2a843e7f75f6..266a520e384a 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1169,7 +1169,10 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( 
const ScAddress& rCellPos,
         // it makes no sense to import data after the last supported column
         // fdo#58539 & gnome#627150
         if(rCurrentPos.Col() > pDoc->MaxCol())
+        {
+            rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
             break;
+        }
 
         if (i > 0)
             rTables.AddColumn(false);
@@ -1182,7 +1185,10 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( 
const ScAddress& rCellPos,
                 // it makes no sense to import data after last supported row
                 // fdo#58539 & gnome#627150
                 if(rCurrentPos.Row() > pDoc->MaxRow())
+                {
+                    
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
                     break;
+                }
 
                 if( (rCurrentPos.Col() == 0) && (j > 0) )
                 {

Reply via email to