summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-03-03 17:45:52 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-03-04 08:08:42 +0100
commitfbb0b0a203f19d7a4dc64c47abd6d4b1d8c17340 (patch)
treec7ee4021072142fa3dbaac382667788f2058dc97 /sc
parent556689c485c2df35abd6a0cdff76329178af17bf (diff)
provide MAXCOL/MAXROW also as strings
Primarily for use in tests. Change-Id: Icb962cbdfa63a3b50115314e9afd46f3fa1a928a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130939 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/address.hxx5
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/inc/sheetlimits.hxx10
-rw-r--r--sc/qa/unit/ucalc_formula.cxx4
4 files changed, 18 insertions, 3 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index ce910f42cf49..18bd11049e92 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -81,6 +81,11 @@ const SCROW MAXTILEDROW = 500000;
const SCTAB MAXINITTAB = 1024;
const SCTAB MININITTAB = 1;
+inline constexpr OUStringLiteral MAXROW_STRING(u"1048575");
+inline constexpr OUStringLiteral MAXCOL_STRING(u"AMJ");
+inline constexpr OUStringLiteral MAXROW_JUMBO_STRING(u"16777215");
+inline constexpr OUStringLiteral MAXCOL_JUMBO_STRING(u"XFD");
+
// Special values
const SCTAB SC_TAB_APPEND = SCTAB_MAX;
const SCTAB TABLEID_DOC = SCTAB_MAX; // entire document, e.g. protect
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 344e99e130f8..4e8eab09ed5d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -879,6 +879,8 @@ public:
SC_DLLPUBLIC SCROW MaxRow() const { return mxSheetLimits->mnMaxRow; }
SC_DLLPUBLIC SCCOL GetMaxColCount() const { return mxSheetLimits->GetMaxColCount(); }
SC_DLLPUBLIC SCROW GetMaxRowCount() const { return mxSheetLimits->GetMaxRowCount(); }
+ SC_DLLPUBLIC OUString MaxRowAsString() const { return mxSheetLimits->MaxRowAsString(); }
+ SC_DLLPUBLIC OUString MaxColAsString() const { return mxSheetLimits->MaxColAsString(); }
ScSheetLimits& GetSheetLimits() const { return *mxSheetLimits; }
[[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mxSheetLimits->mnMaxCol); }
[[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mxSheetLimits->mnMaxRow); }
diff --git a/sc/inc/sheetlimits.hxx b/sc/inc/sheetlimits.hxx
index c8dbc1165216..cbc017c9d10e 100644
--- a/sc/inc/sheetlimits.hxx
+++ b/sc/inc/sheetlimits.hxx
@@ -65,6 +65,16 @@ struct ScSheetLimits final : public salhelper::SimpleReferenceObject
SCROW GetMaxRowCount() const { return mnMaxRow + 1; }
// equivalent of MAXCOLCOUNT in address.hxx
SCCOL GetMaxColCount() const { return mnMaxCol + 1; }
+ // max row number as string
+ OUString MaxRowAsString() const
+ {
+ return mnMaxRow == MAXROW ? OUString(MAXROW_STRING) : OUString(MAXROW_JUMBO_STRING);
+ }
+ // mac col as string ("AMJ" or "XFD")
+ OUString MaxColAsString() const
+ {
+ return mnMaxCol == MAXCOL ? OUString(MAXCOL_STRING) : OUString(MAXCOL_JUMBO_STRING);
+ }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 4d31fbf9ea0f..a1790bb930c9 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2501,9 +2501,7 @@ void TestFormula::testFormulaRefUpdateRange()
// C3 with sticky reference including last column.
m_pDoc->SetString( 2,2,1, "=SUM(23:23)");
// C4 with reference to last column.
- 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)");
+ m_pDoc->SetString( 2,3,1, "=SUM(" + m_pDoc->MaxColAsString() + "22:" + m_pDoc->MaxColAsString() + "23)");
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.