diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-03-04 20:42:59 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-03-23 09:09:07 +0100 |
commit | dab3dec28da57f1132f5b4b194f452d12366225a (patch) | |
tree | facf952921adf78e24dd2772c2b67860d991ea9d | |
parent | 52ce03c8e27a36f21cf2e70bc335f10fc3251ffd (diff) |
remove more hardcoded sheet sizes from Calc tests
E.g. sctablesheetobj test had the limits hardcoded, even as actual
numbers. Apparently some tests cannot easily access global
settings, but this at least makes it easy to check all tests
after modifying ScSheetLimits::CreateDefault().
Change-Id: I6cff577fb01b1ea262dcd1f9fde24e114e19abdc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131040
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r-- | sc/CppunitTest_sc_tablecolumnsobj.mk | 3 | ||||
-rw-r--r-- | sc/CppunitTest_sc_tablerowsobj.mk | 3 | ||||
-rw-r--r-- | sc/CppunitTest_sc_tablesheetobj.mk | 3 | ||||
-rw-r--r-- | sc/inc/sheetlimits.hxx | 9 | ||||
-rw-r--r-- | sc/qa/extras/sctablecolumnsobj.cxx | 4 | ||||
-rw-r--r-- | sc/qa/extras/sctablerowsobj.cxx | 4 | ||||
-rw-r--r-- | sc/qa/extras/sctablesheetobj.cxx | 7 | ||||
-rw-r--r-- | sc/qa/unit/mark_test.cxx | 146 | ||||
-rw-r--r-- | sc/qa/unit/rangelst_test.cxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 16 |
12 files changed, 115 insertions, 86 deletions
diff --git a/sc/CppunitTest_sc_tablecolumnsobj.mk b/sc/CppunitTest_sc_tablecolumnsobj.mk index 04d41985aa22..29e65d860830 100644 --- a/sc/CppunitTest_sc_tablecolumnsobj.mk +++ b/sc/CppunitTest_sc_tablecolumnsobj.mk @@ -22,12 +22,15 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sc_tablecolumnsobj, \ $(eval $(call gb_CppunitTest_use_libraries,sc_tablecolumnsobj, \ cppu \ sal \ + salhelper \ + sc \ subsequenttest \ test \ unotest \ )) $(eval $(call gb_CppunitTest_set_include,sc_tablecolumnsobj,\ + -I$(SRCDIR)/sc/inc \ $$(INCLUDE) \ )) diff --git a/sc/CppunitTest_sc_tablerowsobj.mk b/sc/CppunitTest_sc_tablerowsobj.mk index 4c82243b4f1a..ffbd3850aebd 100644 --- a/sc/CppunitTest_sc_tablerowsobj.mk +++ b/sc/CppunitTest_sc_tablerowsobj.mk @@ -22,12 +22,15 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sc_tablerowsobj, \ $(eval $(call gb_CppunitTest_use_libraries,sc_tablerowsobj, \ cppu \ sal \ + salhelper \ + sc \ subsequenttest \ test \ unotest \ )) $(eval $(call gb_CppunitTest_set_include,sc_tablerowsobj,\ + -I$(SRCDIR)/sc/inc \ $$(INCLUDE) \ )) diff --git a/sc/CppunitTest_sc_tablesheetobj.mk b/sc/CppunitTest_sc_tablesheetobj.mk index 44e72d112bc8..52f7f427b27a 100644 --- a/sc/CppunitTest_sc_tablesheetobj.mk +++ b/sc/CppunitTest_sc_tablesheetobj.mk @@ -22,12 +22,15 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sc_tablesheetobj, \ $(eval $(call gb_CppunitTest_use_libraries,sc_tablesheetobj, \ cppu \ sal \ + salhelper \ + sc \ subsequenttest \ test \ unotest \ )) $(eval $(call gb_CppunitTest_set_include,sc_tablesheetobj,\ + -I$(SRCDIR)/sc/inc \ $$(INCLUDE) \ )) diff --git a/sc/inc/sheetlimits.hxx b/sc/inc/sheetlimits.hxx index cbc017c9d10e..1d1410b9056a 100644 --- a/sc/inc/sheetlimits.hxx +++ b/sc/inc/sheetlimits.hxx @@ -31,12 +31,13 @@ struct ScSheetLimits final : public salhelper::SimpleReferenceObject ScSheetLimits(SCCOL nMaxCol, SCROW nMaxRow) : mnMaxCol(nMaxCol) - , mnMaxRow(nMaxRow){} - - [[nodiscard]] bool ValidCol(SCCOL nCol) const + , mnMaxRow(nMaxRow) { - return ::ValidCol(nCol, mnMaxCol); } + + SC_DLLPUBLIC static ScSheetLimits CreateDefault(); + + [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mnMaxCol); } [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mnMaxRow); } [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { diff --git a/sc/qa/extras/sctablecolumnsobj.cxx b/sc/qa/extras/sctablecolumnsobj.cxx index 406e559489fa..ccb96f7c786d 100644 --- a/sc/qa/extras/sctablecolumnsobj.cxx +++ b/sc/qa/extras/sctablecolumnsobj.cxx @@ -29,6 +29,8 @@ #include <com/sun/star/uno/Reference.hxx> +#include <sheetlimits.hxx> + using namespace css; namespace sc_apitest @@ -90,7 +92,7 @@ private: ScTableColumnsObj::ScTableColumnsObj() : CalcUnoApiTest("/sc/qa/extras/testdocuments") , XElementAccess(cppu::UnoType<table::XCellRange>::get()) - , XIndexAccess(1024) + , XIndexAccess(ScSheetLimits::CreateDefault().GetMaxColCount()) , XNameAccess("ABC") , XServiceInfo("ScTableColumnsObj", "com.sun.star.table.TableColumns") { diff --git a/sc/qa/extras/sctablerowsobj.cxx b/sc/qa/extras/sctablerowsobj.cxx index 5efe6bc64cac..419a326f48cd 100644 --- a/sc/qa/extras/sctablerowsobj.cxx +++ b/sc/qa/extras/sctablerowsobj.cxx @@ -28,6 +28,8 @@ #include <cppu/unotype.hxx> +#include <sheetlimits.hxx> + using namespace css; using namespace css::uno; @@ -79,7 +81,7 @@ private: ScTableRowsObj::ScTableRowsObj() : CalcUnoApiTest("/sc/qa/extras/testdocuments") , XElementAccess(cppu::UnoType<table::XCellRange>::get()) - , XIndexAccess(1048576) + , XIndexAccess(ScSheetLimits::CreateDefault().GetMaxRowCount()) , XServiceInfo("ScTableRowsObj", "com.sun.star.table.TableRows") { } diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx index 3179ae54d2d3..055de3babb2b 100644 --- a/sc/qa/extras/sctablesheetobj.cxx +++ b/sc/qa/extras/sctablesheetobj.cxx @@ -48,6 +48,8 @@ #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/table/CellRangeAddress.hpp> +#include <sheetlimits.hxx> + using namespace css; using namespace css::uno; @@ -248,7 +250,10 @@ private: ScTableSheetObj::ScTableSheetObj(): CalcUnoApiTest("/sc/qa/extras/testdocuments"), apitest::XCellSeries(1, 0), - apitest::XFormulaQuery(table::CellRangeAddress(0, 0, 0, 1023, 1048575), table::CellRangeAddress(0, 0, 0, 1023, 1048575), 0, 0), + apitest::XFormulaQuery( + table::CellRangeAddress(0, 0, 0, ScSheetLimits::CreateDefault().MaxCol(), ScSheetLimits::CreateDefault().MaxRow()), + table::CellRangeAddress(0, 0, 0, ScSheetLimits::CreateDefault().MaxCol(), ScSheetLimits::CreateDefault().MaxRow()), + 0, 0), apitest::XReplaceable("searchReplaceString", "replaceReplaceString"), apitest::XSearchable("test", 4) { diff --git a/sc/qa/unit/mark_test.cxx b/sc/qa/unit/mark_test.cxx index 55a13cb0da57..bca735aae202 100644 --- a/sc/qa/unit/mark_test.cxx +++ b/sc/qa/unit/mark_test.cxx @@ -96,7 +96,8 @@ class Test : public CppUnit::TestFixture public: void testSimpleMark( const ScRange& rRange, const ScRange& rSelectionCover, const ScRangeList& rLeftEnvelope, const ScRangeList& rRightEnvelope, - const ScRangeList& rTopEnvelope, const ScRangeList& rBottomEnvelope ); + const ScRangeList& rTopEnvelope, const ScRangeList& rBottomEnvelope, + const ScSheetLimits& rLimits ); void testSimpleMark_Simple(); void testSimpleMark_Column(); void testSimpleMark_Row(); @@ -147,10 +148,10 @@ static void lcl_GetSortedRanges( const ScRangeList& rRangeList, ScRangeList& rRa void Test::testSimpleMark( const ScRange& rRange, const ScRange& rSelectionCover, const ScRangeList& rLeftEnvelope, const ScRangeList& rRightEnvelope, - const ScRangeList& rTopEnvelope, const ScRangeList& rBottomEnvelope ) + const ScRangeList& rTopEnvelope, const ScRangeList& rBottomEnvelope, + const ScSheetLimits& rLimits ) { - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); - ScMarkData aMark(aSheetLimits); + ScMarkData aMark(rLimits); CPPUNIT_ASSERT( !aMark.IsMarked() ); CPPUNIT_ASSERT( !aMark.IsMultiMarked() ); @@ -168,29 +169,29 @@ void Test::testSimpleMark( const ScRange& rRange, const ScRange& rSelectionCover SCCOL nOutCol2 = rRange.aStart.Col() - 1; CPPUNIT_ASSERT( aMark.IsCellMarked( nMidCol, nMidRow ) ); - if ( ValidCol( nOutCol1, MAXCOL ) && ValidRow( nOutRow1, MAXROW ) ) + if ( ValidCol( nOutCol1, rLimits.MaxCol() ) && ValidRow( nOutRow1, rLimits.MaxRow() ) ) CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol1, nOutRow1 ) ); - if ( ValidCol( nOutCol2, MAXCOL ) && ValidRow( nOutRow2, MAXROW ) ) + if ( ValidCol( nOutCol2, rLimits.MaxCol() ) && ValidRow( nOutRow2, rLimits.MaxRow() ) ) CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol2, nOutRow2 ) ); - if ( ValidRow( nOutRow1, MAXROW ) ) + if ( ValidRow( nOutRow1, rLimits.MaxRow() ) ) CPPUNIT_ASSERT( !aMark.IsCellMarked( nMidCol, nOutRow1 ) ); - if ( ValidCol( nOutCol1, MAXCOL ) ) + if ( ValidCol( nOutCol1, rLimits.MaxCol() ) ) CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol1, nMidRow ) ); - if ( ValidRow( nOutRow2, MAXROW ) ) + if ( ValidRow( nOutRow2, rLimits.MaxRow() ) ) CPPUNIT_ASSERT( !aMark.IsCellMarked( nMidCol, nOutRow2 ) ); - if ( ValidCol( nOutCol2, MAXCOL ) ) + if ( ValidCol( nOutCol2, rLimits.MaxCol() ) ) CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol2, nMidRow ) ); - if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW ) + if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == rLimits.MaxRow() ) CPPUNIT_ASSERT( aMark.IsColumnMarked( nMidCol ) ); else CPPUNIT_ASSERT( !aMark.IsColumnMarked( nMidCol ) ); - if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) + if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == rLimits.MaxCol() ) CPPUNIT_ASSERT( aMark.IsRowMarked( nMidRow ) ); else CPPUNIT_ASSERT( !aMark.IsRowMarked( nMidRow ) ); @@ -206,58 +207,65 @@ void Test::testSimpleMark( const ScRange& rRange, const ScRange& rSelectionCover void Test::testSimpleMark_Simple() { + ScSheetLimits limits( ScSheetLimits::CreateDefault()); testSimpleMark( ScRange( 10, 15, 0, 20, 30, 0 ), // Simple range ScRange( 9, 14, 0, 21, 31, 0 ), // Cover ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope ScRangeList( ScRange( 21, 15, 0, 21, 30, 0 ) ), // Right envelope ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope - ScRangeList( ScRange( 10, 31, 0, 20, 31, 0 ) ) ); // Bottom envelope + ScRangeList( ScRange( 10, 31, 0, 20, 31, 0 ) ), // Bottom envelope + limits ); } void Test::testSimpleMark_Column() { + ScSheetLimits limits( ScSheetLimits::CreateDefault()); // Column 10, rows from 15 to 30 testSimpleMark( ScRange( 10, 15, 0, 10, 30, 0 ), // Simple range ScRange( 9, 14, 0, 11, 31, 0 ), // Cover ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope ScRangeList( ScRange( 11, 15, 0, 11, 30, 0 ) ), // Right envelope ScRangeList( ScRange( 10, 14, 0, 10, 14, 0 ) ), // Top envelope - ScRangeList( ScRange( 10, 31, 0, 10, 31, 0 ) ) ); // Bottom envelope + ScRangeList( ScRange( 10, 31, 0, 10, 31, 0 ) ), // Bottom envelope + limits ); // Full Column 10 - testSimpleMark( ScRange( 10, 0, 0, 10, MAXROW, 0 ), // Simple range - ScRange( 9, 0, 0, 11, MAXROW, 0 ), // Cover - ScRangeList( ScRange( 9, 0, 0, 9, MAXROW, 0 ) ), // Left envelope - ScRangeList( ScRange( 11, 0, 0, 11, MAXROW, 0 ) ), // Right envelope + testSimpleMark( ScRange( 10, 0, 0, 10, limits.MaxRow(), 0 ), // Simple range + ScRange( 9, 0, 0, 11, limits.MaxRow(), 0 ), // Cover + ScRangeList( ScRange( 9, 0, 0, 9, limits.MaxRow(), 0 ) ), // Left envelope + ScRangeList( ScRange( 11, 0, 0, 11, limits.MaxRow(), 0 ) ), // Right envelope ScRangeList(), // Top envelope - ScRangeList()); // Bottom envelope + ScRangeList(), // Bottom envelope + limits ); } void Test::testSimpleMark_Row() { + ScSheetLimits limits( ScSheetLimits::CreateDefault()); // Row 15, cols from 10 to 20 testSimpleMark( ScRange( 10, 15, 0, 20, 15, 0 ), // Simple range ScRange( 9, 14, 0, 21, 16, 0 ), // Cover ScRangeList( ScRange( 9, 15, 0, 9, 15, 0 ) ), // Left envelope ScRangeList( ScRange( 21, 15, 0, 21, 15, 0 ) ), // Right envelope ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope - ScRangeList( ScRange( 10, 16, 0, 20, 16, 0 ) ) ); // Bottom envelope + ScRangeList( ScRange( 10, 16, 0, 20, 16, 0 ) ), // Bottom envelope + limits ); // Full Row 15 - testSimpleMark( ScRange( 0, 15, 0, MAXCOL, 15, 0 ), // Simple range - ScRange( 0, 14, 0, MAXCOL, 16, 0 ), // Cover + testSimpleMark( ScRange( 0, 15, 0, limits.MaxCol(), 15, 0 ), // Simple range + ScRange( 0, 14, 0, limits.MaxCol(), 16, 0 ), // Cover ScRangeList(), // Left envelope ScRangeList(), // Right envelope - ScRangeList( ScRange( 0, 14, 0, MAXCOL, 14, 0 ) ), // Top envelope - ScRangeList( ScRange( 0, 16, 0, MAXCOL, 16, 0 ) ) ); // Bottom envelope + ScRangeList( ScRange( 0, 14, 0, limits.MaxCol(), 14, 0 ) ), // Top envelope + ScRangeList( ScRange( 0, 16, 0, limits.MaxCol(), 16, 0 ) ), // Bottom envelope + limits ); } void Test::testMultiMark( const MultiMarkTestData& rMarksData ) { - - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); - ScMarkData aMark(aSheetLimits); - ScMultiSel aMultiSel(aSheetLimits); + ScSheetLimits limits( ScSheetLimits::CreateDefault()); + ScMarkData aMark(limits); + ScMultiSel aMultiSel(limits); CPPUNIT_ASSERT( !aMark.IsMarked() ); CPPUNIT_ASSERT( !aMark.IsMultiMarked() ); CPPUNIT_ASSERT_EQUAL( SCCOL(0), aMultiSel.GetMultiSelectionCount() ); @@ -286,13 +294,13 @@ void Test::testMultiMark( const MultiMarkTestData& rMarksData ) for ( const auto& rCol : rAreaTestData.aColumnsWithFullMarks ) { CPPUNIT_ASSERT( aMark.IsColumnMarked( rCol ) ); - CPPUNIT_ASSERT( aMultiSel.IsAllMarked( rCol, 0, MAXROW ) ); + CPPUNIT_ASSERT( aMultiSel.IsAllMarked( rCol, 0, limits.MaxRow() ) ); } for ( const auto& rCol : rAreaTestData.aColumnsWithoutFullMarks ) { CPPUNIT_ASSERT( !aMark.IsColumnMarked( rCol ) ); - CPPUNIT_ASSERT( !aMultiSel.IsAllMarked( rCol, 0, MAXROW ) ); + CPPUNIT_ASSERT( !aMultiSel.IsAllMarked( rCol, 0, limits.MaxRow() ) ); } for ( const auto& rRow : rAreaTestData.aRowsWithFullMarks ) @@ -415,6 +423,7 @@ void Test::testMultiMark( const MultiMarkTestData& rMarksData ) void Test::testMultiMark_FourRanges() { + ScSheetLimits limits( ScSheetLimits::CreateDefault()); MultiMarkTestData aData; MarkTestData aSingle1; @@ -449,7 +458,7 @@ void Test::testMultiMark_FourRanges() aSingle1.aNextMarked.emplace_back( 15, 1, 0, 1, 5, 0 ); // Search down aSingle1.aNextMarked.emplace_back( 15, 15, 0, 0, 10, 0 ); // Search up - aSingle1.aNextMarked.emplace_back( 15, 15, 0, 1, MAXROWCOUNT, 0 ); // Search down fail + aSingle1.aNextMarked.emplace_back( 15, 15, 0, 1, limits.GetMaxRowCount(), 0 ); // Search down fail aSingle1.aNextMarked.emplace_back( 15, 4, 0, 0, -1, 0 ); // Search up fail aSingle1.aColumnsWithAtLeastOneMark.push_back( 10 ); @@ -495,7 +504,7 @@ void Test::testMultiMark_FourRanges() aSingle2.aNextMarked.emplace_back( 27, 16, 0, 0, 15, 0 ); // up ok aSingle2.aNextMarked.emplace_back( 27, 4, 0, 1, 7, 0 ); // down ok aSingle2.aNextMarked.emplace_back( 27, 4, 0, 0, -1, 0 ); // up fail - aSingle2.aNextMarked.emplace_back( 27, 16, 0, 1, MAXROWCOUNT, 0 ); // down fail + aSingle2.aNextMarked.emplace_back( 27, 16, 0, 1, limits.GetMaxRowCount(), 0 ); // down fail aSingle2.aColumnsWithAtLeastOneMark = aSingle1.aColumnsWithAtLeastOneMark; aSingle2.aColumnsWithAtLeastOneMark.push_back( 25 ); @@ -510,7 +519,7 @@ void Test::testMultiMark_FourRanges() // Full row = 20 MarkTestData aSingle3; - aSingle3.aRange = ScRange( 0, 20, 0, MAXCOL, 20, 0 ); + aSingle3.aRange = ScRange( 0, 20, 0, limits.MaxCol(), 20, 0 ); aSingle3.bMark = true; aSingle3.aInsideAddresses = aSingle2.aInsideAddresses; @@ -525,13 +534,13 @@ void Test::testMultiMark_FourRanges() aSingle3.aRowsWithFullMarks.push_back( 20 ); aSingle3.aRangesWithFullMarks = aSingle2.aRangesWithFullMarks; - aSingle3.aRangesWithFullMarks.emplace_back( 0, 20, 0, MAXCOL, 20, 0 ); + aSingle3.aRangesWithFullMarks.emplace_back( 0, 20, 0, limits.MaxCol(), 20, 0 ); aSingle3.aRangesWithFullMarks.emplace_back( 15, 20, 0, 55, 20, 0 ); aSingle3.aNextMarked.emplace_back( 15, 16, 0, 0, 10, 0 ); // up ok aSingle3.aNextMarked.emplace_back( 15, 16, 0, 1, 20, 0 ); // down ok aSingle3.aNextMarked.emplace_back( 22, 15, 0, 0, -1, 0 ); // up fail - aSingle3.aNextMarked.emplace_back( 22, 25, 0, 1, MAXROWCOUNT, 0 ); // down fail + aSingle3.aNextMarked.emplace_back( 22, 25, 0, 1, limits.GetMaxRowCount(), 0 ); // down fail aSingle3.aColumnsWithAtLeastOneMark = aSingle2.aColumnsWithAtLeastOneMark; aSingle3.aColumnsWithAtLeastOneMark.push_back( 39 ); @@ -539,7 +548,7 @@ void Test::testMultiMark_FourRanges() // Full col = 35 MarkTestData aSingle4; - aSingle4.aRange = ScRange( 35, 0, 0, 35, MAXROW, 0 ); + aSingle4.aRange = ScRange( 35, 0, 0, 35, limits.MaxRow(), 0 ); aSingle4.bMark = true; aSingle4.aInsideAddresses = aSingle3.aInsideAddresses; @@ -556,7 +565,7 @@ void Test::testMultiMark_FourRanges() aSingle4.aRowsWithFullMarks.push_back( 20 ); aSingle4.aRangesWithFullMarks = aSingle3.aRangesWithFullMarks; - aSingle4.aRangesWithFullMarks.emplace_back( 35, 0, 0, 35, MAXROW, 0 ); + aSingle4.aRangesWithFullMarks.emplace_back( 35, 0, 0, 35, limits.MaxRow(), 0 ); aSingle4.aRangesWithFullMarks.emplace_back( 35, 10, 0, 35, 25, 0 ); // Add the rectangle data to aData @@ -565,26 +574,26 @@ void Test::testMultiMark_FourRanges() aData.aMarks.push_back( aSingle3 ); aData.aMarks.push_back( aSingle4 ); - aData.aSelectionCover = ScRange( 0, 0, 0, MAXCOL, MAXROW, 0 ); + aData.aSelectionCover = ScRange( 0, 0, 0, limits.MaxCol(), limits.MaxRow(), 0 ); aData.aLeftEnvelope.push_back( ScRange( 9, 5, 0, 9, 10, 0 ) ); aData.aLeftEnvelope.push_back( ScRange( 24, 7, 0, 24, 15, 0 ) ); aData.aLeftEnvelope.push_back( ScRange( 34, 0, 0, 34, 19, 0 ) ); - aData.aLeftEnvelope.push_back( ScRange( 34, 21, 0, 34, MAXROW, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 34, 21, 0, 34, limits.MaxRow(), 0 ) ); aData.aRightEnvelope.push_back( ScRange( 21, 5, 0, 21, 10, 0 ) ); aData.aRightEnvelope.push_back( ScRange( 31, 7, 0, 31, 15, 0 ) ); aData.aRightEnvelope.push_back( ScRange( 36, 0, 0, 36, 19, 0 ) ); - aData.aRightEnvelope.push_back( ScRange( 36, 21, 0, 36, MAXROW, 0 ) ); + aData.aRightEnvelope.push_back( ScRange( 36, 21, 0, 36, limits.MaxRow(), 0 ) ); aData.aTopEnvelope.push_back( ScRange( 10, 4, 0, 20, 4, 0 ) ); aData.aTopEnvelope.push_back( ScRange( 25, 6, 0, 30, 6, 0 ) ); aData.aTopEnvelope.push_back( ScRange( 0, 19, 0, 34, 19, 0 ) ); - aData.aTopEnvelope.push_back( ScRange( 36, 19, 0, MAXCOL, 19, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 36, 19, 0, limits.MaxCol(), 19, 0 ) ); aData.aBottomEnvelope.push_back( ScRange( 10, 11, 0, 20, 11, 0 ) ); aData.aBottomEnvelope.push_back( ScRange( 25, 16, 0, 30, 16, 0 ) ); aData.aBottomEnvelope.push_back( ScRange( 0, 21, 0, 34, 21, 0 ) ); - aData.aBottomEnvelope.push_back( ScRange( 36, 21, 0, MAXCOL, 21, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 36, 21, 0, limits.MaxCol(), 21, 0 ) ); MarkArrayTestData aMarkArrayTestData1; aMarkArrayTestData1.nCol = 5; @@ -610,7 +619,7 @@ void Test::testMultiMark_FourRanges() MarkArrayTestData aMarkArrayTestData6; aMarkArrayTestData6.nCol = 35; - aMarkArrayTestData6.aMarkedRowSegs.emplace_back( 0, MAXROW ); + aMarkArrayTestData6.aMarkedRowSegs.emplace_back( 0, limits.MaxRow() ); MarkArrayTestData aMarkArrayTestData7; aMarkArrayTestData7.nCol = 40; @@ -627,7 +636,7 @@ void Test::testMultiMark_FourRanges() aData.aColsWithOneMark.emplace_back( 5, 20, 0, 0, 20, 0 ); aData.aColsWithOneMark.emplace_back( 22, 20, 0, 0, 20, 0 ); aData.aColsWithOneMark.emplace_back( 32, 20, 0, 0, 20, 0 ); - aData.aColsWithOneMark.emplace_back( 35, 0, 0, 0, MAXROW, 0 ); + aData.aColsWithOneMark.emplace_back( 35, 0, 0, 0, limits.MaxRow(), 0 ); aData.aColsWithOneMark.emplace_back( 50, 20, 0, 0, 20, 0 ); aData.aColsWithoutOneMark.push_back( 10 ); @@ -642,7 +651,7 @@ void Test::testMultiMark_FourRanges() aData.aColsAllMarked.emplace_back( 10, 20, 0, 0, 20, 0 ); aData.aColsAllMarked.emplace_back( 25, 7, 0, 0, 15, 0 ); aData.aColsAllMarked.emplace_back( 30, 7, 0, 0, 15, 0 ); - aData.aColsAllMarked.emplace_back( 35, 0, 0, 0, MAXROW, 0 ); + aData.aColsAllMarked.emplace_back( 35, 0, 0, 0, limits.MaxRow(), 0 ); aData.aColsAllMarked.emplace_back( 100, 20, 0, 0, 20, 0 ); aData.aColsNotAllMarked.emplace_back( 5, 5, 0, 0, 25, 0 ); @@ -676,11 +685,12 @@ void Test::testMultiMark_FourRanges() void Test::testMultiMark_NegativeMarking() { + ScSheetLimits limits( ScSheetLimits::CreateDefault()); MultiMarkTestData aData; // Create full row = 5 MarkTestData aSingle1; - aSingle1.aRange = ScRange( 0, 5, 0, MAXCOL, 5, 0 ); + aSingle1.aRange = ScRange( 0, 5, 0, limits.MaxCol(), 5, 0 ); aSingle1.bMark = true; // Create rectangle ( 10, 8, 25, 20 ) @@ -690,7 +700,7 @@ void Test::testMultiMark_NegativeMarking() // Create full row = 12 MarkTestData aSingle3; - aSingle3.aRange = ScRange( 0, 12, 0, MAXCOL, 12, 0 ); + aSingle3.aRange = ScRange( 0, 12, 0, limits.MaxCol(), 12, 0 ); aSingle3.bMark = true; // Create deselection rectangle ( 17, 5, 20, 5 ) @@ -765,7 +775,7 @@ void Test::testMultiMark_NegativeMarking() aData.aMarks.push_back( aSingle4 ); aData.aMarks.push_back( aSingle5 ); - aData.aSelectionCover = ScRange( 0, 4, 0, MAXCOL, 21, 0 ); + aData.aSelectionCover = ScRange( 0, 4, 0, limits.MaxCol(), 21, 0 ); aData.aLeftEnvelope.push_back( ScRange( 9, 8, 0, 9, 11, 0 ) ); aData.aLeftEnvelope.push_back( ScRange( 9, 13, 0, 9, 20, 0 ) ); aData.aLeftEnvelope.push_back( ScRange( 18, 10, 0, 18, 14, 0 ) ); @@ -777,17 +787,17 @@ void Test::testMultiMark_NegativeMarking() aData.aRightEnvelope.push_back( ScRange( 26, 13, 0, 26, 20, 0 ) ); aData.aTopEnvelope.push_back( ScRange( 0, 4, 0, 16, 4, 0 ) ); - aData.aTopEnvelope.push_back( ScRange( 21, 4, 0, MAXCOL, 4, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 21, 4, 0, limits.MaxCol(), 4, 0 ) ); aData.aTopEnvelope.push_back( ScRange( 10, 7, 0, 25, 7, 0 ) ); aData.aTopEnvelope.push_back( ScRange( 0, 11, 0, 9, 11, 0 ) ); - aData.aTopEnvelope.push_back( ScRange( 26, 11, 0, MAXCOL, 11, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 26, 11, 0, limits.MaxCol(), 11, 0 ) ); aData.aTopEnvelope.push_back( ScRange( 15, 14, 0, 18, 14, 0 ) ); aData.aBottomEnvelope.push_back( ScRange( 0, 6, 0, 16, 6, 0 ) ); - aData.aBottomEnvelope.push_back( ScRange( 21, 6, 0, MAXCOL, 6, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 21, 6, 0, limits.MaxCol(), 6, 0 ) ); aData.aBottomEnvelope.push_back( ScRange( 15, 10, 0, 18, 10, 0 ) ); aData.aBottomEnvelope.push_back( ScRange( 0, 13, 0, 9, 13, 0 ) ); - aData.aBottomEnvelope.push_back( ScRange( 26, 13, 0, MAXCOL, 13, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 26, 13, 0, limits.MaxCol(), 13, 0 ) ); aData.aBottomEnvelope.push_back( ScRange( 10, 21, 0, 25, 21, 0 ) ); aData.aColsWithOneMark.emplace_back( 19, 8, 0, 0, 20, 0 ); @@ -834,8 +844,7 @@ void Test::testMultiMark_NegativeMarking() void Test::testInsertTabBeforeSelected() { - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); - ScMarkData aMark(aSheetLimits); + ScMarkData aMark(ScSheetLimits::CreateDefault()); aMark.SelectOneTable(0); aMark.InsertTab(0); CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount()); @@ -844,8 +853,7 @@ void Test::testInsertTabBeforeSelected() void Test::testInsertTabAfterSelected() { - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); - ScMarkData aMark(aSheetLimits); + ScMarkData aMark(ScSheetLimits::CreateDefault()); aMark.SelectOneTable(0); aMark.InsertTab(1); CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount()); @@ -854,8 +862,7 @@ void Test::testInsertTabAfterSelected() void Test::testDeleteTabBeforeSelected() { - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); - ScMarkData aMark(aSheetLimits); + ScMarkData aMark(ScSheetLimits::CreateDefault()); aMark.SelectOneTable(1); aMark.DeleteTab(0); CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount()); @@ -864,8 +871,7 @@ void Test::testDeleteTabBeforeSelected() void Test::testDeleteTabAfterSelected() { - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); - ScMarkData aMark(aSheetLimits); + ScMarkData aMark(ScSheetLimits::CreateDefault()); aMark.SelectOneTable(0); aMark.DeleteTab(1); CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount()); @@ -882,17 +888,17 @@ void Test::testScMarkArraySearch_check(const ScMarkArray & ar, SCROW nRow, bool void Test::testScMarkArraySearch() { - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); + ScSheetLimits limits( ScSheetLimits::CreateDefault()); // empty { - ScMarkArray ar(aSheetLimits); + ScMarkArray ar(limits); testScMarkArraySearch_check(ar, -1, true, 0); testScMarkArraySearch_check(ar, 100, true, 0); } // one range { - ScMarkArray ar(aSheetLimits); + ScMarkArray ar(limits); ar.SetMarkArea(10, 20, true); // 0-9,10-20,21+ @@ -913,7 +919,7 @@ void Test::testScMarkArraySearch() // three ranges { - ScMarkArray ar(aSheetLimits); + ScMarkArray ar(limits); ar.SetMarkArea(10, 20, true); ar.SetMarkArea(21, 30, true); ar.SetMarkArea(50, 100, true); @@ -934,7 +940,7 @@ void Test::testScMarkArraySearch() // three single-row ranges { - ScMarkArray ar(aSheetLimits); + ScMarkArray ar(limits); ar.SetMarkArea(4, 4, true); ar.SetMarkArea(6, 6, true); ar.SetMarkArea(8, 8, true); @@ -954,8 +960,8 @@ void Test::testScMarkArraySearch() // one range { - ScMarkArray ar(aSheetLimits); - ar.SetMarkArea(10, MAXROW, true); + ScMarkArray ar(limits); + ar.SetMarkArea(10, limits.MaxRow(), true); // 0-10,11+ @@ -969,14 +975,14 @@ void Test::testScMarkArraySearch() testScMarkArraySearch_check(ar, 11, true, 1); testScMarkArraySearch_check(ar, 12, true, 1); testScMarkArraySearch_check(ar, 200, true, 1); - testScMarkArraySearch_check(ar, MAXROW, true, 1); + testScMarkArraySearch_check(ar, limits.MaxRow(), true, 1); } } void Test::testIsAllMarked() { - ScSheetLimits aSheetLimits(MAXCOL, MAXROW); - ScMarkData mark(aSheetLimits); + ScSheetLimits limits( ScSheetLimits::CreateDefault()); + ScMarkData mark(limits); ScRange range1( ScAddress( 5, 10, 0 ), ScAddress( 15, 20, 0 )); ScRange range2( ScAddress( 2, 2, 0 ), ScAddress( 25, 30, 0 )); CPPUNIT_ASSERT( !mark.IsAllMarked( range1 )); diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx index 4795f33ad081..7a35ea238881 100644 --- a/sc/qa/unit/rangelst_test.cxx +++ b/sc/qa/unit/rangelst_test.cxx @@ -254,7 +254,7 @@ void Test::testDeleteArea_2Ranges() void Test::testDeleteArea_2Ranges_Case2() { ScRangeList aList(ScRange(1,1,0,1,5,0)); - aList.DeleteArea(0,3,0,MAXCOL,3,0); + aList.DeleteArea(0,3,0,ScSheetLimits::CreateDefault().MaxCol(),3,0); for(SCROW nRow = 1; nRow <= 5; ++nRow) { diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 9fc0b4185154..b51735bad5bd 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6703,7 +6703,7 @@ void Test::testInsertColumnsWithFormulaCells() CPPUNIT_ASSERT_MESSAGE("Columns 2, 4 and 6 should contain formula cells.", equals(aExpected, aCols)); // Insert 2 columns at column A to shift everything to right by 2. - m_pDoc->InsertCol(0, 0, MAXROW, 0, 0, 2); + m_pDoc->InsertCol(0, 0, m_pDoc->MaxRow(), 0, 0, 2); aExpected = { 4, 6, 8 }; aCols = m_pDoc->QueryColumnsWithFormulaCells(0); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index e2264167a5b1..1693b2a0d6c8 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -817,7 +817,7 @@ void TestFormula::testFormulaParseReference() // Both columns at sheet bounds and relative => convert to absolute => entire row reference. aRange.aStart.SetTab(0); - nRes = aRange.Parse(m_pDoc->MaxCol() == MAXCOL ? "A2:AMJ2" : "A2:XFD2", *m_pDoc, formula::FormulaGrammar::CONV_OOO); + nRes = aRange.Parse("A2:" + m_pDoc->MaxColAsString() + "2", *m_pDoc, formula::FormulaGrammar::CONV_OOO); CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(0), aRange.aStart.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), aRange.aStart.Col()); diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index e3b2bed52589..a6aebc039219 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -93,15 +93,19 @@ using namespace com::sun::star; const sal_uInt16 ScDocument::nSrcVer = SC_CURRENT_VERSION; -static ScSheetLimits* CreateSheetLimits() +ScSheetLimits ScSheetLimits::CreateDefault() { #if HAVE_FEATURE_JUMBO_SHEETS - const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions(); - if (rOpt.GetInitJumboSheets()) - return new ScSheetLimits(MAXCOL_JUMBO, MAXROW_JUMBO); + bool jumboSheets = false; + if( SC_MOD()) + jumboSheets = SC_MOD()->GetDefaultsOptions().GetInitJumboSheets(); + else + assert( getenv("LO_TESTNAME") != nullptr ); // in unittests + if (jumboSheets) + return ScSheetLimits(MAXCOL_JUMBO, MAXROW_JUMBO); else #endif - return new ScSheetLimits(MAXCOL, MAXROW); + return ScSheetLimits(MAXCOL, MAXROW); } ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : @@ -114,7 +118,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mpPrinter( nullptr ), mpVirtualDevice_100th_mm( nullptr ), pFormatExchangeList( nullptr ), - mxSheetLimits(CreateSheetLimits()), + mxSheetLimits(new ScSheetLimits(ScSheetLimits::CreateDefault())), pFormulaTree( nullptr ), pEOFormulaTree( nullptr ), pFormulaTrack( nullptr ), |