diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-24 12:29:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-24 13:29:01 +0200 |
commit | 78f63c2b1cd4e185f11486a7b2bdf7fd89ef1b03 (patch) | |
tree | 87db1c93e1e13d55162194cd6d7563126548e592 | |
parent | 27246b94029373c1678335122b8d074eacefc43b (diff) |
sc: rowcol: tdf#50916 convert column*
Change-Id: I6ed03ba9c8e1ae9f6837730fd5579f83198dc7b1
Reviewed-on: https://gerrit.libreoffice.org/81440
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/inc/columnspanset.hxx | 10 | ||||
-rw-r--r-- | sc/inc/externalrefmgr.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/bcaslot.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 39 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 30 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/column4.cxx | 22 | ||||
-rw-r--r-- | sc/source/core/data/columnspanset.cxx | 24 | ||||
-rw-r--r-- | sc/source/core/data/documen6.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/listenercontext.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 10 |
12 files changed, 82 insertions, 81 deletions
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx index c75502f8bde8..99a99ee935c0 100644 --- a/sc/inc/columnspanset.hxx +++ b/sc/inc/columnspanset.hxx @@ -64,7 +64,7 @@ private: std::vector<std::unique_ptr<TableType>> maTables; bool const mbInit; - ColumnType& getColumn(SCTAB nTab, SCCOL nCol); + ColumnType& getColumn(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol); public: class Action @@ -89,11 +89,11 @@ public: const ColumnSpanSet& operator=(const ColumnSpanSet&) = delete; ~ColumnSpanSet(); - void set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal); - void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal); - void set(const ScRange& rRange, bool bVal); + void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal); + void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal); + void set(const ScDocument& rDoc, const ScRange& rRange, bool bVal); - void set( SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal ); + void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal ); /** * Scan specified range in a specified sheet and mark all non-empty cells diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx index 085c2ebb0115..c041983c3ea4 100644 --- a/sc/inc/externalrefmgr.hxx +++ b/sc/inc/externalrefmgr.hxx @@ -255,7 +255,7 @@ public: * cached data, not the cached range metadata stored separately in the * Table. */ - void getAllCachedDataSpans( sal_uInt16 nFileId, sc::ColumnSpanSet& rSet ) const; + void getAllCachedDataSpans( const ScDocument& rSrcDoc, sal_uInt16 nFileId, sc::ColumnSpanSet& rSet ) const; bool getSrcDocTable( const ScDocument& rSrcDoc, const OUString& rTabName, SCTAB& rTab, sal_uInt16 nFileId ) const; diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 0e56dc3f3600..614145b7bc06 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -1085,7 +1085,7 @@ void ScBroadcastAreaSlotMachine::InsertBulkGroupArea( ScBroadcastArea* pArea, co sc::ColumnSpanSet *const pSet = it->second.get(); assert(pSet); - pSet->set(rRange, true); + pSet->set(*pDoc, rRange, true); } bool ScBroadcastAreaSlotMachine::BulkBroadcastGroupAreas( SfxHintId nHintId ) diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index ce924354cd47..d1b10c128344 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -433,7 +433,7 @@ SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& if (!bFound) return -1; - else if (nTop==0 && nBottom==MAXROW) + else if (nTop==0 && nBottom==GetDoc()->MaxRow()) return 0; else return nBottom; @@ -836,7 +836,7 @@ bool ScColumn::TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const // See if there would be any non-empty cell that gets pushed out. // Find the position of the last non-empty cell below nStartRow. - size_t nLastNonEmptyRow = MAXROW; + size_t nLastNonEmptyRow = GetDoc()->MaxRow(); sc::CellStoreType::const_reverse_iterator it = maCells.rbegin(); if (it->type == sc::element_type_empty) nLastNonEmptyRow -= it->size; @@ -845,7 +845,7 @@ bool ScColumn::TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const // No cells would get pushed out. return pAttrArray->TestInsertRow(nSize); - if (nLastNonEmptyRow + nSize > static_cast<size_t>(MAXROW)) + if (nLastNonEmptyRow + nSize > static_cast<size_t>(GetDoc()->MaxRow())) // At least one cell would get pushed out. Not good. return false; @@ -878,6 +878,7 @@ namespace { class CopyToClipHandler { + const ScDocument& mrSrcDoc; const ScColumn& mrSrcCol; ScColumn& mrDestCol; sc::ColumnBlockPosition maDestPos; @@ -891,8 +892,8 @@ class CopyToClipHandler } public: - CopyToClipHandler(const ScColumn& rSrcCol, ScColumn& rDestCol, sc::ColumnBlockPosition* pDestPos) : - mrSrcCol(rSrcCol), mrDestCol(rDestCol), mpDestPos(pDestPos) + CopyToClipHandler(const ScDocument& rSrcDoc, const ScColumn& rSrcCol, ScColumn& rDestCol, sc::ColumnBlockPosition* pDestPos) : + mrSrcDoc(rSrcDoc), mrSrcCol(rSrcCol), mrDestCol(rDestCol), mpDestPos(pDestPos) { if (mpDestPos) maDestPos = *mpDestPos; @@ -982,7 +983,7 @@ public: maDestPos.miCellPos = aPos.first; sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); size_t nLastRow = nTopRow + nDataSize; - if (nLastRow < static_cast<size_t>(MAXROW)) + if (nLastRow < static_cast<size_t>(mrSrcDoc.MaxRow())) { aPos = rDestCells.position(maDestPos.miCellPos, nLastRow+1); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); @@ -1034,7 +1035,7 @@ void ScColumn::CopyToClip( rCxt.isKeepScenarioFlags() ? (ScMF::All & ~ScMF::Scenario) : ScMF::All ); { - CopyToClipHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol)); + CopyToClipHandler aFunc(*GetDoc(), *this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol)); sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2); } @@ -1749,8 +1750,8 @@ void ScColumn::UndoToColumn( CopyToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, rColumn); //TODO: bMarked ???? - if (nRow2 < MAXROW) - CopyToColumn(rCxt, nRow2+1, MAXROW, InsertDeleteFlags::FORMULA, false, rColumn); + if (nRow2 < GetDoc()->MaxRow()) + CopyToColumn(rCxt, nRow2+1, GetDoc()->MaxRow(), InsertDeleteFlags::FORMULA, false, rColumn); } void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const @@ -1767,7 +1768,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const sc::SingleColumnSpanSet::SpansType aRanges; aRangeSet.getSpans(aRanges); - CopyToClipHandler aFunc(*this, rDestCol, nullptr); + CopyToClipHandler aFunc(*GetDoc(), *this, rDestCol, nullptr); sc::CellStoreType::const_iterator itPos = maCells.begin(); for (const auto& rRange : aRanges) itPos = sc::ParseBlock(itPos, maCells, aFunc, rRange.mnRow1, rRange.mnRow2); @@ -1779,7 +1780,7 @@ void ScColumn::CopyScenarioFrom( const ScColumn& rSrcCol ) { // This is the scenario table, the data is copied into it ScDocument* pDocument = GetDoc(); - ScAttrIterator aAttrIter( pAttrArray.get(), 0, MAXROW, pDocument->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc()->MaxRow(), pDocument->GetDefPattern() ); SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) @@ -1808,7 +1809,7 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const { // This is the scenario table, the data is copied to the other ScDocument* pDocument = GetDoc(); - ScAttrIterator aAttrIter( pAttrArray.get(), 0, MAXROW, pDocument->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc()->MaxRow(), pDocument->GetDefPattern() ); SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) @@ -1833,7 +1834,7 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const bool ScColumn::TestCopyScenarioTo( const ScColumn& rDestCol ) const { bool bOk = true; - ScAttrIterator aAttrIter( pAttrArray.get(), 0, MAXROW, GetDoc()->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc()->MaxRow(), GetDoc()->GetDefPattern() ); SCROW nStart = 0, nEnd = 0; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern && bOk) @@ -1851,7 +1852,7 @@ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const { ScRange aRange( nCol, 0, nTab ); - ScAttrIterator aAttrIter( pAttrArray.get(), 0, MAXROW, GetDoc()->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc()->MaxRow(), GetDoc()->GetDefPattern() ); SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) @@ -1955,8 +1956,8 @@ void ScColumn::SwapCol(ScColumn& rCol) std::swap( mnBlkCountFormula, rCol.mnBlkCountFormula); // notes update caption - UpdateNoteCaptions(0, MAXROW); - rCol.UpdateNoteCaptions(0, MAXROW); + UpdateNoteCaptions(0, GetDoc()->MaxRow()); + rCol.UpdateNoteCaptions(0, GetDoc()->MaxRow()); std::swap(pAttrArray, rCol.pAttrArray); @@ -2007,7 +2008,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) // move the notes to the destination column maCellNotes.transfer(nStartRow, nEndRow, rCol.maCellNotes, nStartRow); - UpdateNoteCaptions(0, MAXROW); + UpdateNoteCaptions(0, GetDoc()->MaxRow()); // Re-group transferred formula cells. aPos = rCol.maCells.position(nStartRow); @@ -2441,7 +2442,7 @@ bool ScColumn::UpdateReferenceOnCopy( sc::RefUpdateContext& rCxt, ScDocument* pU // The formula groups at the top and bottom boundaries are expected to // have been split prior to this call. Here, we only do the joining. sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); - if (rCxt.maRange.aEnd.Row() < MAXROW) + if (rCxt.maRange.aEnd.Row() < GetDoc()->MaxRow()) { aPos = maCells.position(aPos.first, rCxt.maRange.aEnd.Row()+1); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); @@ -2831,7 +2832,7 @@ public: maValueRanges.getSpans(aSpans); for (const auto& rSpan : aSpans) - rBroadcastSpans.set(nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); + rBroadcastSpans.set(*mrColumn.GetDoc(), nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); } }; diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 5e62a01f38a1..dfcee81cdde0 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -646,7 +646,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( } else // "Select" the entire column if no selection exists. - aMarkedSpans.emplace_back(0, MAXROW); + aMarkedSpans.emplace_back(0, GetDoc()->MaxRow()); sal_uInt16 nWidth = static_cast<sal_uInt16>(nOldWidth*nPPTX); bool bFound = false; @@ -990,7 +990,7 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& r nRow = rData.GetNextMarked(nCol, nRow, false); if (!ValidRow(nRow)) { - nRow = MAXROW+1; + nRow = GetDoc()->MaxRow()+1; bStop = true; } else @@ -1018,7 +1018,7 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& r } else { - nRow = MAXROW+1; + nRow = GetDoc()->MaxRow()+1; bStop = true; } } @@ -1296,15 +1296,15 @@ SCROW ScColumn::GetLastDataPos() const sc::CellStoreType::const_reverse_iterator it = maCells.rbegin(); if (it->type != sc::element_type_empty) - return MAXROW; + return GetDoc()->MaxRow(); - return MAXROW - static_cast<SCROW>(it->size); + return GetDoc()->MaxRow() - static_cast<SCROW>(it->size); } SCROW ScColumn::GetLastDataPos( SCROW nLastRow, bool bConsiderCellNotes, bool bConsiderCellDrawObjects ) const { - sc::CellStoreType::const_position_type aPos = maCells.position(std::min(nLastRow,MAXROW)); + sc::CellStoreType::const_position_type aPos = maCells.position(std::min(nLastRow,GetDoc()->MaxRow())); if (bConsiderCellNotes && !IsNotesEmptyBlock(nLastRow, nLastRow)) return nLastRow; @@ -1468,14 +1468,14 @@ SCROW ScColumn::FindNextVisibleRow(SCROW nRow, bool bForward) const SCROW nEndRow = 0; bool bHidden = GetDoc()->RowHidden(nRow, nTab, nullptr, &nEndRow); if(bHidden) - return std::min<SCROW>(MAXROW, nEndRow + 1); + return std::min<SCROW>(GetDoc()->MaxRow(), nEndRow + 1); else return nRow; } else { nRow--; - SCROW nStartRow = MAXROW; + SCROW nStartRow = GetDoc()->MaxRow(); bool bHidden = GetDoc()->RowHidden(nRow, nTab, &nStartRow); if(bHidden) return std::max<SCROW>(0, nStartRow - 1); @@ -1498,15 +1498,15 @@ SCROW ScColumn::FindNextVisibleRowWithContent( if (bHidden) { nRow = nEndRow + 1; - if(nRow >= MAXROW) - return MAXROW; + if(nRow >= GetDoc()->MaxRow()) + return GetDoc()->MaxRow(); } std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(itPos, nRow); itPos = aPos.first; if (itPos == maCells.end()) // Invalid row. - return MAXROW; + return GetDoc()->MaxRow(); if (itPos->type != sc::element_type_empty) return nRow; @@ -1514,15 +1514,15 @@ SCROW ScColumn::FindNextVisibleRowWithContent( // Move to the last cell of the current empty block. nRow += itPos->size - aPos.second - 1; } - while (nRow < MAXROW); + while (nRow < GetDoc()->MaxRow()); - return MAXROW; + return GetDoc()->MaxRow(); } do { nRow--; - SCROW nStartRow = MAXROW; + SCROW nStartRow = GetDoc()->MaxRow(); bool bHidden = pDocument->RowHidden(nRow, nTab, &nStartRow); if (bHidden) { @@ -3409,7 +3409,7 @@ void ScColumn::UpdateSelectionFunction( // Exclude all hidden rows. ScFlatBoolRowSegments::RangeData aRange; SCROW nRow = 0; - while (nRow <= MAXROW) + while (nRow <= GetDoc()->MaxRow()) { if (!rHiddenRows.getRangeData(nRow, aRange)) break; diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 7f2edb925d96..90a0dcec43aa 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -145,7 +145,7 @@ void ScColumn::Delete( SCROW nRow ) void ScColumn::FreeAll() { - // Keep a logical empty range of 0-MAXROW at all times. + // Keep a logical empty range of 0-rDoc.MaxRow() at all times. maCells.clear(); maCells.resize(MAXROWCOUNT); maCellTextAttrs.clear(); @@ -206,7 +206,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* // Check if there are any cells below the end row that will get shifted. bool bShiftCells = false; - if (nEndRow < MAXROW) //only makes sense to do this if there *is* a row after the end row + if (nEndRow < GetDoc()->MaxRow()) //only makes sense to do this if there *is* a row after the end row { aPos = maCells.position(itCell, nEndRow+1); itCell = aPos.first; @@ -229,7 +229,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* // Mark all non-empty cell positions below the end row. sc::ColumnBlockConstPosition aBlockPos; aBlockPos.miCellPos = itCell; - aNonEmptySpans.scan(aBlockPos, *this, nEndRow+1, MAXROW); + aNonEmptySpans.scan(aBlockPos, *this, nEndRow+1, GetDoc()->MaxRow()); } sc::AutoCalcSwitch aACSwitch(*GetDoc(), false); @@ -243,7 +243,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* // Shift the formula cell positions below the start row. ShiftFormulaPosHandler aShiftFormulaFunc; - sc::ProcessFormula(aPos.first, maCells, nStartRow, MAXROW, aShiftFormulaFunc); + sc::ProcessFormula(aPos.first, maCells, nStartRow, GetDoc()->MaxRow(), aShiftFormulaFunc); bool bJoined = sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); if (bJoined && pGroupPos) @@ -577,7 +577,7 @@ sc::CellStoreType::iterator ScColumn::GetPositionToInsert( const sc::CellStoreTy sc::CellStoreType::position_type aPosBefore = maCells.position(maCells.begin(), nRow-1); lcl_AddFormulaGroupBoundaries(aPosBefore, rNewSharedRows); } - if (nRow < MAXROW) + if (nRow < GetDoc()->MaxRow()) { sc::CellStoreType::position_type aPosAfter = maCells.position(maCells.begin(), nRow+1); lcl_AddFormulaGroupBoundaries(aPosAfter, rNewSharedRows); @@ -996,7 +996,7 @@ void ScColumn::DeleteArea( sc::SingleColumnSpanSet::SpansType aSpans; aDeletedRows.getSpans(aSpans); for (const auto& rSpan : aSpans) - pBroadcastSpans->set(nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); + pBroadcastSpans->set(*GetDoc(), nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); } } diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index ccaf177f5140..ed8608e6b750 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -161,7 +161,7 @@ void ScColumn::DeleteBeforeCopyFromClip( { sc::SingleColumnSpanSet aDeletedRows; DeleteCells(aBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows); - rBroadcastSpans.set(nTab, nCol, aDeletedRows, true); + rBroadcastSpans.set(*GetDoc(), nTab, nCol, aDeletedRows, true); } if (nDelFlag & InsertDeleteFlags::NOTE) @@ -313,7 +313,7 @@ void ScColumn::SetValues( const SCROW nRow, const std::vector<double>& rVals ) return; SCROW nLastRow = nRow + rVals.size() - 1; - if (nLastRow > MAXROW) + if (nLastRow > GetDoc()->MaxRow()) // Out of bound. Do nothing. return; @@ -343,7 +343,7 @@ void ScColumn::TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rD return; SCROW nLastRow = nRow + nLen - 1; - if (nLastRow > MAXROW) + if (nLastRow > GetDoc()->MaxRow()) // Out of bound. Do nothing. return; @@ -368,7 +368,7 @@ void ScColumn::CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc ) return; SCROW nLastRow = nRow + rSrc.size() - 1; - if (nLastRow > MAXROW) + if (nLastRow > GetDoc()->MaxRow()) // Out of bound. Do nothing return; @@ -436,7 +436,7 @@ void ScColumn::ConvertFormulaToValue( std::vector<SCROW> aBounds; aBounds.push_back(nRow1); - if (nRow2 < MAXROW-1) + if (nRow2 < GetDoc()->MaxRow()-1) aBounds.push_back(nRow2+1); // Split formula cell groups at top and bottom boundaries (if applicable). @@ -497,7 +497,7 @@ void ScColumn::SwapNonEmpty( const ScRange& rRange = rValues.getRange(); std::vector<SCROW> aBounds; aBounds.push_back(rRange.aStart.Row()); - if (rRange.aEnd.Row() < MAXROW-1) + if (rRange.aEnd.Row() < GetDoc()->MaxRow()-1) aBounds.push_back(rRange.aEnd.Row()+1); // Split formula cell groups at top and bottom boundaries (if applicable). @@ -715,7 +715,7 @@ class NoteEntryCollector SCROW const mnEndRow; public: NoteEntryCollector( std::vector<sc::NoteEntry>& rNotes, SCTAB nTab, SCCOL nCol, - SCROW nStartRow = 0, SCROW nEndRow = MAXROW) : + SCROW nStartRow, SCROW nEndRow) : mrNotes(rNotes), mnTab(nTab), mnCol(nCol), mnStartRow(nStartRow), mnEndRow(nEndRow) {} @@ -747,7 +747,7 @@ public: void ScColumn::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const { - std::for_each(maCellNotes.begin(), maCellNotes.end(), NoteEntryCollector(rNotes, nTab, nCol)); + std::for_each(maCellNotes.begin(), maCellNotes.end(), NoteEntryCollector(rNotes, nTab, nCol, 0, GetDoc()->MaxRow())); } void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow, @@ -1187,7 +1187,7 @@ public: void ScColumn::SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange ) { - if (rBoundRange.aStart.Row() >= MAXROW) + if (rBoundRange.aStart.Row() >= GetDoc()->MaxRow()) // Nothing to split. return; @@ -1195,7 +1195,7 @@ void ScColumn::SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange ) // Cut at row boundaries first. aBounds.push_back(rBoundRange.aStart.Row()); - if (rBoundRange.aEnd.Row() < MAXROW) + if (rBoundRange.aEnd.Row() < GetDoc()->MaxRow()) aBounds.push_back(rBoundRange.aEnd.Row()+1); sc::SharedFormulaUtil::splitFormulaCellGroups(maCells, aBounds); @@ -1280,7 +1280,7 @@ bool ScColumn::HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const if (nRow2 < nRow1 || !ValidRow(nRow1) || !ValidRow(nRow2)) return false; - if (nRow1 == 0 && nRow2 == MAXROW) + if (nRow1 == 0 && nRow2 == GetDoc()->MaxRow()) return HasFormulaCell(); FindAnyFormula aFunc; diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx index 7cc3e7c9e982..fe4408a58494 100644 --- a/sc/source/core/data/columnspanset.cxx +++ b/sc/source/core/data/columnspanset.cxx @@ -62,7 +62,7 @@ ColumnSpanSet::~ColumnSpanSet() { } -ColumnSpanSet::ColumnType& ColumnSpanSet::getColumn(SCTAB nTab, SCCOL nCol) +ColumnSpanSet::ColumnType& ColumnSpanSet::getColumn(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol) { if (static_cast<size_t>(nTab) >= maTables.size()) maTables.resize(nTab+1); @@ -75,47 +75,47 @@ ColumnSpanSet::ColumnType& ColumnSpanSet::getColumn(SCTAB nTab, SCCOL nCol) rTab.resize(nCol+1); if (!rTab[nCol]) - rTab[nCol].reset(new ColumnType(0, MAXROW, mbInit)); + rTab[nCol].reset(new ColumnType(0, rDoc.MaxRow(), mbInit)); return *rTab[nCol]; } -void ColumnSpanSet::set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal) +void ColumnSpanSet::set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal) { if (!ValidTab(nTab) || !ValidCol(nCol) || !ValidRow(nRow)) return; - ColumnType& rCol = getColumn(nTab, nCol); + ColumnType& rCol = getColumn(rDoc, nTab, nCol); rCol.miPos = rCol.maSpans.insert(rCol.miPos, nRow, nRow+1, bVal).first; } -void ColumnSpanSet::set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal) +void ColumnSpanSet::set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal) { if (!ValidTab(nTab) || !ValidCol(nCol) || !ValidRow(nRow1) || !ValidRow(nRow2)) return; - ColumnType& rCol = getColumn(nTab, nCol); + ColumnType& rCol = getColumn(rDoc, nTab, nCol); rCol.miPos = rCol.maSpans.insert(rCol.miPos, nRow1, nRow2+1, bVal).first; } -void ColumnSpanSet::set(const ScRange& rRange, bool bVal) +void ColumnSpanSet::set(const ScDocument& rDoc, const ScRange& rRange, bool bVal) { for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab) { for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol) { - ColumnType& rCol = getColumn(nTab, nCol); + ColumnType& rCol = getColumn(rDoc, nTab, nCol); rCol.miPos = rCol.maSpans.insert(rCol.miPos, rRange.aStart.Row(), rRange.aEnd.Row()+1, bVal).first; } } } -void ColumnSpanSet::set( SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal ) +void ColumnSpanSet::set( const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal ) { SingleColumnSpanSet::SpansType aSpans; rSingleSet.getSpans(aSpans); for (const auto& rSpan : aSpans) - set(nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, bVal); + set(rDoc, nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, bVal); } void ColumnSpanSet::scan( @@ -134,7 +134,7 @@ void ColumnSpanSet::scan( nCol2 = pTab->ClampToAllocatedColumns(nCol2); for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) { - ColumnType& rCol = getColumn(nTab, nCol); + ColumnType& rCol = getColumn(rDoc, nTab, nCol); const CellStoreType& rSrcCells = pTab->aCol[nCol].maCells; @@ -328,7 +328,7 @@ void SingleColumnSpanSet::swap( SingleColumnSpanSet& r ) bool SingleColumnSpanSet::empty() const { - // Empty if there's only the 0..MAXROW span with false. + // Empty if there's only the 0..rDoc.MaxRow() span with false. ColumnSpansType::const_iterator it = maSpans.begin(); return (it->first == 0) && !(it->second) && (++it != maSpans.end()) && (it->first == MAXROWCOUNT); } diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx index 7845ef2c60f4..789f26c2c009 100644 --- a/sc/source/core/data/documen6.cxx +++ b/sc/source/core/data/documen6.cxx @@ -199,7 +199,7 @@ SvtScriptType ScDocument::GetRangeScriptType( const ScRangeList& rRanges ) SCROW nRow1 = rRange.aStart.Row(); SCROW nRow2 = rRange.aEnd.Row(); for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol) - aSet.set(nTab, nCol, nRow1, nRow2, true); + aSet.set(*this, nTab, nCol, nRow1, nRow2, true); } ScriptTypeAggregator aAction(*this); diff --git a/sc/source/core/data/listenercontext.cxx b/sc/source/core/data/listenercontext.cxx index 85871ac91d30..46f0ecb5cc27 100644 --- a/sc/source/core/data/listenercontext.cxx +++ b/sc/source/core/data/listenercontext.cxx @@ -65,7 +65,7 @@ ColumnBlockPosition* EndListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCo void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow) { - maSet.set(nTab, nCol, nRow, true); + maSet.set(mrDoc, nTab, nCol, nRow, true); } void EndListeningContext::purgeEmptyBroadcasters() diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index ec92abad27e4..f26f3d086e34 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1198,7 +1198,7 @@ void ScTable::SortReorderByRowRefUpdate( if (!aMoveRange.Intersects(aRange)) { // Doesn't overlap with the sorted range at all. - aGrpListenerRanges.set(aRange, true); + aGrpListenerRanges.set(GetDoc(), aRange, true); continue; } @@ -1206,7 +1206,7 @@ void ScTable::SortReorderByRowRefUpdate( { // Its column range is within the column range of the sorted range. expandRowRange(aRange, aMoveRange.aStart.Row(), aMoveRange.aEnd.Row()); - aGrpListenerRanges.set(aRange, true); + aGrpListenerRanges.set(GetDoc(), aRange, true); continue; } @@ -1230,8 +1230,8 @@ void ScTable::SortReorderByRowRefUpdate( expandRowRange(aR1, aMoveRange.aStart.Row(), aMoveRange.aEnd.Row()); } - aGrpListenerRanges.set(aR1, true); - aGrpListenerRanges.set(aR2, true); + aGrpListenerRanges.set(GetDoc(), aR1, true); + aGrpListenerRanges.set(GetDoc(), aR2, true); } } diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index fc85ad791e4f..96d159a42c1a 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -1227,7 +1227,7 @@ void ScExternalRefCache::addCacheDocToReferenced( sal_uInt16 nFileId ) } } -void ScExternalRefCache::getAllCachedDataSpans( sal_uInt16 nFileId, sc::ColumnSpanSet& rSet ) const +void ScExternalRefCache::getAllCachedDataSpans( const ScDocument& rSrcDoc, sal_uInt16 nFileId, sc::ColumnSpanSet& rSet ) const { const DocItem* pDocItem = getDocItem(nFileId); if (!pDocItem) @@ -1249,7 +1249,7 @@ void ScExternalRefCache::getAllCachedDataSpans( sal_uInt16 nFileId, sc::ColumnSp pTab->getAllCols(nRow, aCols); for (SCCOL nCol : aCols) { - rSet.set(nTab, nCol, nRow, true); + rSet.set(rSrcDoc, nTab, nCol, nRow, true); } } } @@ -2886,9 +2886,6 @@ public: bool ScExternalRefManager::refreshSrcDocument(sal_uInt16 nFileId) { - sc::ColumnSpanSet aCachedArea(false); - maRefCache.getAllCachedDataSpans(nFileId, aCachedArea); - OUString aFilter; SfxObjectShellRef xDocShell; try @@ -2904,6 +2901,9 @@ bool ScExternalRefManager::refreshSrcDocument(sal_uInt16 nFileId) ScDocShell& rDocSh = static_cast<ScDocShell&>(*xDocShell); ScDocument& rSrcDoc = rDocSh.GetDocument(); + sc::ColumnSpanSet aCachedArea(false); + maRefCache.getAllCachedDataSpans(rSrcDoc, nFileId, aCachedArea); + // Clear the existing cache, and refill it. Make sure we keep the // existing cache table instances here. maRefCache.clearCacheTables(nFileId); |