diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-29 16:14:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-30 10:49:19 +0200 |
commit | 9ab64dc48a6a61edce6ff3724093162ca1cf8331 (patch) | |
tree | 7b27c9ea039671ddb133eb4f141862a2611dee29 /sc/source | |
parent | cefad27ee85486b01cf600c08371a651787dadc2 (diff) |
pass ScSheetLimits around
instead of MAXROW, MAXCOL. In preparation for more conversion work that
needs to be done to make jumbo sheets work.
Change-Id: I4698b8fe111e060ae2a965afc7276b7e7bfb482a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95153
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
36 files changed, 224 insertions, 169 deletions
diff --git a/sc/source/core/data/colcontainer.cxx b/sc/source/core/data/colcontainer.cxx index 74a3ca46ecfb..4a99bc16f336 100644 --- a/sc/source/core/data/colcontainer.cxx +++ b/sc/source/core/data/colcontainer.cxx @@ -25,7 +25,7 @@ ScColContainer::ScColContainer( const size_t nSize ) { aCols.resize( nSize ); for ( size_t nCol = 0; nCol < nSize; ++nCol ) - aCols[nCol].reset( new ScColumn ); + aCols[nCol].reset( new ScColumn() ); } ScColContainer::~ScColContainer() COVERITY_NOEXCEPT_FALSE @@ -49,7 +49,7 @@ void ScColContainer::resize( const size_t aNewColSize ) size_t aOldColSize = aCols.size(); aCols.resize( aNewColSize ); for ( size_t nCol = aOldColSize; nCol < aNewColSize; ++nCol ) - aCols[nCol].reset(new ScColumn); + aCols[nCol].reset(new ScColumn()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 6a150a82c60c..b18b68e1fc68 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -2231,7 +2231,7 @@ ScRangeList ScConditionalFormatList::GetCombinedRange() const void ScConditionalFormatList::RemoveFromDocument(ScDocument* pDoc) const { ScRangeList aRange = GetCombinedRange(); - ScMarkData aMark(pDoc->MaxRow(), pDoc->MaxCol()); + ScMarkData aMark(pDoc->GetSheetLimits()); aMark.MarkFromRangeList(aRange, true); sal_uInt16 const pItems[2] = { sal_uInt16(ATTR_CONDITIONAL),0}; pDoc->ClearSelectionItems(pItems, aMark); diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index cc45c83c30d4..ac89e288bda1 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -91,6 +91,15 @@ using namespace com::sun::star; const sal_uInt16 ScDocument::nSrcVer = SC_CURRENT_VERSION; +static ScSheetLimits* CreateSheetLimits() +{ + const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions(); + if (rOpt.GetInitJumboSheets()) + return new ScSheetLimits(MAXCOL_JUMBO, MAXROW_JUMBO); + else + return new ScSheetLimits(MAXCOL, MAXROW); +} + ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mpCellStringPool(std::make_shared<svl::SharedStringPool>(*ScGlobal::getCharClassPtr())), mpDocLinkMgr(new sc::DocumentLinkManager(pDocShell)), @@ -101,13 +110,13 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mpPrinter( nullptr ), mpVirtualDevice_100th_mm( nullptr ), pFormatExchangeList( nullptr ), - mxSheetLimits(new ScSheetLimits(MAXCOL, MAXROW)), + mxSheetLimits(CreateSheetLimits()), pFormulaTree( nullptr ), pEOFormulaTree( nullptr ), pFormulaTrack( nullptr ), pEOFormulaTrack( nullptr ), pPreviewCellStyle( nullptr ), - maPreviewSelection(MAXROW, MAXCOL), + maPreviewSelection(*mxSheetLimits), nUnoObjectId( 0 ), nRangeOverflowType( 0 ), aCurTextWidthCalcPos(MaxCol(),0,0), @@ -170,12 +179,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mbDocShellRecalc(false), mnMutationGuardFlags(0) { - const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions(); - if (rOpt.GetInitJumboSheets()) - { - mxSheetLimits = new ScSheetLimits(MAXCOL_JUMBO, MAXROW_JUMBO); - } - maPreviewSelection = { MaxRow(), MaxCol() }; + maPreviewSelection = { *mxSheetLimits }; aCurTextWidthCalcPos = { MaxCol(), 0, 0 }; SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT); diff --git a/sc/source/core/data/markarr.cxx b/sc/source/core/data/markarr.cxx index 81481f2118f5..68fc09781a76 100644 --- a/sc/source/core/data/markarr.cxx +++ b/sc/source/core/data/markarr.cxx @@ -20,24 +20,27 @@ #include <markarr.hxx> #include <address.hxx> #include <rangelst.hxx> +#include <sheetlimits.hxx> #include <vector> #include <osl/diagnose.h> -ScMarkArray::ScMarkArray(SCROW nMaxRow) : - mnMaxRow( nMaxRow ) +ScMarkArray::ScMarkArray(const ScSheetLimits& rLimits) : + mrSheetLimits(rLimits) { Reset(false); } // Move constructor ScMarkArray::ScMarkArray( ScMarkArray&& rOther ) noexcept + : mrSheetLimits(rOther.mrSheetLimits) { operator=(std::move(rOther)); } // Copy constructor ScMarkArray::ScMarkArray( const ScMarkArray & rOther ) + : mrSheetLimits(rOther.mrSheetLimits) { operator=(rOther); } @@ -54,7 +57,7 @@ void ScMarkArray::Reset( bool bMarked, SCSIZE nNeeded ) assert(nNeeded); mvData.resize(1); mvData.reserve(nNeeded); - mvData[0].nRow = mnMaxRow; + mvData[0].nRow = mrSheetLimits.mnMaxRow; mvData[0].bMarked = bMarked; } @@ -104,9 +107,9 @@ bool ScMarkArray::GetMark( SCROW nRow ) const void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ) { - if (ValidRow(nStartRow, mnMaxRow) && ValidRow(nEndRow, mnMaxRow)) + if (mrSheetLimits.ValidRow(nStartRow) && mrSheetLimits.ValidRow(nEndRow)) { - if ((nStartRow == 0) && (nEndRow == mnMaxRow)) + if ((nStartRow == 0) && (nEndRow == mrSheetLimits.mnMaxRow)) { Reset(bMarked); } @@ -123,7 +126,7 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ) Search( nStartRow, nIndex ); ni = nIndex; - nInsert = MAXROWCOUNT; + nInsert = mrSheetLimits.GetMaxRowCount(); if ( mvData[ni].bMarked != bMarked ) { if ( ni == 0 || (mvData[ni-1].nRow < nStartRow - 1) ) @@ -140,7 +143,7 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ) if ( ni > 0 && mvData[ni-1].bMarked == bMarked ) { // combine mvData[ni-1].nRow = nEndRow; - nInsert = MAXROWCOUNT; + nInsert = mrSheetLimits.GetMaxRowCount(); bCombined = true; } } @@ -167,7 +170,7 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ) else if ( ni == nInsert ) mvData[ni-1].nRow = nStartRow - 1; // shrink } - nInsert = MAXROWCOUNT; + nInsert = mrSheetLimits.GetMaxRowCount(); bCombined = true; } else if ( ni > 0 && ni == nInsert ) @@ -180,7 +183,7 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ) mvData[ni].nRow = nEndRow; mvData[ni].bMarked = bMarked; ni++; - nInsert = MAXROWCOUNT; + nInsert = mrSheetLimits.GetMaxRowCount(); } if ( ni < nj ) { // remove entries @@ -188,7 +191,7 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ) } } - if ( nInsert < sal::static_int_cast<SCSIZE>(MAXROWCOUNT) ) + if ( nInsert < sal::static_int_cast<SCSIZE>(mrSheetLimits.GetMaxRowCount()) ) { // insert or append new entry if ( nInsert <= mvData.size() ) { @@ -240,7 +243,7 @@ bool ScMarkArray::HasOneMark( SCROW& rStartRow, SCROW& rEndRow ) const if ( mvData[0].bMarked ) { rStartRow = 0; - rEndRow = mnMaxRow; + rEndRow = mrSheetLimits.mnMaxRow; bRet = true; } } @@ -254,7 +257,7 @@ bool ScMarkArray::HasOneMark( SCROW& rStartRow, SCROW& rEndRow ) const else { rStartRow = mvData[0].nRow + 1; - rEndRow = mnMaxRow; + rEndRow = mrSheetLimits.mnMaxRow; } bRet = true; } @@ -278,21 +281,19 @@ bool ScMarkArray::operator==( const ScMarkArray& rOther ) const ScMarkArray& ScMarkArray::operator=( const ScMarkArray& rOther ) { mvData = rOther.mvData; - mnMaxRow = rOther.mnMaxRow; return *this; } ScMarkArray& ScMarkArray::operator=(ScMarkArray&& rOther) noexcept { mvData = std::move(rOther.mvData); - mnMaxRow = rOther.mnMaxRow; return *this; } SCROW ScMarkArray::GetNextMarked( SCROW nRow, bool bUp ) const { SCROW nRet = nRow; - if (ValidRow(nRow, mnMaxRow)) + if (mrSheetLimits.ValidRow(nRow)) { SCSIZE nIndex; Search(nRow, nIndex); @@ -333,7 +334,7 @@ SCROW ScMarkArray::GetMarkEnd( SCROW nRow, bool bUp ) const void ScMarkArray::Shift(SCROW nStartRow, long nOffset) { - if (nOffset == 0 || nStartRow > mnMaxRow) + if (nOffset == 0 || nStartRow > mrSheetLimits.mnMaxRow) return; for (size_t i=0; i < mvData.size(); ++i) @@ -347,9 +348,9 @@ void ScMarkArray::Shift(SCROW nStartRow, long nOffset) { rEntry.nRow = 0; } - else if (rEntry.nRow > mnMaxRow) + else if (rEntry.nRow > mrSheetLimits.mnMaxRow) { - rEntry.nRow = mnMaxRow; + rEntry.nRow = mrSheetLimits.mnMaxRow; } } } diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx index 6b8a99eb5237..d2983b25688a 100644 --- a/sc/source/core/data/markdata.cxx +++ b/sc/source/core/data/markdata.cxx @@ -32,13 +32,13 @@ #include <osl/diagnose.h> #include <mdds/flat_segment_tree.hpp> +#include <cassert> -ScMarkData::ScMarkData(SCROW nMaxRow, SCCOL nMaxCol) : +ScMarkData::ScMarkData(const ScSheetLimits& rSheetLimits) : maTabMarked(), - aMultiSel(nMaxRow), - mnMaxRow(nMaxRow), - mnMaxCol(nMaxCol) + aMultiSel(rSheetLimits), + mrSheetLimits(rSheetLimits) { ResetMark(); } @@ -47,6 +47,41 @@ ScMarkData::~ScMarkData() { } +ScMarkData& ScMarkData::operator=(const ScMarkData& rOther) +{ + maTabMarked = rOther.maTabMarked; + aMarkRange = rOther.aMarkRange; + aMultiRange = rOther.aMultiRange; + aMultiSel = rOther.aMultiSel; + aTopEnvelope = rOther.aTopEnvelope; + aBottomEnvelope = rOther.aBottomEnvelope; + aLeftEnvelope = rOther.aLeftEnvelope; + aRightEnvelope = rOther.aRightEnvelope; + bMarked = rOther.bMarked; + bMultiMarked = rOther.bMultiMarked; + bMarking = rOther.bMarking; + bMarkIsNeg = rOther.bMarkIsNeg; + return *this; +} + +ScMarkData& ScMarkData::operator=(ScMarkData&& rOther) +{ + maTabMarked = std::move(rOther.maTabMarked); + aMarkRange = std::move(rOther.aMarkRange); + aMultiRange = std::move(rOther.aMultiRange); + aMultiSel = std::move(rOther.aMultiSel); + aTopEnvelope = std::move(rOther.aTopEnvelope); + aBottomEnvelope = std::move(rOther.aBottomEnvelope); + aLeftEnvelope = std::move(rOther.aLeftEnvelope); + aRightEnvelope = std::move(rOther.aRightEnvelope); + bMarked = rOther.bMarked; + bMultiMarked = rOther.bMultiMarked; + bMarking = rOther.bMarking; + bMarkIsNeg = rOther.bMarkIsNeg; + return *this; +} + + void ScMarkData::ResetMark() { aMultiSel.Clear(); @@ -106,7 +141,7 @@ void ScMarkData::SetMultiMarkArea( const ScRange& rRange, bool bMark, bool bSetu PutInOrder( nStartRow, nEndRow ); PutInOrder( nStartCol, nEndCol ); - aMultiSel.SetMarkArea( ScSheetLimits(mnMaxCol, mnMaxRow), nStartCol, nEndCol, nStartRow, nEndRow, bMark ); + aMultiSel.SetMarkArea( nStartCol, nEndCol, nStartRow, nEndRow, bMark ); if ( bMultiMarked ) // Update aMultiRange { @@ -271,10 +306,10 @@ bool ScMarkData::IsColumnMarked( SCCOL nCol ) const if ( bMarked && !bMarkIsNeg && aMarkRange.aStart.Col() <= nCol && aMarkRange.aEnd.Col() >= nCol && - aMarkRange.aStart.Row() == 0 && aMarkRange.aEnd.Row() == mnMaxRow ) + aMarkRange.aStart.Row() == 0 && aMarkRange.aEnd.Row() == mrSheetLimits.mnMaxRow ) return true; - if ( bMultiMarked && aMultiSel.IsAllMarked( nCol, 0, mnMaxRow ) ) + if ( bMultiMarked && aMultiSel.IsAllMarked( nCol, 0, mrSheetLimits.mnMaxRow ) ) return true; return false; @@ -286,7 +321,7 @@ bool ScMarkData::IsRowMarked( SCROW nRow ) const //TODO: GetMarkRowRanges for completely marked rows if ( bMarked && !bMarkIsNeg && - aMarkRange.aStart.Col() == 0 && aMarkRange.aEnd.Col() == mnMaxCol && + aMarkRange.aStart.Col() == 0 && aMarkRange.aEnd.Col() == mrSheetLimits.mnMaxCol && aMarkRange.aStart.Row() <= nRow && aMarkRange.aEnd.Row() >= nRow ) return true; @@ -325,10 +360,9 @@ void ScMarkData::MarkFromRangeList( const ScRangeList& rList, bool bReset ) /** Optimise the case of constructing from a range list, speeds up import. */ -ScMarkData::ScMarkData(SCROW nMaxRow, SCCOL nMaxCol, const ScRangeList& rList) - : aMultiSel(nMaxRow), - mnMaxRow(nMaxRow), - mnMaxCol(nMaxCol) +ScMarkData::ScMarkData(const ScSheetLimits& rLimits, const ScRangeList& rList) + : aMultiSel(rLimits), + mrSheetLimits(rLimits) { ResetMark(); @@ -340,7 +374,7 @@ ScMarkData::ScMarkData(SCROW nMaxRow, SCCOL nMaxCol, const ScRangeList& rList) bMultiMarked = true; aMultiRange = rList.Combine(); - aMultiSel.Set( ScSheetLimits(mnMaxCol, mnMaxRow), rList ); + aMultiSel.Set( rList ); } else if (rList.size() == 1) { @@ -447,7 +481,7 @@ std::vector<sc::ColRowSpan> ScMarkData::GetMarkedRowSpans() const typedef mdds::flat_segment_tree<SCCOLROW, bool> SpansType; ScRangeList aRanges = GetMarkedRanges(); - SpansType aSpans(0, mnMaxRow+1, false); + SpansType aSpans(0, mrSheetLimits.mnMaxRow+1, false); SpansType::const_iterator itPos = aSpans.begin(); for (size_t i = 0, n = aRanges.size(); i < n; ++i) @@ -470,7 +504,7 @@ std::vector<sc::ColRowSpan> ScMarkData::GetMarkedColSpans() const { // Use segment tree to merge marked with multi marked. typedef mdds::flat_segment_tree<SCCOLROW, bool> SpansType; - SpansType aSpans(0, mnMaxCol+1, false); + SpansType aSpans(0, mrSheetLimits.mnMaxCol+1, false); SpansType::const_iterator itPos = aSpans.begin(); do { @@ -554,7 +588,7 @@ bool ScMarkData::IsAllMarked( const ScRange& rRange ) const SCROW nEndRow = rRange.aEnd.Row(); bool bOk = true; - if ( nStartCol == 0 && nEndCol == mnMaxCol ) + if ( nStartCol == 0 && nEndCol == mrSheetLimits.mnMaxCol ) return aMultiSel.IsRowRangeMarked( nStartRow, nEndRow ); for (SCCOL nCol=nStartCol; nCol<=nEndCol && bOk; nCol++) @@ -622,7 +656,7 @@ void ScMarkData::ShiftCols(const ScDocument* pDoc, SCCOL nStartCol, long nColOff } else if (bMultiMarked) { - aMultiSel.ShiftCols(pDoc->GetSheetLimits(), nStartCol, nColOffset); + aMultiSel.ShiftCols(nStartCol, nColOffset); aMultiRange.IncColIfNotLessThan(pDoc, nStartCol, nColOffset); } } @@ -667,13 +701,13 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) SCCOL nStartCol = aMultiRange.aStart.Col(), nEndCol = aMultiRange.aEnd.Col(); PutInOrder( nStartCol, nEndCol ); nStartCol = ( nStartCol == 0 ) ? nStartCol : nStartCol - 1; - nEndCol = ( nEndCol == mnMaxCol ) ? nEndCol : nEndCol + 1; + nEndCol = ( nEndCol == mrSheetLimits.mnMaxCol ) ? nEndCol : nEndCol + 1; std::unique_ptr<ScFlatBoolRowSegments> pPrevColMarkedRows; std::unique_ptr<ScFlatBoolRowSegments> pCurColMarkedRows; std::unordered_map<SCROW,ScFlatBoolColSegments> aRowToColSegmentsInTopEnvelope; std::unordered_map<SCROW,ScFlatBoolColSegments> aRowToColSegmentsInBottomEnvelope; - ScFlatBoolRowSegments aNoRowsMarked(mnMaxRow); - aNoRowsMarked.setFalse( 0, mnMaxRow ); + ScFlatBoolRowSegments aNoRowsMarked(mrSheetLimits.mnMaxRow); + aNoRowsMarked.setFalse( 0, mrSheetLimits.mnMaxRow ); bool bPrevColUnMarked = false; @@ -683,8 +717,8 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) bool bCurColUnMarked = !aMultiSel.HasMarks( nCol ); if ( !bCurColUnMarked ) { - pCurColMarkedRows.reset( new ScFlatBoolRowSegments(mnMaxRow) ); - pCurColMarkedRows->setFalse( 0, mnMaxRow ); + pCurColMarkedRows.reset( new ScFlatBoolRowSegments(mrSheetLimits.mnMaxRow) ); + pCurColMarkedRows->setFalse( 0, mrSheetLimits.mnMaxRow ); ScMultiSelIter aMultiIter( aMultiSel, nCol ); ScFlatBoolRowSegments::ForwardIterator aPrevItr( pPrevColMarkedRows ? *pPrevColMarkedRows @@ -773,22 +807,22 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) lcl_AddRanges( rRange, aAddRange ); // Top envelope auto it = aRowToColSegmentsInTopEnvelope.find(nTop - 1); if (it == aRowToColSegmentsInTopEnvelope.end()) - it = aRowToColSegmentsInTopEnvelope.emplace(nTop - 1, ScFlatBoolColSegments(mnMaxCol)).first; + it = aRowToColSegmentsInTopEnvelope.emplace(nTop - 1, ScFlatBoolColSegments(mrSheetLimits.mnMaxCol)).first; it->second.setTrue( nCol, nCol ); } - if( nBottom < mnMaxRow ) + if( nBottom < mrSheetLimits.mnMaxRow ) { ScRange aAddRange(nCol, nBottom + 1, aMultiRange.aStart.Tab(), nCol, nBottom + 1, aMultiRange.aStart.Tab()); lcl_AddRanges( rRange, aAddRange ); // Bottom envelope auto it = aRowToColSegmentsInBottomEnvelope.find(nBottom + 1); if (it == aRowToColSegmentsInBottomEnvelope.end()) - it = aRowToColSegmentsInBottomEnvelope.emplace(nBottom + 1, ScFlatBoolColSegments(mnMaxCol)).first; + it = aRowToColSegmentsInBottomEnvelope.emplace(nBottom + 1, ScFlatBoolColSegments(mrSheetLimits.mnMaxCol)).first; it->second.setTrue( nCol, nCol ); } } - while( nTopPrev <= mnMaxRow && nBottomPrev <= mnMaxRow && ( nCol > nStartCol ) ) + while( nTopPrev <= mrSheetLimits.mnMaxRow && nBottomPrev <= mrSheetLimits.mnMaxRow && ( nCol > nStartCol ) ) { bool bRangeMarked; const bool bHasValue = aPrevItr1.getValue( nTopPrev, bRangeMarked ); @@ -816,7 +850,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) bool bRangeMarked = false; ScFlatBoolRowSegments::ForwardIterator aPrevItr( pPrevColMarkedRows ? *pPrevColMarkedRows : aNoRowsMarked); - while( nTopPrev <= mnMaxRow && nBottomPrev <= mnMaxRow ) + while( nTopPrev <= mrSheetLimits.mnMaxRow && nBottomPrev <= mrSheetLimits.mnMaxRow ) { const bool bHasValue = aPrevItr.getValue(nTopPrev, bRangeMarked); assert(bHasValue); (void)bHasValue; @@ -892,12 +926,12 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) aTopEnvelope.push_back( ScRange( nCol1, nRow1 - 1, nTab1, nCol2, nRow1 - 1, nTab2 ) ); --nRow1New; } - if( nCol2 < mnMaxCol ) + if( nCol2 < mrSheetLimits.mnMaxCol ) { aRightEnvelope.push_back( ScRange( nCol2 + 1, nRow1, nTab1, nCol2 + 1, nRow2, nTab2 ) ); ++nCol2New; } - if( nRow2 < mnMaxRow ) + if( nRow2 < mrSheetLimits.mnMaxRow ) { aBottomEnvelope.push_back( ScRange( nCol1, nRow2 + 1, nTab1, nCol2, nRow2 + 1, nTab2 ) ); ++nRow2New; diff --git a/sc/source/core/data/markmulti.cxx b/sc/source/core/data/markmulti.cxx index b98872aaf0ec..f14999f542c7 100644 --- a/sc/source/core/data/markmulti.cxx +++ b/sc/source/core/data/markmulti.cxx @@ -27,9 +27,8 @@ #include <algorithm> -ScMultiSel::ScMultiSel(SCROW nMaxRow) - : aRowSel(nMaxRow), - mnMaxRow(nMaxRow) +ScMultiSel::ScMultiSel(const ScSheetLimits& rSheetLimits) + : aRowSel(rSheetLimits), mrSheetLimits(rSheetLimits) { } @@ -37,6 +36,21 @@ ScMultiSel::~ScMultiSel() { } +ScMultiSel& ScMultiSel::operator=(const ScMultiSel& rOther) +{ + aMultiSelContainer = rOther.aMultiSelContainer; + aRowSel = rOther.aRowSel; + return *this; +} + +ScMultiSel& ScMultiSel::operator=(ScMultiSel&& rOther) +{ + aMultiSelContainer = std::move(rOther.aMultiSelContainer); + aRowSel = std::move(rOther.aRowSel); + return *this; +} + + void ScMultiSel::Clear() { aMultiSelContainer.clear(); @@ -163,18 +177,18 @@ SCROW ScMultiSel::GetNextMarked( SCCOL nCol, SCROW nRow, bool bUp ) const return ( bUp ? nRow2 : nRow1 ); } -void ScMultiSel::MarkAllCols( const ScSheetLimits& rLimits, SCROW nStartRow, SCROW nEndRow ) +void ScMultiSel::MarkAllCols( SCROW nStartRow, SCROW nEndRow ) { - aMultiSelContainer.resize(rLimits.mnMaxCol+1, ScMarkArray(mnMaxRow)); - for ( SCCOL nCol = rLimits.mnMaxCol; nCol >= 0; --nCol ) + aMultiSelContainer.resize(mrSheetLimits.mnMaxCol+1, ScMarkArray(mrSheetLimits)); + for ( SCCOL nCol = mrSheetLimits.mnMaxCol; nCol >= 0; --nCol ) { aMultiSelContainer[nCol].SetMarkArea( nStartRow, nEndRow, true ); } } -void ScMultiSel::SetMarkArea( const ScSheetLimits& rLimits, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow, bool bMark ) +void ScMultiSel::SetMarkArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow, bool bMark ) { - if ( nStartCol == 0 && nEndCol == rLimits.mnMaxCol ) + if ( nStartCol == 0 && nEndCol == mrSheetLimits.mnMaxCol ) { aRowSel.SetMarkArea( nStartRow, nEndRow, bMark ); if ( !bMark ) @@ -200,30 +214,30 @@ void ScMultiSel::SetMarkArea( const ScSheetLimits& rLimits, SCCOL nStartCol, SCC else { nBeg = aRowSel.GetNextMarked( nStartRow, false ); - if ( nBeg != rLimits.GetMaxRowCount() ) + if ( nBeg != mrSheetLimits.GetMaxRowCount() ) nLast = aRowSel.GetMarkEnd( nBeg, false ); } - if ( nBeg != rLimits.GetMaxRowCount() && nLast >= nEndRow ) - MarkAllCols( rLimits, nBeg, nEndRow ); + if ( nBeg != mrSheetLimits.GetMaxRowCount() && nLast >= nEndRow ) + MarkAllCols( nBeg, nEndRow ); else { - while ( nBeg != rLimits.GetMaxRowCount() && nLast < nEndRow ) + while ( nBeg != mrSheetLimits.GetMaxRowCount() && nLast < nEndRow ) { - MarkAllCols( rLimits, nBeg, nLast ); + MarkAllCols( nBeg, nLast ); nBeg = aRowSel.GetNextMarked( nLast + 1, false ); - if ( nBeg != rLimits.GetMaxRowCount() ) + if ( nBeg != mrSheetLimits.GetMaxRowCount() ) nLast = aRowSel.GetMarkEnd( nBeg, false ); } - if ( nBeg != rLimits.GetMaxRowCount() && nLast >= nEndRow ) - MarkAllCols( rLimits, nBeg, nEndRow ); + if ( nBeg != mrSheetLimits.GetMaxRowCount() && nLast >= nEndRow ) + MarkAllCols( nBeg, nEndRow ); } aRowSel.SetMarkArea( nStartRow, nEndRow, false ); } if (nEndCol >= static_cast<SCCOL>(aMultiSelContainer.size())) - aMultiSelContainer.resize(nEndCol+1, ScMarkArray(mnMaxRow)); + aMultiSelContainer.resize(nEndCol+1, ScMarkArray(mrSheetLimits)); for ( SCCOL nColIter = nEndCol; nColIter >= nStartCol; --nColIter ) aMultiSelContainer[nColIter].SetMarkArea( nStartRow, nEndRow, bMark ); } @@ -232,7 +246,7 @@ void ScMultiSel::SetMarkArea( const ScSheetLimits& rLimits, SCCOL nStartCol, SCC optimised init-from-range-list. Specifically this is optimised for cases where we have very large data columns with lots and lots of ranges. */ -void ScMultiSel::Set( const ScSheetLimits& rLimits, ScRangeList const & rList ) +void ScMultiSel::Set( ScRangeList const & rList ) { Clear(); if (rList.size() == 0) @@ -246,7 +260,7 @@ void ScMultiSel::Set( const ScSheetLimits& rLimits, ScRangeList const & rList ) return lhs.aStart.Row() < rhs.aStart.Row(); }); - std::vector<std::vector<ScMarkEntry>> aMarkEntriesPerCol(rLimits.mnMaxCol+1); + std::vector<std::vector<ScMarkEntry>> aMarkEntriesPerCol(mrSheetLimits.mnMaxCol+1); SCCOL nMaxCol = -1; int i = 0; @@ -258,7 +272,7 @@ void ScMultiSel::Set( const ScSheetLimits& rLimits, ScRangeList const & rList ) SCROW nEndRow = rRange.aEnd.Row(); assert( nEndRow >= nStartRow && "this method assumes the input data has ranges with endrow>=startrow"); assert( nEndCol >= nStartCol && "this method assumes the input data has ranges with endcol>=startcol"); - if ( nStartCol == 0 && nEndCol == rLimits.mnMaxCol ) + if ( nStartCol == 0 && nEndCol == mrSheetLimits.mnMaxCol ) aRowSel.SetMarkArea( nStartRow, nEndRow, /*bMark*/true ); else { @@ -285,7 +299,7 @@ void ScMultiSel::Set( const ScSheetLimits& rLimits, ScRangeList const & rList ) ++i; } - aMultiSelContainer.resize(nMaxCol+1, ScMarkArray(mnMaxRow)); + aMultiSelContainer.resize(nMaxCol+1, ScMarkArray(mrSheetLimits)); for (SCCOL nCol = 0; nCol<=nMaxCol; ++nCol) if (!aMarkEntriesPerCol[nCol].empty()) { @@ -310,7 +324,7 @@ bool ScMultiSel::IsRowRangeMarked( SCROW nStartRow, SCROW nEndRow ) const ScMarkArray ScMultiSel::GetMarkArray( SCCOL nCol ) const { ScMultiSelIter aMultiIter( *this, nCol ); - ScMarkArray aMarkArray(mnMaxRow); + ScMarkArray aMarkArray(mrSheetLimits); SCROW nTop, nBottom; while( aMultiIter.Next( nTop, nBottom ) ) aMarkArray.SetMarkArea( nTop, nBottom, true ); @@ -327,9 +341,9 @@ bool ScMultiSel::HasAnyMarks() const return false; } -void ScMultiSel::ShiftCols(const ScSheetLimits& rLimits, SCCOL nStartCol, long nColOffset) +void ScMultiSel::ShiftCols(SCCOL nStartCol, long nColOffset) { - if (nStartCol > rLimits.mnMaxCol) + if (nStartCol > mrSheetLimits.mnMaxCol) return; ScMultiSel aNewMultiSel(*this); @@ -352,11 +366,11 @@ void ScMultiSel::ShiftCols(const ScSheetLimits& rLimits, SCCOL nStartCol, long n nDestCol += nColOffset; if (nDestCol < 0) nDestCol = 0; - else if (nDestCol > rLimits.mnMaxCol) - nDestCol = rLimits.mnMaxCol; + else if (nDestCol > mrSheetLimits.mnMaxCol) + nDestCol = mrSheetLimits.mnMaxCol; } if (nDestCol >= static_cast<SCCOL>(aMultiSelContainer.size())) - aMultiSelContainer.resize(nDestCol, ScMarkArray(mnMaxRow)); + aMultiSelContainer.resize(nDestCol, ScMarkArray(mrSheetLimits)); aMultiSelContainer[nDestCol] = aSourceArray; ++nCol; } @@ -372,7 +386,7 @@ void ScMultiSel::ShiftCols(const ScSheetLimits& rLimits, SCCOL nStartCol, long n rNewCol = rStartPos; rNewCol.Intersect(rPrevPos); if (nStartCol + nColOffset >= static_cast<SCCOL>(aNewMultiSel.aMultiSelContainer.size())) - aNewMultiSel.aMultiSelContainer.resize(nStartCol + nColOffset, ScMarkArray(mnMaxRow)); + aNewMultiSel.aMultiSelContainer.resize(nStartCol + nColOffset, ScMarkArray(mrSheetLimits)); for (long i = 1; i < nColOffset; ++i) aMultiSelContainer[nStartCol + i] = rNewCol; } @@ -407,8 +421,8 @@ ScMultiSelIter::ScMultiSelIter( const ScMultiSel& rMultiSel, SCCOL nCol ) : if (bHasMarks1 && bHasMarks2) { - pRowSegs.reset( new ScFlatBoolRowSegments(rMultiSel.mnMaxRow) ); - pRowSegs->setFalse( 0, rMultiSel.mnMaxRow ); + pRowSegs.reset( new ScFlatBoolRowSegments(rMultiSel.mrSheetLimits.mnMaxRow) ); + pRowSegs->setFalse( 0, rMultiSel.mrSheetLimits.mnMaxRow ); { ScMarkArrayIter aMarkIter( &rMultiSel.aRowSel ); SCROW nTop, nBottom; diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 869d255b2b47..75a4061ef784 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1454,7 +1454,7 @@ const ScRangeList* ScTable::GetScenarioRanges() const if (!pScenarioRanges) { const_cast<ScTable*>(this)->pScenarioRanges.reset(new ScRangeList); - ScMarkData aMark(pDocument->MaxRow(), pDocument->MaxCol()); + ScMarkData aMark(pDocument->GetSheetLimits()); MarkScenarioIn( aMark, ScScenarioFlags::NONE ); // always aMark.FillRangeListWithMarks( pScenarioRanges.get(), false ); } diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 2e445d0247ed..3a45a5f3be83 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1834,7 +1834,7 @@ void ScChangeActionContent::PutValueToDoc( aRange.aEnd.IncCol( nC-1 ); if ( nR > 1 ) aRange.aEnd.IncRow( nR-1 ); - ScMarkData aDestMark(pDoc->MaxRow(), pDoc->MaxCol()); + ScMarkData aDestMark(pDoc->GetSheetLimits()); aDestMark.SelectOneTable( aPos.Tab() ); aDestMark.SetMarkArea( aRange ); pDoc->InsertMatrixFormula( aPos.Col(), aPos.Row(), diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 42375c20d46f..d283d7d099c3 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -1281,7 +1281,7 @@ XclExpXct::XclExpXct( const XclExpRoot& rRoot, const OUString& rTabName, sal_uInt16 nSBTab, ScExternalRefCache::TableTypeRef const & xCacheTable ) : XclExpRoot( rRoot ), mxCacheTable( xCacheTable ), - maUsedCells( MAXROW, MAXCOL ), + maUsedCells( rRoot.GetDoc().GetSheetLimits() ), maBoundRange( ScAddress::INITIALIZE_INVALID ), maTabName( rTabName ), mnSBTab( nSBTab ) diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index b26e2b33b6a2..990a296383ff 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -567,7 +567,7 @@ bool ScAccessibleCell::IsDropdown() const if ( nTab+1<nTabCount && mpDoc->IsScenario(nTab+1) && !mpDoc->IsScenario(nTab) ) { SCTAB i; - ScMarkData aMarks(mpDoc->MaxRow(), mpDoc->MaxCol()); + ScMarkData aMarks(mpDoc->GetSheetLimits()); for (i=nTab+1; i<nTabCount && mpDoc->IsScenario(i); i++) mpDoc->MarkScenario( i, nTab, aMarks, false, ScScenarioFlags::ShowFrame ); ScRangeList aRanges; diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 912f956f930f..289217103785 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -646,7 +646,7 @@ ScDocShell* ScTransferObj::GetSourceDocShell() ScMarkData ScTransferObj::GetSourceMarkData() const { - ScMarkData aMarkData(m_pDoc->MaxRow(), m_pDoc->MaxCol()); + ScMarkData aMarkData(m_pDoc->GetSheetLimits()); ScCellRangesBase* pRangesObj = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( m_xDragSourceRanges ); if (pRangesObj) { @@ -671,7 +671,7 @@ void ScTransferObj::InitDocShell(bool bLimitToPageSize) pDocSh->DoInitNew(); ScDocument& rDestDoc = pDocSh->GetDocument(); - ScMarkData aDestMark(rDestDoc.MaxRow(), rDestDoc.MaxCol()); + ScMarkData aDestMark(rDestDoc.GetSheetLimits()); aDestMark.SelectTable( 0, true ); rDestDoc.SetDocOptions( m_pDoc->GetDocOptions() ); // #i42666# diff --git a/sc/source/ui/dataprovider/dataprovider.cxx b/sc/source/ui/dataprovider/dataprovider.cxx index 817ffce44236..8ad2ee0cf38d 100644 --- a/sc/source/ui/dataprovider/dataprovider.cxx +++ b/sc/source/ui/dataprovider/dataprovider.cxx @@ -237,7 +237,7 @@ void ScDBDataManager::WriteToDoc(ScDocument& rDoc) SCROW nRowSize = std::min<SCROW>(aDestRange.aEnd.Row() - aDestRange.aStart.Row(), nEndRow); aDestRange.aEnd.SetRow(aDestRange.aStart.Row() + nRowSize); - ScMarkData aMark(mpDoc->MaxRow(), mpDoc->MaxCol()); + ScMarkData aMark(mpDoc->GetSheetLimits()); aMark.SelectTable(0, true); mpDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &rDoc); ScDocShell* pDocShell = static_cast<ScDocShell*>(mpDoc->GetDocumentShell()); diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx index b0e6c81f6243..a07b5573d8d5 100644 --- a/sc/source/ui/docshell/arealink.cxx +++ b/sc/source/ui/docshell/arealink.cxx @@ -375,7 +375,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter, { ScRange const & rTokenRange( aSourceRanges[nRange]); SCTAB nSrcTab = rTokenRange.aStart.Tab(); - ScMarkData aSourceMark(rSrcDoc.MaxRow(), rSrcDoc.MaxCol()); + ScMarkData aSourceMark(rSrcDoc.GetSheetLimits()); aSourceMark.SelectOneTable( nSrcTab ); // selecting for CopyToClip aSourceMark.SetMarkArea( rTokenRange ); @@ -395,7 +395,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter, aNewTokenRange.aEnd.SetCol( aNewTokenRange.aStart.Col() + (rTokenRange.aEnd.Col() - rTokenRange.aStart.Col()) ); aNewTokenRange.aEnd.SetRow( aNewTokenRange.aStart.Row() + (rTokenRange.aEnd.Row() - rTokenRange.aStart.Row()) ); - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); aDestMark.SelectOneTable( nDestTab ); aDestMark.SetMarkArea( aNewTokenRange ); rDoc.CopyFromClip( aNewTokenRange, aDestMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, false ); diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 352c77f619e9..6247132508d4 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -836,7 +836,7 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam, aOldForm.aEnd.SetRow( aOldDest.aEnd.Row() ); rDoc.FitBlock( aOldForm, aNewForm, false ); - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SelectOneTable(nDestTab); SCROW nFStartY = aLocalParam.nRow1 + ( aLocalParam.bHasHeader ? 1 : 0 ); diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index 76d8333cdc78..c4960acce7b4 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -471,7 +471,7 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, pUndoDBData.reset(new ScDBData( *pDBData )); } - ScMarkData aNewMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aNewMark(rDoc.GetSheetLimits()); aNewMark.SelectOneTable( nTab ); if (bRecord) @@ -535,7 +535,7 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, nEndCol+nFormulaCols, nEndRow, nTab, InsertDeleteFlags::ATTRIB, false, rDoc); // fill formulas - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SelectOneTable(nTab); sal_uLong nProgCount = nFormulaCols; diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index c66ddeb06a9e..f3a1f3d795ee 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -1188,7 +1188,7 @@ void ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, aPattern.GetItemSet().ClearItem( ATTR_HOR_JUSTIFY ); // wasn't removed above if no edit object if ( aPattern.GetItemSet().Count() > 0 ) { - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SelectTable( rPos.Tab(), true ); aMark.SetMarkArea( ScRange( rPos ) ); ApplyAttributes( aMark, aPattern, bApi ); @@ -1762,7 +1762,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, if (bRecord && !rDoc.IsUndoEnabled()) bRecord = false; - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -2267,7 +2267,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, if (!rDoc.IsUndoEnabled()) bRecord = false; - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -2849,7 +2849,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, ScDocumentUniquePtr pClipDoc(new ScDocument(SCDOCMODE_CLIP)); - ScMarkData aSourceMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aSourceMark(rDoc.GetSheetLimits()); for (nTab=nStartTab; nTab<=nEndTab; nTab++) aSourceMark.SelectTable( nTab, true ); // select source aSourceMark.SetMarkArea( rSource ); @@ -2970,7 +2970,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, bool bSourceHeight = false; // adjust heights? if (bCut) { - ScMarkData aDelMark(rDoc.MaxRow(), rDoc.MaxCol()); // only for tables + ScMarkData aDelMark(rDoc.GetSheetLimits()); // only for tables for (nTab=nStartTab; nTab<=nEndTab; nTab++) { rDoc.DeleteAreaTab( nStartCol,nStartRow, nOldEndCol,nOldEndRow, nTab, InsertDeleteFlags::ALL ); @@ -3005,7 +3005,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, ScRange aPasteDest( nDestCol, nDestRow, nDestTab, nDestEndCol, nDestEndRow, nDestEndTab ); - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); for (nTab=nDestTab; nTab<=nDestEndTab; nTab++) aDestMark.SelectTable( nTab, true ); // select destination aDestMark.SetMarkArea( aPasteDest ); @@ -3755,7 +3755,7 @@ bool ScDocFunc::SetWidthOrHeight( if (bRecord) { - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SelectOneTable( nTab ); rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoWidthOrHeight>( @@ -4191,7 +4191,7 @@ bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark, bool bRecord = true; if (!rDoc.IsUndoEnabled()) bRecord = false; - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -4305,7 +4305,7 @@ bool ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark, SCROW nEndRow = rRange.aEnd.Row(); SCTAB nEndTab = rRange.aEnd.Tab(); - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -4392,7 +4392,7 @@ bool ScDocFunc::TabOp( const ScRange& rRange, const ScMarkData* pTabMark, if (bRecord && !rDoc.IsUndoEnabled()) bRecord = false; - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -4536,7 +4536,7 @@ bool ScDocFunc::FillSimple( const ScRange& rRange, const ScMarkData* pTabMark, if (!rDoc.IsUndoEnabled()) bRecord = false; - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -4649,7 +4649,7 @@ bool ScDocFunc::FillSeries( const ScRange& rRange, const ScMarkData* pTabMark, if (!rDoc.IsUndoEnabled()) bRecord = false; - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -4782,7 +4782,7 @@ bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir e if (bRecord && !rDoc.IsUndoEnabled()) bRecord = false; - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); if (pTabMark) aMark = *pTabMark; else @@ -5461,7 +5461,7 @@ void ScDocFunc::ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd aFormula = aFormula.copy(1, aFormula.getLength()-2); - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SetMarkArea( rOldRange ); aMark.SelectTable( nTab, true ); ScRange aNewRange( rOldRange.aStart, rNewEnd ); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index f2d80f1d5bf9..a305a1b5bc12 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1601,7 +1601,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) m_aDocument.GetCellArea( nTab, nEndCol, nEndRow ); aColWidthRange.aEnd.SetCol( nEndCol ); aColWidthRange.aEnd.SetRow( nEndRow ); - ScMarkData aMark(m_aDocument.MaxRow(), m_aDocument.MaxCol()); + ScMarkData aMark(m_aDocument.GetSheetLimits()); aMark.SetMarkArea( aColWidthRange ); aMark.MarkToMulti(); diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 0e29619f582b..2df6f6ec9b8f 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -441,7 +441,7 @@ void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore ) if ( nUpdateTab >= nTabCount ) nUpdateTab = nTabCount-1; // nUpdateTab is inclusive - ScMarkData aUpdateSheets(m_aDocument.MaxRow(), m_aDocument.MaxCol()); + ScMarkData aUpdateSheets(m_aDocument.GetSheetLimits()); SCTAB nTab; for (nTab=0; nTab<=nUpdateTab; ++nTab) if ( m_aDocument.IsPendingRowHeights( nTab ) ) @@ -680,7 +680,7 @@ void ScDocShell::UseScenario( SCTAB nTab, const OUString& rName, bool bRecord ) if ( m_aDocument.TestCopyScenario( nSrcTab, nTab ) ) // test cell protection { ScDocShellModificator aModificator( *this ); - ScMarkData aScenMark(m_aDocument.MaxRow(), m_aDocument.MaxCol()); + ScMarkData aScenMark(m_aDocument.GetSheetLimits()); m_aDocument.MarkScenario( nSrcTab, nTab, aScenMark ); ScRange aMultiRange; aScenMark.GetMultiMarkArea( aMultiRange ); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 7912d7ec389a..50ce540eb893 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -262,7 +262,7 @@ void ScImportExport::EndPaste(bool bAutoRowHeight) ScDocumentUniquePtr pRedoDoc(new ScDocument( SCDOCMODE_UNDO )); pRedoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aEnd.Tab() ); pDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL | InsertDeleteFlags::NOCAPTIONS, false, *pRedoDoc); - ScMarkData aDestMark(pRedoDoc->MaxRow(), pRedoDoc->MaxCol()); + ScMarkData aDestMark(pRedoDoc->GetSheetLimits()); aDestMark.SetMarkArea(aRange); pDocSh->GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPaste>(pDocSh, aRange, aDestMark, std::move(pUndoDoc), std::move(pRedoDoc), InsertDeleteFlags::ALL, nullptr)); @@ -1949,7 +1949,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) pDoc->CheckLinkFormulaNeedingCheck(*xCode); if ( ch == 'M' ) { - ScMarkData aMark(pDoc->MaxRow(), pDoc->MaxCol()); + ScMarkData aMark(pDoc->GetSheetLimits()); aMark.SelectTable( aPos.Tab(), true ); pDoc->InsertMatrixFormula( nCol, nRow, nRefCol, nRefRow, aMark, EMPTY_OUSTRING, xCode.get() ); diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx index 7da2e6128493..a41a64b8a684 100644 --- a/sc/source/ui/drawfunc/futext3.cxx +++ b/sc/source/ui/drawfunc/futext3.cxx @@ -160,7 +160,7 @@ void FuText::StopEditMode() // Make sure the former area of the note anchor is invalidated. ScRangeList aRangeList(aNotePos); - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol(), aRangeList); + ScMarkData aMarkData(rDoc.GetSheetLimits(), aRangeList); rViewShell.UpdateSelectionArea(aMarkData); } else if( bNewNote || bDeleteNote ) diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 7feaee017a33..7675f7c93f6a 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -1188,7 +1188,7 @@ static bool lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, ScDra bool bDisallow = true; ScDocument& rSrcDoc = pSrcShell->GetDocument(); - ScMarkData aMark(rSrcDoc.MaxRow(), rSrcDoc.MaxCol()); + ScMarkData aMark(rSrcDoc.GetSheetLimits()); aMark.SelectTable( rRange.aStart.Tab(), true ); aMark.SetMarkArea( rRange ); diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index d9f89078e6e6..b9145c286ecd 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -464,7 +464,7 @@ void ScUndoDeleteCells::DoChange( const bool bUndo ) aWorkRange.aEnd.SetCol(rDoc.MaxCol()); if ( eCmd==DelCellCmd::Rows || eCmd==DelCellCmd::CellsUp ) aWorkRange.aEnd.SetRow(rDoc.MaxRow()); - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); aMarkData.SelectOneTable( aWorkRange.aStart.Tab() ); ScPatternAttr aPattern( rDoc.GetPool() ); aPattern.GetItemSet().Put( ScMergeFlagAttr() ); @@ -1082,7 +1082,7 @@ void ScUndoPaste::DoChange(bool bUndo) ScRange& rDrawRange = aDrawRanges[i]; rDoc.ExtendMerge(rDrawRange, true); // only needed for single sheet (text/rtf etc.) ScRangeList aRangeList(rDrawRange); - ScMarkData aData(rDoc.MaxRow(), rDoc.MaxCol(), aRangeList); + ScMarkData aData(rDoc.GetSheetLimits(), aRangeList); if (bPaintAll) { rDrawRange.aStart.SetCol(0); @@ -1407,7 +1407,7 @@ void ScUndoDragDrop::Redo() of drawing undo actions. */ SCTAB nTab; - ScMarkData aSourceMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aSourceMark(rDoc.GetSheetLimits()); for (nTab=aSrcRange.aStart.Tab(); nTab<=aSrcRange.aEnd.Tab(); nTab++) aSourceMark.SelectTable( nTab, true ); @@ -1426,7 +1426,7 @@ void ScUndoDragDrop::Redo() PaintArea( aSrcPaintRange, nExtFlags ); } - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); for (nTab=aDestRange.aStart.Tab(); nTab<=aDestRange.aEnd.Tab(); nTab++) aDestMark.SelectTable( nTab, true ); @@ -1916,7 +1916,7 @@ void ScUndoEnterMatrix::Redo() ScDocument& rDoc = pDocShell->GetDocument(); - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); aDestMark.SelectOneTable( aBlockRange.aStart.Tab() ); aDestMark.SetMarkArea( aBlockRange ); @@ -2364,7 +2364,7 @@ void ScUndoBorder::Undo() BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); aMarkData.MarkFromRangeList(*xRanges, false); xUndoDoc->CopyToDocument(aBlockRange, InsertDeleteFlags::ATTRIB, true, rDoc, &aMarkData); pDocShell->PostPaint( aBlockRange, PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE ); @@ -2383,7 +2383,7 @@ void ScUndoBorder::Redo() ScRange const & rRange = (*xRanges)[i]; SCTAB nTab = rRange.aStart.Tab(); - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SetMarkArea( rRange ); aMark.SelectTable( nTab, true ); diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index a386cbd6db0e..f08e420a4ad8 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -859,7 +859,7 @@ void ScUndoAutoFormat::Redo() sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, pVirtDev); for (SCTAB nTab=nStartZ; nTab<=nEndZ; nTab++) { - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); aDestMark.SelectOneTable( nTab ); aDestMark.SetMarkArea( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) ); aDestMark.MarkToMulti(); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 856736b275b1..e173c2550910 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1075,7 +1075,7 @@ void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& r rDoc.CopyToDocument(rRange, InsertDeleteFlags::ATTRIB, false, *pUndoDoc); } - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SetMarkArea( rRange ); aMark.SelectTable( nTab, true ); @@ -1216,7 +1216,7 @@ static bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, if ( pUndoDoc ) { - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); aDestMark.SelectOneTable( nTab ); rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPaste>( @@ -1313,7 +1313,7 @@ static bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange, if ( pUndoDoc ) { - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); aDestMark.SelectOneTable( nTab ); rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPaste>( &rDocShell, @@ -1527,7 +1527,7 @@ const ScMarkData* ScCellRangesBase::GetMarkData() { if (!pMarkData) { - pMarkData.reset( new ScMarkData(GetDocument()->MaxRow(), GetDocument()->MaxCol(), aRanges) ); + pMarkData.reset( new ScMarkData(GetDocument()->GetSheetLimits(), aRanges) ); } return pMarkData.get(); } @@ -2455,7 +2455,7 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE SvxBoxInfoItem aInner(ATTR_BORDER_INNER); ScDocument& rDoc = pDocShell->GetDocument(); - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SetMarkArea( rFirst ); aMark.SelectTable( rFirst.aStart.Tab(), true ); rDoc.GetSelectionFrame( aMark, aOuter, aInner ); @@ -3417,7 +3417,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC { ScDocument& rDoc = pDocShell->GetDocument(); - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); // select matching cells for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i ) @@ -3506,7 +3506,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaC { ScDocument& rDoc = pDocShell->GetDocument(); - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); // select matching cells for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i ) @@ -3560,7 +3560,7 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl( size_t nRangeCount = aRanges.size(); size_t i; ScDocument& rDoc = pDocShell->GetDocument(); - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); SCCOLROW nCmpPos = bColumnDiff ? static_cast<SCCOLROW>(aCompare.Row) : static_cast<SCCOLROW>(aCompare.Column); @@ -3690,7 +3690,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPreceden bFound = false; // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); aMarkData.MarkFromRangeList( aNewRanges, false ); aMarkData.MarkToMulti(); // needed for IsAllMarked @@ -3739,7 +3739,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependen bFound = false; // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); aMarkData.MarkFromRangeList( aNewRanges, false ); aMarkData.MarkToMulti(); // needed for IsAllMarked @@ -4173,7 +4173,7 @@ void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress aNotSheetRanges.push_back( rRanges[ i ] ); } } - ScMarkData aMarkData(GetDocument()->MaxRow(), GetDocument()->MaxCol()); + ScMarkData aMarkData(GetDocument()->GetSheetLimits()); aMarkData.MarkFromRangeList( aSheetRanges, false ); ScRange aRange(static_cast<SCCOL>(rRange.StartColumn), static_cast<SCROW>(rRange.StartRow), @@ -4326,7 +4326,7 @@ static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries, if ( (nParse & ( ScRefFlags::VALID | ScRefFlags::TAB_3D )) == ( ScRefFlags::VALID | ScRefFlags::TAB_3D )) { - ScMarkData aMarkData(pDocSh->GetDocument().MaxRow(), pDocSh->GetDocument().MaxCol()); + ScMarkData aMarkData(pDocSh->GetDocument().GetSheetLimits()); aMarkData.MarkFromRangeList( rRanges, false ); aMarkData.MarkToMulti(); // needed for IsAllMarked if ( aMarkData.IsAllMarked( aCellRange ) ) @@ -4344,7 +4344,7 @@ static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries, // test if named entry is contained in rRanges const ScRange& rComp = rNamedEntry.GetRange(); - ScMarkData aMarkData(pDocSh->GetDocument().MaxRow(), pDocSh->GetDocument().MaxCol()); + ScMarkData aMarkData(pDocSh->GetDocument().GetSheetLimits()); aMarkData.MarkFromRangeList( rRanges, false ); aMarkData.MarkToMulti(); // needed for IsAllMarked if ( aMarkData.IsAllMarked( rComp ) ) @@ -4393,7 +4393,7 @@ void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName ) } if ( bValid ) { - ScMarkData aMarkData(GetDocument()->MaxRow(), GetDocument()->MaxCol()); + ScMarkData aMarkData(GetDocument()->GetSheetLimits()); aMarkData.MarkFromRangeList( rRanges, false ); for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ ) @@ -4886,7 +4886,7 @@ void ScCellRangeObj::SetArrayFormula_Impl(const OUString& rFormula, else { // empty string -> erase array formula - ScMarkData aMark(GetDocument()->MaxRow(), GetDocument()->MaxCol()); + ScMarkData aMark(GetDocument()->GetSheetLimits()); aMark.SetMarkArea( aRange ); aMark.SelectTable( aRange.aStart.Tab(), true ); pDocSh->GetDocFunc().DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, true ); @@ -4961,7 +4961,7 @@ void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::Formula else { // empty sequence -> erase array formula - ScMarkData aMark(pDocSh->GetDocument().MaxRow(), pDocSh->GetDocument().MaxCol()); + ScMarkData aMark(pDocSh->GetDocument().GetSheetLimits()); aMark.SetMarkArea( aRange ); aMark.SelectTable( aRange.aStart.Tab(), true ); pDocSh->GetDocFunc().DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, true ); @@ -7703,7 +7703,7 @@ void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAd if (rDoc.IsScenario(nTab)) { - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); aMarkData.SelectTable( nTab, true ); for (const table::CellRangeAddress& rRange : rScenRanges) @@ -8746,7 +8746,7 @@ void ScCellsEnumeration::CheckPos_Impl() { if (!pMark) { - pMark.reset( new ScMarkData(rDoc.MaxRow(), rDoc.MaxCol()) ); + pMark.reset( new ScMarkData(rDoc.GetSheetLimits()) ); pMark->MarkFromRangeList(aRanges, false); pMark->MarkToMulti(); // needed for GetNextMarkedCell } @@ -8770,7 +8770,7 @@ void ScCellsEnumeration::Advance_Impl() OSL_ENSURE(!bAtEnd,"too much Advance_Impl"); if (!pMark) { - pMark.reset( new ScMarkData(pDocShell->GetDocument().MaxRow(), pDocShell->GetDocument().MaxCol()) ); + pMark.reset( new ScMarkData(pDocShell->GetDocument().GetSheetLimits()) ); pMark->MarkFromRangeList( aRanges, false ); pMark->MarkToMulti(); // needed for GetNextMarkedCell } diff --git a/sc/source/ui/unoobj/cursuno.cxx b/sc/source/ui/unoobj/cursuno.cxx index 6f18ed237c76..b9b7bcb310b6 100644 --- a/sc/source/ui/unoobj/cursuno.cxx +++ b/sc/source/ui/unoobj/cursuno.cxx @@ -338,7 +338,7 @@ void SAL_CALL ScCellCursorObj::gotoNext() aOneRange.PutInOrder(); ScAddress aCursor(aOneRange.aStart); // always use start of block - ScMarkData aMark(GetDocument()->MaxRow(), GetDocument()->MaxCol()); // not used with bMarked=FALSE + ScMarkData aMark(GetDocument()->GetSheetLimits()); // not used with bMarked=FALSE SCCOL nNewX = aCursor.Col(); SCROW nNewY = aCursor.Row(); SCTAB nTab = aCursor.Tab(); @@ -360,7 +360,7 @@ void SAL_CALL ScCellCursorObj::gotoPrevious() aOneRange.PutInOrder(); ScAddress aCursor(aOneRange.aStart); // always use start of block - ScMarkData aMark(GetDocument()->MaxRow(), GetDocument()->MaxCol()); // not used with bMarked=FALSE + ScMarkData aMark(GetDocument()->GetSheetLimits()); // not used with bMarked=FALSE SCCOL nNewX = aCursor.Col(); SCROW nNewY = aCursor.Row(); SCTAB nTab = aCursor.Tab(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 276a2bd42dbf..4592bdb9c04d 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1572,7 +1572,7 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection, static_cast< sheet::XSpreadsheetDocument* >(this) ); } - ScMarkData aMark(GetDocument()->MaxRow(), GetDocument()->MaxCol()); + ScMarkData aMark(GetDocument()->GetSheetLimits()); ScPrintSelectionStatus aStatus; OUString aPagesStr; bool bRenderToGraphic = false; @@ -1662,7 +1662,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 static_cast< sheet::XSpreadsheetDocument* >(this) ); } - ScMarkData aMark(pDocShell->GetDocument().MaxRow(), pDocShell->GetDocument().MaxCol()); + ScMarkData aMark(pDocShell->GetDocument().GetSheetLimits()); ScPrintSelectionStatus aStatus; OUString aPagesStr; // #i115266# if FillRenderMarkData fails, keep nTotalPages at 0, but still handle getRenderer(0) below @@ -1909,7 +1909,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec static_cast< sheet::XSpreadsheetDocument* >(this) ); } - ScMarkData aMark(pDocShell->GetDocument().MaxRow(), pDocShell->GetDocument().MaxCol()); + ScMarkData aMark(pDocShell->GetDocument().GetSheetLimits()); ScPrintSelectionStatus aStatus; OUString aPagesStr; bool bRenderToGraphic = false; @@ -3085,7 +3085,7 @@ void ScModelObj::NotifyChanges( const OUString& rOperation, const ScRangeList& r //! separate method with ScMarkData? Then change HasChangesListeners back. if ( rOperation == "cell-change" && pDocShell ) { - ScMarkData aMarkData(pDocShell->GetDocument().MaxRow(), pDocShell->GetDocument().MaxCol()); + ScMarkData aMarkData(pDocShell->GetDocument().GetSheetLimits()); aMarkData.MarkFromRangeList( rRanges, false ); ScDocument& rDoc = pDocShell->GetDocument(); SCTAB nTabCount = rDoc.GetTableCount(); @@ -4453,7 +4453,7 @@ void SAL_CALL ScAnnotationsObj::removeByIndex( sal_Int32 nIndex ) ScAddress aPos; if ( GetAddressByIndex_Impl( nIndex, aPos ) ) { - ScMarkData aMarkData(pDocShell->GetDocument().MaxRow(), pDocShell->GetDocument().MaxCol()); + ScMarkData aMarkData(pDocShell->GetDocument().GetSheetLimits()); aMarkData.SelectTable( aPos.Tab(), true ); aMarkData.SetMultiMarkArea( ScRange(aPos) ); @@ -4584,7 +4584,7 @@ void SAL_CALL ScScenariosObj::addNewByName( const OUString& aName, SolarMutexGuard aGuard; if ( pDocShell ) { - ScMarkData aMarkData(pDocShell->GetDocument().MaxRow(), pDocShell->GetDocument().MaxCol()); + ScMarkData aMarkData(pDocShell->GetDocument().GetSheetLimits()); aMarkData.SelectTable( nTab, true ); for (const table::CellRangeAddress& rRange : aRanges) diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 3d7774e40944..7725567f42e6 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -146,7 +146,7 @@ static bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange, nDestTab ) ); ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP )); - ScMarkData aSourceMark(pSrcDoc->MaxRow(), pSrcDoc->MaxCol()); + ScMarkData aSourceMark(pSrcDoc->GetSheetLimits()); aSourceMark.SelectOneTable( nSrcTab ); // for CopyToClip aSourceMark.SetMarkArea( rSrcRange ); ScClipParam aClipParam(rSrcRange, false); @@ -161,7 +161,7 @@ static bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange, pClipDoc->ApplyPatternAreaTab( 0,0, pClipDoc->MaxCol(), pClipDoc->MaxRow(), nSrcTab, aPattern ); } - ScMarkData aDestMark(pDestDoc->MaxRow(), pDestDoc->MaxCol()); + ScMarkData aDestMark(pDestDoc->GetSheetLimits()); aDestMark.SelectOneTable( nDestTab ); aDestMark.SetMarkArea( aNewRange ); pDestDoc->CopyFromClip( aNewRange, aDestMark, InsertDeleteFlags::ALL & ~InsertDeleteFlags::FORMULA, nullptr, pClipDoc.get(), false ); diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 403ea1c2f1d5..546ff7871c71 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -5308,7 +5308,7 @@ ScVbaRange::setStyle( const uno::Any& _style ) uno::Reference< excel::XRange > ScVbaRange::PreviousNext( bool bIsPrevious ) { - ScMarkData markedRange(getScDocument().MaxRow(), getScDocument().MaxCol()); + ScMarkData markedRange(getScDocument().GetSheetLimits()); ScRange refRange; RangeHelper thisRange( mxRange ); diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 5e6e384433c5..be76009bc351 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -503,7 +503,7 @@ void ScVbaWorksheets::PrintPreview( const css::uno::Any& /*EnableChanges*/ ) ScPreviewShell* pPrvShell = static_cast< ScPreviewShell* >( pShell ); ScPreview* pPrvView = pPrvShell->GetPreview(); const ScDocument& rDoc = *pViewShell->GetViewData().GetDocument(); - ScMarkData aMarkData(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMarkData(rDoc.GetSheetLimits()); sal_Int32 nElems = getCount(); for ( sal_Int32 nItem = 1; nItem <= nElems; ++nItem ) { diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 0ee0cc1b2f9d..8d4fe45c1e0c 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2466,7 +2466,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) ScViewData* pData = GetViewData(); ScMarkData& rMark = pData->GetMarkData(); ScDocument* pDoc = pData->GetDocument(); - ScMarkData aNewMark(pDoc->MaxRow(), pDoc->MaxCol()); + ScMarkData aNewMark(pDoc->GetSheetLimits()); ScRangeList aRangeList; for (auto const& rTab : rMark.GetSelectedTabs()) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 284fc13a29a8..f6422cfb6ab5 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5401,7 +5401,7 @@ bool ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRang //! cache the Ranges in Table!!!! - ScMarkData aMarks(pDoc->MaxRow(), pDoc->MaxCol()); + ScMarkData aMarks(pDoc->GetSheetLimits()); for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) pDoc->MarkScenario( i, nTab, aMarks, false, ScScenarioFlags::ShowFrame ); ScRangeList aRanges; diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 8c60a5c9efc3..b0cac0658201 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -197,7 +197,7 @@ static void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, S //! cache the ranges in table!!!! - ScMarkData aMarks(pDoc->MaxRow(), pDoc->MaxCol()); + ScMarkData aMarks(pDoc->GetSheetLimits()); for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) pDoc->MarkScenario( i, nTab, aMarks, false, ScScenarioFlags::ShowFrame ); ScRangeListRef xRanges = new ScRangeList; diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 0fddf7862b82..4d92510d3257 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -727,12 +727,14 @@ ScSplitPos ScViewDataTable::SanitizeWhichActive() const return eWhichActive; } +static const ScSheetLimits gaNoShellSheetLimits(MAXCOL, MAXROW); + ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ) : nPPTX(0.0), nPPTY(0.0), mpMarkData(pDocSh? - new ScMarkData(pDocSh->GetDocument().MaxRow(), pDocSh->GetDocument().MaxCol()) : - new ScMarkData(MAXROW, MAXCOL) + new ScMarkData(pDocSh->GetDocument().GetSheetLimits()) : + new ScMarkData(gaNoShellSheetLimits) ), pDocShell ( pDocSh ), pDoc ( nullptr ), diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 135b621e6c4f..ef0501afc469 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -142,7 +142,7 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow, rDoc.CopyToDocument( nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, InsertDeleteFlags::ALL|InsertDeleteFlags::NOCAPTIONS, false, *pRedoDoc ); ScRange aMarkRange(nStartCol, nStartRow, nTab, nStartCol, nEndRow, nTab); - ScMarkData aDestMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aDestMark(rDoc.GetSheetLimits()); aDestMark.SetMarkArea( aMarkRange ); pDocSh->GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPaste>( pDocSh, aMarkRange, aDestMark, diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index 7aa96e344dbb..4b576632b407 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -140,7 +140,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId, if (!rSrcDoc.HasTable(nSrcTab)) nSrcTab = 0; - ScMarkData aSrcMark(rSrcDoc.MaxRow(), rSrcDoc.MaxCol()); + ScMarkData aSrcMark(rSrcDoc.GetSheetLimits()); aSrcMark.SelectOneTable( nSrcTab ); // for CopyToClip ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP )); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index d70b2742b6f6..af5090441068 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -213,7 +213,7 @@ void ScViewFunc::DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab, if ( !pSource->GetItem(ATTR_MERGE).IsMerged() ) { ScRange aRange( nCol, nRow, nTab, nCol, nRow, nTab ); - ScMarkData aMark(rDoc.MaxRow(), rDoc.MaxCol()); + ScMarkData aMark(rDoc.GetSheetLimits()); aMark.SetMarkArea( aRange ); ScDocFunc &rFunc = GetViewData().GetDocFunc(); @@ -548,7 +548,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt32 nFormat = pFormatter->GetStandardFormat( SvNumFormatType::NUMBER, nLang); ScPatternAttr aPattern( pDoc->GetPool()); aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nFormat)); - ScMarkData aMark(pDoc->MaxRow(), pDoc->MaxCol()); + ScMarkData aMark(pDoc->GetSheetLimits()); aMark.SelectTable( i, true); aMark.SetMarkArea( ScRange( aPos)); rFunc.ApplyAttributes( aMark, aPattern, false); |