sc/inc/address.hxx                   |    6 ++++--
 sc/inc/document.hxx                  |    2 ++
 sc/source/core/data/bcaslot.cxx      |   14 ++++++--------
 sc/source/core/data/column.cxx       |    8 ++++----
 sc/source/core/data/column2.cxx      |    6 +++---
 sc/source/core/data/column3.cxx      |   12 ++++++------
 sc/source/core/data/documen3.cxx     |    4 ++--
 sc/source/core/data/document.cxx     |    8 ++++----
 sc/source/core/data/dpcache.cxx      |    2 +-
 sc/source/core/data/dpoutput.cxx     |    4 ++--
 sc/source/core/data/table6.cxx       |    4 ++--
 sc/source/core/tool/chgtrack.cxx     |    6 +++---
 sc/source/core/tool/formulagroup.cxx |    2 +-
 sc/source/core/tool/interpr4.cxx     |    6 +++---
 sc/source/ui/view/cliputil.cxx       |    5 ++++-
 15 files changed, 47 insertions(+), 42 deletions(-)

New commits:
commit d9a17ca961d65b01b4c5c036ecb11b10a3ff414b
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Feb 25 12:48:31 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Fri Feb 25 22:18:41 2022 +0100

    convert more MAXCOLCOUNT/MAXROWCOUNT
    
    And add GetMax{Col|Row}Count() directly to ScDocument, and also
    add MAX{COL|ROW}COUNT_JUMBO.
    
    Change-Id: Ib92cfbf65dd7cbe87230b02b8916e7cc50fcdbc7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130529
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 4532fffec32d..ce910f42cf49 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -69,8 +69,10 @@ const SCROW       MAXROW         = MAXROWCOUNT - 1;
 const SCCOL       MAXCOL         = MAXCOLCOUNT - 1;
 const SCTAB       MAXTAB         = MAXTABCOUNT - 1;
 const SCCOLROW    MAXCOLROW      = MAXROW;
-const SCROW       MAXROW_JUMBO   = 16 * 1024 * 1024 - 1;
-const SCCOL       MAXCOL_JUMBO   = 16384 - 1;
+const SCROW       MAXROWCOUNT_JUMBO = 16 * 1024 * 1024;
+const SCCOL       MAXCOLCOUNT_JUMBO = 16384;
+const SCROW       MAXROW_JUMBO   = MAXROWCOUNT_JUMBO - 1;
+const SCCOL       MAXCOL_JUMBO   = MAXCOLCOUNT_JUMBO - 1;
 // Maximum tiled rendering values
 const SCROW       MAXTILEDROW    = 500000;
 // Limit the initial tab count to prevent users to set the count too high,
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a53c9334d47f..b0557751ae22 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -877,6 +877,8 @@ public:
     SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
     SC_DLLPUBLIC SCCOL MaxCol() const { return mxSheetLimits->mnMaxCol; }
     SC_DLLPUBLIC SCROW MaxRow() const { return mxSheetLimits->mnMaxRow; }
