diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-03-22 16:46:55 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-03-24 19:10:54 +0100 |
commit | cb9a166f4d3fff1ff364aade5d40ef9a6d4da24b (patch) | |
tree | ce314c1eb514ea84f226ae17970d8303c3ad62be | |
parent | 11f22ac8526557c3340aa948da12ac3da81cda7e (diff) |
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/+/131945
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/qa/unit/data/ods/too-many-cols-rows.ods | bin | 0 -> 9646 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test2.cxx | 17 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 6 |
3 files changed, 20 insertions, 3 deletions
diff --git a/sc/qa/unit/data/ods/too-many-cols-rows.ods b/sc/qa/unit/data/ods/too-many-cols-rows.ods Binary files differnew file mode 100644 index 000000000000..fcf1a0bc9ea8 --- /dev/null +++ b/sc/qa/unit/data/ods/too-many-cols-rows.ods diff --git a/sc/qa/unit/subsequent_filters-test2.cxx b/sc/qa/unit/subsequent_filters-test2.cxx index 35ad23deba54..d6b738d43c33 100644 --- a/sc/qa/unit/subsequent_filters-test2.cxx +++ b/sc/qa/unit/subsequent_filters-test2.cxx @@ -70,9 +70,7 @@ #include <detfunc.hxx> #include <cellmergeoption.hxx> #include <undoblk.hxx> - -#include <orcusfilters.hxx> -#include <filter.hxx> +#include <scerrors.hxx> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XControlShape.hpp> @@ -207,6 +205,7 @@ public: void testTdf139763ShapeAnchor(); void testAutofilterNamedRangesXLSX(); void testInvalidBareBiff5(); + void testTooManyColsRows(); CPPUNIT_TEST_SUITE(ScFiltersTest2); @@ -313,6 +312,7 @@ public: CPPUNIT_TEST(testTdf139763ShapeAnchor); CPPUNIT_TEST(testAutofilterNamedRangesXLSX); CPPUNIT_TEST(testInvalidBareBiff5); + CPPUNIT_TEST(testTooManyColsRows); CPPUNIT_TEST_SUITE_END(); @@ -2983,6 +2983,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 638c2c5cba67..04bf96b98860 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1170,7 +1170,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); @@ -1183,7 +1186,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) ) { |