summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-02-22 19:03:33 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-02-23 09:52:17 +0100
commitbc734289e5542a0ffa04c0ac3cd1aa7cb1810be0 (patch)
treebebe8f48d1b5fe7135020b29c5f4fb6d502d5047
parent7e482815b4a719fa4d04f0013c96d8a8063bad21 (diff)
fix more MAXCOL/MAXROW in tests
Change-Id: I7e3444f0b2ee5a4297705a24fbab3bfb96904b8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130387 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx80
-rw-r--r--sc/qa/unit/ucalc_formula.cxx78
2 files changed, 105 insertions, 53 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 3e47b42df6f0..b0990b41f150 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1894,6 +1894,7 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
comphelper::LibreOfficeKit::setPartInInvalidation(true);
ScModelObj* pModelObj = createDoc("two_sheets.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
ScViewData* pViewData = ScDocShell::GetViewData();
CPPUNIT_ASSERT(pViewData);
@@ -1910,7 +1911,10 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidations.size());
- CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1310720, 268435456), aView1.m_aInvalidations[0]);
+ const ScSheetLimits& rLimits = pDoc->GetSheetLimits();
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1280 * rLimits.GetMaxColCount(),
+ 256 * rLimits.GetMaxRowCount()),
+ aView1.m_aInvalidations[0]);
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1000000000, 1000000000), aView1.m_aInvalidations[1]);
CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidationsParts.size());
CPPUNIT_ASSERT_EQUAL(pModelObj->getPart(), aView1.m_aInvalidationsParts[0]);
@@ -2208,27 +2212,6 @@ class SheetGeometryData
public:
- SheetGeometryData()
- {
- aCols = {
- // width spans
- { { STD_COL_WIDTH, MAXCOL } },
- // hidden spans
- { { 0, MAXCOL } },
- // filtered spans
- { { 0, MAXCOL } }
- };
-
- aRows = {
- // height spans
- { { ScGlobal::nStdRowHeight, MAXROW } },
- // hidden spans
- { { 0, MAXROW } },
- // filtered spans
- { { 0, MAXROW } }
- };
- }
-
SheetGeometryData(const SheetDimData& rCols, const SheetDimData& rRows) :
aCols(rCols), aRows(rRows)
{}
@@ -2259,6 +2242,7 @@ public:
void ScTiledRenderingTest::testSheetGeometryDataInvariance()
{
ScModelObj* pModelObj = createDoc("empty.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
const SheetGeometryData aSGData(
// cols
{
@@ -2266,21 +2250,21 @@ void ScTiledRenderingTest::testSheetGeometryDataInvariance()
{
{ STD_COL_WIDTH, 20 },
{ 2*STD_COL_WIDTH, 26 },
- { STD_COL_WIDTH, MAXCOL }
+ { STD_COL_WIDTH, pDoc->MaxCol() }
},
// hidden spans
{
{ 0, 5 },
{ 1, 12 },
- { 0, MAXCOL }
+ { 0, pDoc->MaxCol() }
},
// filtered spans
{
{ 0, 50 },
{ 1, 59 },
- { 0, MAXCOL }
+ { 0, pDoc->MaxCol() }
}
},
@@ -2290,7 +2274,7 @@ void ScTiledRenderingTest::testSheetGeometryDataInvariance()
{
{ 300, 50 },
{ 600, 65 },
- { 300, MAXROW }
+ { 300, pDoc->MaxRow() }
},
// hidden spans
@@ -2298,20 +2282,18 @@ void ScTiledRenderingTest::testSheetGeometryDataInvariance()
{ 1, 100 },
{ 0, 500 },
{ 1, 578 },
- { 0, MAXROW }
+ { 0, pDoc->MaxRow() }
},
// filtered spans
{
{ 0, 150 },
{ 1, 159 },
- { 0, MAXROW }
+ { 0, pDoc->MaxRow() }
}
}
);
- ScDocument* pDoc = pModelObj->GetDocument();
-
ScViewData* pViewData = ScDocShell::GetViewData();
CPPUNIT_ASSERT(pViewData);
@@ -2363,6 +2345,28 @@ void ScTiledRenderingTest::testSheetGeometryDataInvariance()
void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
{
ScModelObj* pModelObj = createDoc("empty.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
+ const SheetGeometryData aDefaultSGData(
+ // cols
+ {
+ // width spans
+ { { STD_COL_WIDTH, pDoc->MaxCol() } },
+ // hidden spans
+ { { 0, pDoc->MaxCol() } },
+ // filtered spans
+ { { 0, pDoc->MaxCol() } }
+ },
+ // rows
+ {
+ // height spans
+ { { ScGlobal::nStdRowHeight, pDoc->MaxRow() } },
+ // hidden spans
+ { { 0, pDoc->MaxRow() } },
+ // filtered spans
+ { { 0, pDoc->MaxRow() } }
+ }
+ );
+
const SheetGeometryData aSGData(
// cols
{
@@ -2370,21 +2374,21 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
{
{ STD_COL_WIDTH, 20 },
{ 2*STD_COL_WIDTH, 26 },
- { STD_COL_WIDTH, MAXCOL }
+ { STD_COL_WIDTH, pDoc->MaxCol() }
},
// hidden spans
{
{ 0, 5 },
{ 1, 12 },
- { 0, MAXCOL }
+ { 0, pDoc->MaxCol() }
},
// filtered spans
{
{ 0, 50 },
{ 1, 59 },
- { 0, MAXCOL }
+ { 0, pDoc->MaxCol() }
}
},
@@ -2394,7 +2398,7 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
{
{ 300, 50 },
{ 600, 65 },
- { 300, MAXROW }
+ { 300, pDoc->MaxRow() }
},
// hidden spans
@@ -2402,20 +2406,18 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
{ 1, 100 },
{ 0, 500 },
{ 1, 578 },
- { 0, MAXROW }
+ { 0, pDoc->MaxRow() }
},
// filtered spans
{
{ 0, 150 },
{ 1, 159 },
- { 0, MAXROW }
+ { 0, pDoc->MaxRow() }
}
}
);
- ScDocument* pDoc = pModelObj->GetDocument();
-
ScViewData* pViewData = ScDocShell::GetViewData();
CPPUNIT_ASSERT(pViewData);
@@ -2425,7 +2427,7 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
// with the default empty sheet and test the JSON encoding.
OString aGeomDefaultStr = pModelObj->getSheetGeometryData(/*bColumns*/ true, /*bRows*/ true, /*bSizes*/ true,
/*bHidden*/ true, /*bFiltered*/ true, /*bGroups*/ true);
- SheetGeometryData().parseTest(aGeomDefaultStr);
+ aDefaultSGData.parseTest(aGeomDefaultStr);
// Apply geometry settings to the sheet and then test the resulting JSON encoding.
aSGData.setDataToDoc(pDoc);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index ef12df67748f..3255a4b3ed56 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -789,7 +789,9 @@ void TestFormula::testFormulaParseReference()
// Both rows at sheet bounds and relative => convert to absolute => entire column reference.
aRange.aStart.SetTab(0);
- nRes = aRange.Parse("B1:B1048576", *m_pDoc, formula::FormulaGrammar::CONV_OOO);
+ nRes = aRange.Parse(m_pDoc->MaxRow() == MAXROW ? OUString("B1:B1048576")
+ : OUString("B1:B16777216"),
+ *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>(1), aRange.aStart.Col());
@@ -808,7 +810,7 @@ void TestFormula::testFormulaParseReference()
// Both columns at sheet bounds and relative => convert to absolute => entire row reference.
aRange.aStart.SetTab(0);
- nRes = aRange.Parse("A2:AMJ2", *m_pDoc, formula::FormulaGrammar::CONV_OOO);
+ nRes = aRange.Parse(m_pDoc->MaxCol() == MAXCOL ? "A2:AMJ2" : "A2:XFD2", *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());
@@ -827,24 +829,69 @@ void TestFormula::testFormulaParseReference()
// Check for reference input conversion to and display string of entire column/row.
{
- const char* aChecks[][2] = {
+ const char* row1048576Checks[][2] = {
{ "=B:B", "B:B" },
{ "=B1:B1048576", "B:B" },
{ "=B1:B$1048576", "B1:B$1048576" },
{ "=B$1:B1048576", "B$1:B1048576" },
- { "=B$1:B$1048576", "B:B" },
+ { "=B$1:B$1048576", "B:B" }
+ };
+ const char* row16777216Checks[][2] = {
+ { "=B:B", "B:B" },
+ { "=B1:B16777216", "B:B" },
+ { "=B1:B$16777216", "B1:B$16777216" },
+ { "=B$1:B16777216", "B$1:B16777216" },
+ { "=B$1:B$16777216", "B:B" }
+ };
+ const char* col1024Checks[][2] = {
{ "=2:2", "2:2" },
{ "=A2:AMJ2", "2:2" },
{ "=A2:$AMJ2", "A2:$AMJ2" },
{ "=$A2:AMJ2", "$A2:AMJ2" },
{ "=$A2:$AMJ2", "2:2" }
};
+ const char* col16384Checks[][2] = {
+ { "=2:2", "2:2" },
+ { "=A2:XFD2", "2:2" },
+ { "=A2:$XFD2", "A2:$XFD2" },
+ { "=$A2:XFD2", "$A2:XFD2" },
+ { "=$A2:$XFD2", "2:2" }
+ };
- for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
+ if (m_pDoc->MaxRow() == 1048575)
{
- // Use the 'Dummy' sheet for this.
- m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(aChecks[i][0]));
- ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), aChecks[i][1], "Wrong formula");
+ for (const auto& check : row1048576Checks)
+ {
+ // Use the 'Dummy' sheet for this.
+ m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0]));
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula");
+ }
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL(SCROW(16777215), m_pDoc->MaxRow());
+ for (const auto& check : row16777216Checks)
+ {
+ m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0]));
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula");
+ }
+ }
+ if (m_pDoc->MaxCol() == 1023)
+ {
+ for (const auto& check : col1024Checks)
+ {
+ m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0]));
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula");
+ }
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL(SCROW(16383), m_pDoc->MaxRow());
+ for (const auto& check : col16384Checks)
+ {
+ m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0]));
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula");
+ }
}
}
@@ -2431,14 +2478,16 @@ void TestFormula::testFormulaRefUpdateRange()
ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:$B", "Wrong reference in A17 after deletion.");
aPos.IncRow();
- // Enter values in B1 and B1048576 (last row).
+ // Enter values in B1 and B1048576/B16777216 (last row).
m_pDoc->SetValue( 1,0,1, 1.0);
m_pDoc->SetValue( 1,m_pDoc->MaxRow(),1, 2.0);
// Sticky reference including last row.
m_pDoc->SetString( 2,0,1, "=SUM(B:B)");
// Reference to last row.
- CPPUNIT_ASSERT_EQUAL_MESSAGE("m_pDoc->MaxRow() changed, adapt unit test.", 1048575, int(m_pDoc->MaxRow()));
- m_pDoc->SetString( 2,1,1, "=SUM(B1048576:C1048576)");
+ CPPUNIT_ASSERT_MESSAGE("m_pDoc->MaxRow() changed, adapt unit test.",
+ m_pDoc->MaxRow() == 1048575 || m_pDoc->MaxRow() == 16777215);
+ m_pDoc->SetString( 2,1,1, m_pDoc->MaxRow() == 1048575 ? OUString("=SUM(B1048576:C1048576)")
+ : OUString("=SUM(B16777216:C16777216)"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C1.", 3.0, m_pDoc->GetValue(2,0,1));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C2.", 2.0, m_pDoc->GetValue(2,1,1));
// Delete last row.
@@ -2446,14 +2495,15 @@ void TestFormula::testFormulaRefUpdateRange()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C1.", 1.0, m_pDoc->GetValue(2,0,1));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Reference in C2 not invalidated.", OUString("#REF!"), m_pDoc->GetString(2,1,1));
- // Enter values in A23 and AMJ23 (last column).
+ // Enter values in A23 and AMJ23/XFD23 (last column).
m_pDoc->SetValue( 0,22,1, 1.0);
m_pDoc->SetValue( m_pDoc->MaxCol(),22,1, 2.0);
// C3 with sticky reference including last column.
m_pDoc->SetString( 2,2,1, "=SUM(23:23)");
// C4 with reference to last column.
- CPPUNIT_ASSERT_EQUAL_MESSAGE("m_pDoc->MaxCol() changed, adapt unit test.", 1023, int(m_pDoc->MaxCol()));
- m_pDoc->SetString( 2,3,1, "=SUM(AMJ22:AMJ23)");
+ CPPUNIT_ASSERT_MESSAGE("m_pDoc->MaxCol() changed, adapt unit test.",
+ m_pDoc->MaxCol() == 1023 || m_pDoc->MaxCol() == 16383);
+ m_pDoc->SetString( 2,3,1, m_pDoc->MaxCol() == 1023 ? "=SUM(AMJ22:AMJ23)" : "=SUM(XFD22:XFD23)");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C3.", 3.0, m_pDoc->GetValue(2,2,1));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C4.", 2.0, m_pDoc->GetValue(2,3,1));
// Delete last column.