+    SC_DLLPUBLIC SCCOL GetMaxColCount() const { return 
mxSheetLimits->GetMaxColCount(); }
+    SC_DLLPUBLIC SCROW GetMaxRowCount() const { return 
mxSheetLimits->GetMaxRowCount(); }
     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/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 7e6383a9c35b..65bc2600d475 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -568,7 +568,6 @@ ScBroadcastAreaSlotMachine::ScBroadcastAreaSlotMachine(
     pEOUpdateChain( nullptr ),
     nInBulkBroadcast( 0 )
 {
-    const ScSheetLimits& rSheetLimits = pDoc->GetSheetLimits();
     // initSlotDistribution ---------
     // Logarithmic or any other distribution.
     // Upper and leftmost sheet part usually is more populated and referenced 
and gets fine
@@ -585,7 +584,7 @@ ScBroadcastAreaSlotMachine::ScBroadcastAreaSlotMachine(
     sal_Int32 nCol1 = 0;
     sal_Int32 nCol2 = 1024;
     SCSIZE nSliceCol = 16;
-    while (nCol2 <= rSheetLimits.GetMaxColCount())
+    while (nCol2 <= pDoc->GetMaxColCount())
     {
         SCROW nRow1 = 0;
         SCROW nRow2 = 32*1024;
@@ -593,7 +592,7 @@ ScBroadcastAreaSlotMachine::ScBroadcastAreaSlotMachine(
         SCSIZE nSlotsCol = 0;
         SCSIZE nSlotsStartCol = nSlots;
         // Must be sorted by row1,row2!
-        while (nRow2 <= rSheetLimits.GetMaxRowCount())
+        while (nRow2 <= pDoc->GetMaxRowCount())
         {
             maSlotDistribution.emplace_back(nRow1, nRow2, nSliceRow, 
nSlotsCol, nCol1, nCol2, nSliceCol, nSlotsStartCol);
             nSlotsCol += (nRow2 - nRow1) / nSliceRow;
@@ -690,7 +689,6 @@ static void compare(SCSIZE value1, SCSIZE value2, int line)
 // Basic checks that the calculations work correctly.
 void ScBroadcastAreaSlotMachine::DoChecks()
 {
-    const ScSheetLimits& rSheetLimits = pDoc->GetSheetLimits();
     // Copy&paste from the ctor.
     constexpr SCSIZE nSliceRow = 128;
     constexpr SCSIZE nSliceCol = 16;
@@ -702,7 +700,7 @@ void ScBroadcastAreaSlotMachine::DoChecks()
     compare( ComputeSlotOffset( ScAddress( nSliceCol - 1, 0, 0 )),
              ComputeSlotOffset( ScAddress( nSliceCol, 0, 0 )) - mnBcaSlotsCol, 
__LINE__ );
     // Check that last cell is the last slot.
-    compare( ComputeSlotOffset( ScAddress( rSheetLimits.GetMaxColCount() - 1, 
rSheetLimits.GetMaxRowCount() - 1, 0 )),
+    compare( ComputeSlotOffset( ScAddress( pDoc->GetMaxColCount() - 1, 
pDoc->GetMaxRowCount() - 1, 0 )),
              mnBcaSlots - 1, __LINE__ );
     // Check that adjacent rows in the same column but in different 
distribution areas differ by one slot.
     for( size_t i = 0; i < maSlotDistribution.size() - 1; ++i )
@@ -732,7 +730,7 @@ void ScBroadcastAreaSlotMachine::DoChecks()
         }
     }
     // Iterate all slots.
-    ScRange range( ScAddress( 0, 0, 0 ), ScAddress( 
rSheetLimits.GetMaxColCount() - 1, rSheetLimits.GetMaxRowCount() - 1, 0 ));
+    ScRange range( ScAddress( 0, 0, 0 ), ScAddress( pDoc->MaxCol(), 
pDoc->MaxRow(), 0 ));
     SCSIZE nStart, nEnd, nRowBreak;
     ComputeAreaPoints( range, nStart, nEnd, nRowBreak );
     assert( nStart == 0 );
@@ -749,8 +747,8 @@ void ScBroadcastAreaSlotMachine::DoChecks()
         compare( nOff, previous + 1, __LINE__ );
     }
     // Iterate slots in the last row (each will differ by mnBcaSlotsCol).
-    range = ScRange( ScAddress( 0, rSheetLimits.GetMaxRowCount() - 1, 0 ),
-                     ScAddress( rSheetLimits.GetMaxColCount() - 1, 
rSheetLimits.GetMaxRowCount() - 1, 0 ));
+    range = ScRange( ScAddress( 0, pDoc->MaxRow(), 0 ),
+                     ScAddress( pDoc->MaxCol(), pDoc->MaxRow() - 1, 0 ));
     ComputeAreaPoints( range, nStart, nEnd, nRowBreak );
     assert( nStart == mnBcaSlotsCol - 1 );
     assert( nEnd == mnBcaSlots - 1 );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 5e19d1b05ada..1c091b2a767d 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -875,16 +875,16 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
     pAttrArray->InsertRow( nStartRow, nSize );
 
     maCellNotes.insert_empty(nStartRow, nSize);
-    maCellNotes.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maCellNotes.resize(GetDoc().GetMaxRowCount());
 
     maBroadcasters.insert_empty(nStartRow, nSize);
-    maBroadcasters.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maBroadcasters.resize(GetDoc().GetMaxRowCount());
 
     maCellTextAttrs.insert_empty(nStartRow, nSize);
-    maCellTextAttrs.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maCellTextAttrs.resize(GetDoc().GetMaxRowCount());
 
     maCells.insert_empty(nStartRow, nSize);
-    maCells.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maCells.resize(GetDoc().GetMaxRowCount());
 
     CellStorageModified();
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 042b1eafbe25..c6be6f4ce8f2 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1658,13 +1658,13 @@ void ScColumn::CellStorageModified()
 
     // TODO: Update column's "last updated" timestamp here.
 
-    assert(sal::static_int_cast<SCROW>(maCells.size()) == 
GetDoc().GetSheetLimits().GetMaxRowCount()
+    assert(sal::static_int_cast<SCROW>(maCells.size()) == 
GetDoc().GetMaxRowCount()
         && "Size of the cell array is incorrect." );
 
-    assert(sal::static_int_cast<SCROW>(maCellTextAttrs.size()) == 
GetDoc().GetSheetLimits().GetMaxRowCount()
+    assert(sal::static_int_cast<SCROW>(maCellTextAttrs.size()) == 
GetDoc().GetMaxRowCount()
         && "Size of the cell text attribute array is incorrect.");
 
-    assert(sal::static_int_cast<SCROW>(maBroadcasters.size()) == 
GetDoc().GetSheetLimits().GetMaxRowCount()
+    assert(sal::static_int_cast<SCROW>(maBroadcasters.size()) == 
GetDoc().GetMaxRowCount()
         && "Size of the broadcaster array is incorrect.");
 
 #if DEBUG_COLUMN_STORAGE
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e34aac4d135c..618e56e46626 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -157,7 +157,7 @@ void ScColumn::FreeAll()
 {
     maCells.event_handler().stop();
 
-    auto maxRowCount = GetDoc().GetSheetLimits().GetMaxRowCount();
+    auto maxRowCount = GetDoc().GetMaxRowCount();
     // Keep a logical empty range of 0-rDoc.MaxRow() at all times.
     maCells.clear();
     maCells.resize(maxRowCount);
@@ -171,7 +171,7 @@ void ScColumn::FreeAll()
 void ScColumn::FreeNotes()
 {
     maCellNotes.clear();
-    maCellNotes.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maCellNotes.resize(GetDoc().GetMaxRowCount());
 }
 
 namespace {
@@ -195,11 +195,11 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, 
std::vector<ScAddress>*
     SCROW nEndRow = nStartRow + nSize - 1;
 
     maBroadcasters.erase(nStartRow, nEndRow);
-    maBroadcasters.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maBroadcasters.resize(GetDoc().GetMaxRowCount());
 
     CellNotesDeleting(nStartRow, nEndRow, false);
     maCellNotes.erase(nStartRow, nEndRow);
-    maCellNotes.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maCellNotes.resize(GetDoc().GetMaxRowCount());
 
     // See if we have any cells that would get deleted or shifted by deletion.
     sc::CellStoreType::position_type aPos = maCells.position(nStartRow);
@@ -249,7 +249,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, 
std::vector<ScAddress>*
 
     // Remove the cells.
     maCells.erase(nStartRow, nEndRow);
-    maCells.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maCells.resize(GetDoc().GetMaxRowCount());
 
     // Get the position again after the container change.
     aPos = maCells.position(nStartRow);
@@ -264,7 +264,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, 
std::vector<ScAddress>*
 
     // Shift the text attribute array too (before the broadcast).
     maCellTextAttrs.erase(nStartRow, nEndRow);
-    maCellTextAttrs.resize(GetDoc().GetSheetLimits().GetMaxRowCount());
+    maCellTextAttrs.resize(GetDoc().GetMaxRowCount());
 
     CellStorageModified();
 }
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 01f8be42f085..fcae168d4f58 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1010,9 +1010,9 @@ void ScDocument::UpdateReference(
 {
     if (!ValidRange(rCxt.maRange) && !(rCxt.meMode == URM_INSDEL &&
                 ((rCxt.mnColDelta < 0 &&    // convention from 
ScDocument::DeleteCol()
-                  rCxt.maRange.aStart.Col() == MAXCOLCOUNT && 
rCxt.maRange.aEnd.Col() == MAXCOLCOUNT) ||
+                  rCxt.maRange.aStart.Col() == GetMaxColCount() && 
rCxt.maRange.aEnd.Col() == GetMaxColCount()) ||
                  (rCxt.mnRowDelta < 0 &&    // convention from 
ScDocument::DeleteRow()
-                  rCxt.maRange.aStart.Row() == 
GetSheetLimits().GetMaxRowCount() && rCxt.maRange.aEnd.Row() == 
GetSheetLimits().GetMaxRowCount()))))
+                  rCxt.maRange.aStart.Row() == GetMaxRowCount() && 
rCxt.maRange.aEnd.Row() == GetMaxRowCount()))))
         return;
 
     std::unique_ptr<sc::ExpandRefsSwitch> pExpandRefsSwitch;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 6e0fc6468457..aaced69cc651 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1397,7 +1397,7 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB 
nStartTab,
     while ( lcl_GetNextTabRange( nTabRangeStart, nTabRangeEnd, pTabMark, 
static_cast<SCTAB>(maTabs.size()) ) );
 
     sc::RefUpdateContext aCxt(*this);
-    const bool bLastRowIncluded = (static_cast<SCROW>(nStartRow + nSize) == 
GetSheetLimits().GetMaxRowCount() && ValidRow(nStartRow));
+    const bool bLastRowIncluded = (static_cast<SCROW>(nStartRow + nSize) == 
GetMaxRowCount() && ValidRow(nStartRow));
     if ( ValidRow(nStartRow+nSize) || bLastRowIncluded )
     {
         lcl_GetFirstTabRange( nTabRangeStart, nTabRangeEnd, pTabMark, 
static_cast<SCTAB>(maTabs.size()) );
@@ -1406,7 +1406,7 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB 
nStartTab,
         if (bLastRowIncluded)
         {
             // Last row is included, shift a virtually non-existent row in.
-            aCxt.maRange = ScRange( nStartCol, 
GetSheetLimits().GetMaxRowCount(), nTabRangeStart, nEndCol, 
GetSheetLimits().GetMaxRowCount(), nTabRangeEnd);
+            aCxt.maRange = ScRange( nStartCol, GetMaxRowCount(), 
nTabRangeStart, nEndCol, GetMaxRowCount(), nTabRangeEnd);
         }
         else
         {
@@ -1618,7 +1618,7 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB 
nStartTab, SCROW nEndRow, SCTA
     while ( lcl_GetNextTabRange( nTabRangeStart, nTabRangeEnd, pTabMark, 
static_cast<SCTAB>(maTabs.size()) ) );
 
     sc::RefUpdateContext aCxt(*this);
-    const bool bLastColIncluded = (nStartCol + nSize == MAXCOLCOUNT && 
ValidCol(nStartCol));
+    const bool bLastColIncluded = (static_cast<SCCOL>(nStartCol + nSize) == 
GetMaxColCount() && ValidCol(nStartCol));
     if ( ValidCol(sal::static_int_cast<SCCOL>(nStartCol+nSize)) || 
bLastColIncluded )
     {
         lcl_GetFirstTabRange( nTabRangeStart, nTabRangeEnd, pTabMark, 
static_cast<SCTAB>(maTabs.size()) );
@@ -1627,7 +1627,7 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB 
nStartTab, SCROW nEndRow, SCTA
         if (bLastColIncluded)
         {
             // Last column is included, shift a virtually non-existent column 
in.
-            aCxt.maRange = ScRange( MAXCOLCOUNT, nStartRow, nTabRangeStart, 
MAXCOLCOUNT, nEndRow, nTabRangeEnd);
+            aCxt.maRange = ScRange( GetMaxColCount(), nStartRow, 
nTabRangeStart, GetMaxColCount(), nEndRow, nTabRangeEnd);
         }
         else
         {
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index d544fb884d9c..0f3778eb40a6 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -72,7 +72,7 @@ ScDPCache::Field::Field() : mnNumFormat(0) {}
 ScDPCache::ScDPCache(ScDocument& rDoc) :
     mrDoc( rDoc ),
     mnColumnCount ( 0 ),
-    maEmptyRows(0, rDoc.GetSheetLimits().GetMaxRowCount(), true),
+    maEmptyRows(0, rDoc.GetMaxRowCount(), true),
     mnDataSize(-1),
     mnRowCount(0),
     mbDisposing(false)
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 1297fb136afb..c15f9b6e848f 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -859,8 +859,8 @@ void ScDPOutput::CalcSizes()
             ++nPageSize;        //  filter button above the page fields
     }
 
-    if ( aStartPos.Col() + static_cast<tools::Long>(pRowFields.size()) + 
nColCount - 1 > MAXCOL ||
-         aStartPos.Row() + nPageSize + nHeaderSize + pColFields.size() + 
nRowCount > MAXROW )
+    if ( aStartPos.Col() + static_cast<tools::Long>(pRowFields.size()) + 
nColCount - 1 > pDoc->MaxCol() ||
+         aStartPos.Row() + nPageSize + nHeaderSize + 
static_cast<tools::Long>(pColFields.size()) + nRowCount > pDoc->MaxRow())
     {
         bSizeOverflow = true;
     }
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 4245e8c548da..0ced56900d6d 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -799,8 +799,8 @@ bool ScTable::SearchAndReplace(
     bool bFound = false;
     if ( ValidColRow(rCol, rRow) ||
          ((nCommand == SvxSearchCmd::FIND || nCommand == 
SvxSearchCmd::REPLACE) &&
-           (((rCol == GetDoc().GetSheetLimits().GetMaxColCount() || rCol == 
-1) && ValidRow(rRow)) ||
-            ((rRow == GetDoc().GetSheetLimits().GetMaxRowCount() || rRow == 
-1) && ValidCol(rCol))
+           (((rCol == GetDoc().GetMaxColCount() || rCol == -1) && 
ValidRow(rRow)) ||
+            ((rRow == GetDoc().GetMaxRowCount() || rRow == -1) && 
ValidCol(rCol))
            )
          )
        )
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index e82be567387d..ab0cd2ae6199 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1999,8 +1999,8 @@ SCSIZE ScChangeTrack::ComputeContentSlot( sal_Int32 nRow 
) const
 SCROW ScChangeTrack::InitContentRowsPerSlot()
 {
     const SCSIZE nMaxSlots = 0xffe0 / sizeof( ScChangeActionContent* ) - 2;
-    SCROW nRowsPerSlot = rDoc.GetSheetLimits().GetMaxRowCount() / nMaxSlots;
-    if ( nRowsPerSlot * nMaxSlots < 
sal::static_int_cast<SCSIZE>(rDoc.GetSheetLimits().GetMaxRowCount()) )
+    SCROW nRowsPerSlot = rDoc.GetMaxRowCount() / nMaxSlots;
+    if ( nRowsPerSlot * nMaxSlots < 
sal::static_int_cast<SCSIZE>(rDoc.GetMaxRowCount()) )
         ++nRowsPerSlot;
     return nRowsPerSlot;
 }
@@ -2036,7 +2036,7 @@ ScChangeTrack::~ScChangeTrack()
 void ScChangeTrack::Init()
 {
     mnContentRowsPerSlot = InitContentRowsPerSlot();
-    mnContentSlots = rDoc.GetSheetLimits().GetMaxRowCount() / 
InitContentRowsPerSlot() + 2;
+    mnContentSlots = rDoc.GetMaxRowCount() / InitContentRowsPerSlot() + 2;
 
     pFirst = nullptr;
     pLast = nullptr;
diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index f430c511ceed..c7ac689f25f3 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -41,7 +41,7 @@ FormulaGroupEntry::FormulaGroupEntry( ScFormulaCell* pCell, 
size_t nRow ) :
 
 size_t FormulaGroupContext::ColKey::Hash::operator ()( const 
FormulaGroupContext::ColKey& rKey ) const
 {
-    return rKey.mnTab * MAXCOLCOUNT + rKey.mnCol;
+    return rKey.mnTab * MAXCOLCOUNT_JUMBO + rKey.mnCol;
 }
 
 FormulaGroupContext::ColKey::ColKey( SCTAB nTab, SCCOL nCol ) : mnTab(nTab), 
mnCol(nCol) {}
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 9abd5729c557..185ad830f057 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -281,7 +281,7 @@ bool ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW 
nRow1, SCTAB nTab1,
 {
 
     // Old Add-Ins are hard limited to sal_uInt16 values.
-    static_assert(MAXCOL < SAL_MAX_UINT16 && MAXCOL_JUMBO < SAL_MAX_UINT16,
+    static_assert(MAXCOLCOUNT <= SAL_MAX_UINT16 && MAXCOLCOUNT_JUMBO <= 
SAL_MAX_UINT16,
         "Add check for columns > SAL_MAX_UINT16!");
     if (nRow1 > SAL_MAX_UINT16 || nRow2 > SAL_MAX_UINT16)
         return false;
@@ -365,7 +365,7 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW 
nRow1, SCTAB nTab1,
 {
 
     // Old Add-Ins are hard limited to sal_uInt16 values.
-    static_assert(MAXCOL < SAL_MAX_UINT16 && MAXCOL_JUMBO < SAL_MAX_UINT16,
+    static_assert(MAXCOLCOUNT <= SAL_MAX_UINT16 && MAXCOLCOUNT_JUMBO <= 
SAL_MAX_UINT16,
         "Add check for columns > SAL_MAX_UINT16!");
     if (nRow1 > SAL_MAX_UINT16 || nRow2 > SAL_MAX_UINT16)
         return false;
@@ -463,7 +463,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, 
SCTAB nTab1,
 {
 
     // Old Add-Ins are hard limited to sal_uInt16 values.
-    static_assert(MAXCOL < SAL_MAX_UINT16 && MAXCOL_JUMBO < SAL_MAX_UINT16,
+    static_assert(MAXCOLCOUNT <= SAL_MAX_UINT16 && MAXCOLCOUNT_JUMBO <= 
SAL_MAX_UINT16,
         "Add check for columns > SAL_MAX_UINT16!");
     if (nRow1 > SAL_MAX_UINT16 || nRow2 > SAL_MAX_UINT16)
         return false;
diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index 494c1b27c366..bbf80bce33ad 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -104,8 +104,11 @@ void ScClipUtil::PasteFromClipboard( ScViewData& 
rViewData, ScTabViewShell* pTab
             ScClipParam clipParam = pOwnClip->GetDocument()->GetClipParam();
             if (clipParam.maRanges.size() > 0)
             {
-                if (clipParam.maRanges[0].aEnd.Col() == MAXCOLCOUNT -1 || 
clipParam.maRanges[0].aEnd.Row() == MAXROWCOUNT - 1)
+                if (clipParam.maRanges[0].aEnd.Col() == 
pOwnClip->GetDocument()->MaxCol()
+                    || clipParam.maRanges[0].aEnd.Row() == 
pOwnClip->GetDocument()->MaxRow())
+                {
                     entireColumnOrRowSelected = true;
+                }
             }
         }
         const SfxBoolItem* pItem = rThisDoc.GetAttr(nThisCol, nThisRow, 
nThisTab, ATTR_LINEBREAK);

Reply via email to