sc/inc/table.hxx | 8 sc/source/core/data/documen2.cxx | 12 - sc/source/core/data/document.cxx | 20 +- sc/source/core/data/documentimport.cxx | 2 sc/source/core/data/table1.cxx | 176 +++++++++---------- sc/source/core/data/table2.cxx | 300 ++++++++++++++++----------------- sc/source/core/data/table3.cxx | 74 ++++---- sc/source/core/data/table4.cxx | 64 +++---- sc/source/core/data/table5.cxx | 40 ++-- sc/source/core/data/table6.cxx | 40 ++-- sc/source/core/data/table7.cxx | 18 - 11 files changed, 377 insertions(+), 377 deletions(-)
New commits: commit b979802fc92c8386fa35893f3c620082cec8fbde Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Sep 15 12:01:50 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Sep 16 14:22:01 2020 +0200 ScTable ctor never called with a null ScDocument* Change-Id: I183fd26df45ddd4e7432833c5c77b07b64e03609 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102842 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index f938ea9009fb..3e15695567cd 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -199,7 +199,7 @@ private: mutable SCROW nTableAreaY; SCTAB nTab; - ScDocument* pDocument; + ScDocument& rDocument; std::unique_ptr<utl::TextSearch> pSearchText; mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName @@ -266,14 +266,14 @@ friend class sc::EditTextIterator; friend class sc::FormulaGroupAreaListener; public: - ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, + ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName, bool bColInfo = true, bool bRowInfo = true ); ~ScTable() COVERITY_NOEXCEPT_FALSE; ScTable(const ScTable&) = delete; ScTable& operator=(const ScTable&) = delete; - ScDocument& GetDoc() { return *pDocument;} - const ScDocument& GetDoc() const { return *pDocument;} + ScDocument& GetDoc() { return rDocument;} + const ScDocument& GetDoc() const { return rDocument;} SCTAB GetTab() const { return nTab; } ScOutlineTable* GetOutlineTable() { return pOutlineTable.get(); } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 3e08ae45a35d..6015aa596b55 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -495,7 +495,7 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks ) OUString aString = pSourceDoc->maTabs[i]->GetName(); if ( i < static_cast<SCTAB>(maTabs.size()) ) { - maTabs[i].reset( new ScTable(this, i, aString) ); + maTabs[i].reset( new ScTable(*this, i, aString) ); } else @@ -504,7 +504,7 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks ) { maTabs.resize(i); } - maTabs.emplace_back(new ScTable(this, i, aString)); + maTabs.emplace_back(new ScTable(*this, i, aString)); } maTabs[i]->SetLayoutRTL( pSourceDoc->maTabs[i]->IsLayoutRTL() ); } @@ -524,7 +524,7 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB nTab ) { maTabs.resize(nTab+1); } - maTabs[nTab].reset( new ScTable(this, nTab, "baeh") ); + maTabs[nTab].reset( new ScTable(*this, nTab, "baeh") ); if (nTab < static_cast<SCTAB>(pSourceDoc->maTabs.size()) && pSourceDoc->maTabs[nTab]) maTabs[nTab]->SetLayoutRTL( pSourceDoc->maTabs[nTab]->IsLayoutRTL() ); } @@ -541,7 +541,7 @@ void ScDocument::EnsureTable( SCTAB nTab ) maTabs.resize(nTab+1); if (!maTabs[nTab]) - maTabs[nTab].reset( new ScTable(this, nTab, "temp", bExtras, bExtras) ); + maTabs[nTab].reset( new ScTable(*this, nTab, "temp", bExtras, bExtras) ); } ScRefCellValue ScDocument::GetRefCellValue( const ScAddress& rPos ) @@ -790,7 +790,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM if (nNewPos >= static_cast<SCTAB>(maTabs.size())) { nNewPos = static_cast<SCTAB>(maTabs.size()); - maTabs.emplace_back(new ScTable(this, nNewPos, aName)); + maTabs.emplace_back(new ScTable(*this, nNewPos, aName)); } else { @@ -820,7 +820,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM (*it)->UpdateInsertTab(aCxt); if (nNewPos <= nOldPos) nOldPos++; - maTabs.emplace(maTabs.begin() + nNewPos, new ScTable(this, nNewPos, aName)); + maTabs.emplace(maTabs.begin() + nNewPos, new ScTable(*this, nNewPos, aName)); bValid = true; for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it) if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin() + nNewPos) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 86fe8a318263..553b7e5f42af 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -177,13 +177,13 @@ void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck ) CreateValidTabName( aString ); // no doubles if (nTab < static_cast<SCTAB>(maTabs.size())) { - maTabs[nTab].reset( new ScTable(this, nTab, aString) ); + maTabs[nTab].reset( new ScTable(*this, nTab, aString) ); } else { while(nTab > static_cast<SCTAB>(maTabs.size())) maTabs.push_back(nullptr); - maTabs.emplace_back( new ScTable(this, nTab, aString) ); + maTabs.emplace_back( new ScTable(*this, nTab, aString) ); } maTabs[nTab]->SetLoadingMedium(bLoadingMedium); } @@ -478,7 +478,7 @@ void ScDocument::AppendTabOnLoad(const OUString& rName) OUString aName = rName; CreateValidTabName(aName); - maTabs.emplace_back( new ScTable(this, nTabCount, aName) ); + maTabs.emplace_back( new ScTable(*this, nTabCount, aName) ); } void ScDocument::SetTabNameOnLoad(SCTAB nTab, const OUString& rName) @@ -513,7 +513,7 @@ bool ScDocument::InsertTab( if (nPos == SC_TAB_APPEND || nPos >= nTabCount) { nPos = maTabs.size(); - maTabs.emplace_back( new ScTable(this, nTabCount, rName) ); + maTabs.emplace_back( new ScTable(*this, nTabCount, rName) ); if ( bExternalDocument ) maTabs[nTabCount]->SetVisible( false ); } @@ -544,7 +544,7 @@ bool ScDocument::InsertTab( if (a) a->UpdateInsertTab(aCxt); } - maTabs.emplace(maTabs.begin() + nPos, new ScTable(this, nPos, rName)); + maTabs.emplace(maTabs.begin() + nPos, new ScTable(*this, nPos, rName)); // UpdateBroadcastAreas must be called between UpdateInsertTab, // which ends listening, and StartAllListeners, to not modify @@ -602,7 +602,7 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames, { for ( SCTAB i = 0; i < nNewSheets; ++i ) { - maTabs.emplace_back( new ScTable(this, nTabCount + i, rNames.at(i)) ); + maTabs.emplace_back( new ScTable(*this, nTabCount + i, rNames.at(i)) ); } } else @@ -633,7 +633,7 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames, } for (SCTAB i = 0; i < nNewSheets; ++i) { - maTabs.emplace(maTabs.begin() + nPos + i, new ScTable(this, nPos + i, rNames.at(i)) ); + maTabs.emplace(maTabs.begin() + nPos + i, new ScTable(*this, nPos + i, rNames.at(i)) ); } // UpdateBroadcastAreas must be called between UpdateInsertTab, @@ -1987,7 +1987,7 @@ void ScDocument::InitUndoSelected( const ScDocument* pSrcDoc, const ScMarkData& for (SCTAB nTab = 0; nTab <= rTabSelection.GetLastSelected(); nTab++) if ( rTabSelection.GetTableSelect( nTab ) ) { - ScTableUniquePtr pTable(new ScTable(this, nTab, OUString(), bColInfo, bRowInfo)); + ScTableUniquePtr pTable(new ScTable(*this, nTab, OUString(), bColInfo, bRowInfo)); if (nTab < static_cast<SCTAB>(maTabs.size())) maTabs[nTab] = std::move(pTable); else @@ -2028,7 +2028,7 @@ void ScDocument::InitUndo( const ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2, maTabs.resize(nTab2 + 1); for (SCTAB nTab = nTab1; nTab <= nTab2; nTab++) { - maTabs[nTab].reset(new ScTable(this, nTab, OUString(), bColInfo, bRowInfo)); + maTabs[nTab].reset(new ScTable(*this, nTab, OUString(), bColInfo, bRowInfo)); } } @@ -2048,7 +2048,7 @@ void ScDocument::AddUndoTab( SCTAB nTab1, SCTAB nTab2, bool bColInfo, bool bRowI for (SCTAB nTab = nTab1; nTab <= nTab2; nTab++) if (!maTabs[nTab]) { - maTabs[nTab].reset( new ScTable(this, nTab, OUString(), bColInfo, bRowInfo) ); + maTabs[nTab].reset( new ScTable(*this, nTab, OUString(), bColInfo, bRowInfo) ); } } diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 224dfeacae6f..3b6a1e5315bf 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -163,7 +163,7 @@ bool ScDocumentImport::appendSheet(const OUString& rName) if (!ValidTab(nTabCount)) return false; - mpImpl->mrDoc.maTabs.emplace_back(new ScTable(&mpImpl->mrDoc, nTabCount, rName)); + mpImpl->mrDoc.maTabs.emplace_back(new ScTable(mpImpl->mrDoc, nTabCount, rName)); return true; } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 9d70e081b1ae..331b5a7c3513 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -229,9 +229,9 @@ bool SetOptimalHeightsToRows( } -ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, +ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName, bool bColInfo, bool bRowInfo ) : - aCol( pDoc->GetSheetLimits(), INITIALCOLCOUNT ), + aCol( rDoc.GetSheetLimits(), INITIALCOLCOUNT ), aName( rNewName ), aCodeName( rNewName ), nLinkRefreshDelay( 0 ), @@ -242,14 +242,14 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, nRepeatStartY( SCROW_REPEAT_NONE ), nRepeatEndY( SCROW_REPEAT_NONE ), mpRowHeights( static_cast<ScFlatUInt16RowSegments*>(nullptr) ), - mpHiddenCols(new ScFlatBoolColSegments(pDoc->MaxCol())), - mpHiddenRows(new ScFlatBoolRowSegments(pDoc->MaxRow())), - mpFilteredCols(new ScFlatBoolColSegments(pDoc->MaxCol())), - mpFilteredRows(new ScFlatBoolRowSegments(pDoc->MaxRow())), + mpHiddenCols(new ScFlatBoolColSegments(rDoc.MaxCol())), + mpHiddenRows(new ScFlatBoolRowSegments(rDoc.MaxRow())), + mpFilteredCols(new ScFlatBoolColSegments(rDoc.MaxCol())), + mpFilteredRows(new ScFlatBoolRowSegments(rDoc.MaxRow())), nTableAreaX( 0 ), nTableAreaY( 0 ), nTab( nNewTab ), - pDocument( pDoc ), + rDocument( rDoc ), pSortCollator( nullptr ), nLockCount( 0 ), aScenarioColor( COL_LIGHTGRAY ), @@ -271,46 +271,46 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, bActiveScenario(false), mbPageBreaksValid(false), mbForceBreaks(false), - aDefaultColAttrArray(static_cast<SCCOL>(-1), nNewTab, pDoc, nullptr) + aDefaultColAttrArray(static_cast<SCCOL>(-1), nNewTab, &rDoc, nullptr) { if (bColInfo) { - mpColWidth.reset( new ScCompressedArray<SCCOL, sal_uInt16>( pDocument->MaxCol()+1, STD_COL_WIDTH ) ); - mpColFlags.reset( new ScBitMaskCompressedArray<SCCOL, CRFlags>( pDocument->MaxCol()+1, CRFlags::NONE ) ); + mpColWidth.reset( new ScCompressedArray<SCCOL, sal_uInt16>( rDocument.MaxCol()+1, STD_COL_WIDTH ) ); + mpColFlags.reset( new ScBitMaskCompressedArray<SCCOL, CRFlags>( rDocument.MaxCol()+1, CRFlags::NONE ) ); } if (bRowInfo) { - mpRowHeights.reset(new ScFlatUInt16RowSegments(pDocument->MaxRow(), ScGlobal::nStdRowHeight)); - pRowFlags.reset(new ScBitMaskCompressedArray<SCROW, CRFlags>( pDocument->MaxRow(), CRFlags::NONE)); + mpRowHeights.reset(new ScFlatUInt16RowSegments(rDocument.MaxRow(), ScGlobal::nStdRowHeight)); + pRowFlags.reset(new ScBitMaskCompressedArray<SCROW, CRFlags>( rDocument.MaxRow(), CRFlags::NONE)); } - if ( pDocument->IsDocVisible() ) + if ( rDocument.IsDocVisible() ) { // when a sheet is added to a visible document, // initialize its RTL flag from the system locale bLayoutRTL = ScGlobal::IsSystemRTL(); } - ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); + ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer(); if (pDrawLayer) { if ( pDrawLayer->ScAddPage( nTab ) ) // sal_False (not inserted) during Undo { pDrawLayer->ScRenamePage( nTab, aName ); - sal_uLong const nx = sal_uLong(double(pDocument->MaxCol()+1) * STD_COL_WIDTH * HMM_PER_TWIPS ); - sal_uLong ny = static_cast<sal_uLong>(double(pDocument->MaxRow()+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS ); + sal_uLong const nx = sal_uLong(double(rDocument.MaxCol()+1) * STD_COL_WIDTH * HMM_PER_TWIPS ); + sal_uLong ny = static_cast<sal_uLong>(double(rDocument.MaxRow()+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS ); pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ), false ); } } for (SCCOL k=0; k < aCol.size(); k++) - aCol[k].Init( k, nTab, pDocument, true ); + aCol[k].Init( k, nTab, &rDocument, true ); } ScTable::~ScTable() COVERITY_NOEXCEPT_FALSE { - if (!pDocument->IsInDtorClear()) + if (!rDocument.IsInDtorClear()) { for (SCCOL nCol = 0; nCol < (aCol.size() - 1); ++nCol) { @@ -320,7 +320,7 @@ ScTable::~ScTable() COVERITY_NOEXCEPT_FALSE // (or else nTab does not reflect the page number!) // In ScDocument::Clear is afterwards used from Clear at the Draw Layer to delete everything. - ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); + ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer(); if (pDrawLayer) pDrawLayer->ScRemovePage( nTab ); } @@ -369,7 +369,7 @@ void ScTable::SetStreamValid( bool bSet, bool bIgnoreLock ) { if (!bStreamValid && !bSet) return; // shortcut - if ( bIgnoreLock || !pDocument->IsStreamValidLocked() ) + if ( bIgnoreLock || !rDocument.IsStreamValidLocked() ) bStreamValid = bSet; } @@ -456,14 +456,14 @@ bool ScTable::SetOptimalHeight( OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(), "automatic OptimalHeight with Extra" ); - if ( pDocument->IsAdjustHeightLocked() ) + if ( rDocument.IsAdjustHeightLocked() ) { return false; } SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1); - ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument); + ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, &rDocument); mpRowHeights->enableTreeSearch(false); @@ -487,12 +487,12 @@ void ScTable::SetOptimalHeightOnly( OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(), "automatic OptimalHeight with Extra" ); - if ( pDocument->IsAdjustHeightLocked() ) + if ( rDocument.IsAdjustHeightLocked() ) return; SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1); - ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument); + ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, &rDocument); GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, pProgress, nProgressStart); @@ -603,7 +603,7 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const } } - if (nMaxX == pDocument->MaxCol()) // omit attribute at the right + if (nMaxX == rDocument.MaxCol()) // omit attribute at the right { --nMaxX; while ( nMaxX>0 && aCol[nMaxX].IsVisibleAttrEqual(aCol[nMaxX+1]) ) @@ -658,7 +658,7 @@ bool ScTable::GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow, } } - if (nMaxX == pDocument->MaxCol()) // omit attribute at the right + if (nMaxX == rDocument.MaxCol()) // omit attribute at the right { --nMaxX; while ( nMaxX>0 && aCol[nMaxX].IsVisibleAttrEqual(aCol[nMaxX+1], nStartRow, nEndRow) ) @@ -727,7 +727,7 @@ bool ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const { bool bFound = false; SCCOL nMinX = aCol.size()-1; - SCROW nMinY = pDocument->MaxRow(); + SCROW nMinY = rDocument.MaxRow(); SCCOL i; for (i=0; i<aCol.size(); i++) // Test attribute @@ -819,7 +819,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S SCROW nStart = rStartRow; SCROW nEnd = rEndRow; if (nStart>0) --nStart; - if (nEnd<pDocument->MaxRow()) ++nEnd; + if (nEnd<rDocument.MaxRow()) ++nEnd; if (rEndCol < (aCol.size()-1)) if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd)) @@ -856,7 +856,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S } } - if (rEndRow < pDocument->MaxRow()) + if (rEndRow < rDocument.MaxRow()) { SCROW nTest = rEndRow+1; bool needExtend = false; @@ -883,7 +883,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S while ( rEndCol > 0 && rStartCol < rEndCol && aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) ) --rEndCol; - if ( !bTop && rStartRow < pDocument->MaxRow() && rStartRow < rEndRow ) + if ( !bTop && rStartRow < rDocument.MaxRow() && rStartRow < rEndRow ) { bool bShrink = true; do @@ -893,7 +893,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S bShrink = false; if (bShrink) ++rStartRow; - } while (bShrink && rStartRow < pDocument->MaxRow() && rStartRow < rEndRow); + } while (bShrink && rStartRow < rDocument.MaxRow() && rStartRow < rEndRow); } } @@ -975,9 +975,9 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS rEndCol = aCol.size()-1; o_bShrunk = true; } - if (rEndRow > pDocument->MaxRow()) + if (rEndRow > rDocument.MaxRow()) { - rEndRow = pDocument->MaxRow(); + rEndRow = rDocument.MaxRow(); o_bShrunk = true; } @@ -1173,17 +1173,17 @@ SCCOL ScTable::FindNextVisibleCol( SCCOL nCol, bool bRight ) const { nCol++; SCCOL nEnd = 0; - bool bHidden = pDocument->ColHidden(nCol, nTab, nullptr, &nEnd); + bool bHidden = rDocument.ColHidden(nCol, nTab, nullptr, &nEnd); if(bHidden) nCol = nEnd +1; - return std::min<SCCOL>(pDocument->MaxCol(), nCol); + return std::min<SCCOL>(rDocument.MaxCol(), nCol); } else { nCol--; - SCCOL nStart = pDocument->MaxCol(); - bool bHidden = pDocument->ColHidden(nCol, nTab, &nStart); + SCCOL nStart = rDocument.MaxCol(); + bool bHidden = rDocument.ColHidden(nCol, nTab, &nStart); if(bHidden) nCol = nStart - 1; @@ -1197,22 +1197,22 @@ SCCOL ScTable::FindNextVisibleColWithContent( SCCOL nCol, bool bRight, SCROW nRo if(bRight) { // If nCol is the last allocated column index, there won't be any content to its right. - // To maintain the original return behaviour, return pDocument->MaxCol(). + // To maintain the original return behaviour, return rDocument.MaxCol(). if(nCol >= nLastCol) - return pDocument->MaxCol(); + return rDocument.MaxCol(); do { nCol++; SCCOL nEndCol = 0; - bool bHidden = pDocument->ColHidden( nCol, nTab, nullptr, &nEndCol ); + bool bHidden = rDocument.ColHidden( nCol, nTab, nullptr, &nEndCol ); if(bHidden) { nCol = nEndCol +1; // Can end search early as there is no data after nLastCol. - // For nCol == nLastCol, it may still have data so don't want to return pDocument->MaxCol(). + // For nCol == nLastCol, it may still have data so don't want to return rDocument.MaxCol(). if(nCol > nLastCol) - return pDocument->MaxCol(); + return rDocument.MaxCol(); } if(aCol[nCol].HasVisibleDataAt(nRow)) @@ -1220,11 +1220,11 @@ SCCOL ScTable::FindNextVisibleColWithContent( SCCOL nCol, bool bRight, SCROW nRo } while(nCol < nLastCol); // Stop search as soon as the last allocated column is searched. - return pDocument->MaxCol(); + return rDocument.MaxCol(); } else { - // If nCol is in the unallocated range [nLastCol+1, pDocument->MaxCol()], then move it directly to nLastCol + // If nCol is in the unallocated range [nLastCol+1, rDocument.MaxCol()], then move it directly to nLastCol // as there is no data in the unallocated range. This also makes the search faster and avoids // the need for more range checks in the loop below. if ( nCol > nLastCol ) @@ -1236,8 +1236,8 @@ SCCOL ScTable::FindNextVisibleColWithContent( SCCOL nCol, bool bRight, SCROW nRo do { nCol--; - SCCOL nStartCol = pDocument->MaxCol(); - bool bHidden = pDocument->ColHidden( nCol, nTab, &nStartCol ); + SCCOL nStartCol = rDocument.MaxCol(); + bool bHidden = rDocument.ColHidden( nCol, nTab, &nStartCol ); if(bHidden) { nCol = nStartCol -1; @@ -1265,7 +1265,7 @@ void ScTable::FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection bool bRight = (eDirection == SC_MOVE_RIGHT); if (bThere) { - if(nNewCol >= pDocument->MaxCol() && eDirection == SC_MOVE_RIGHT) + if(nNewCol >= rDocument.MaxCol() && eDirection == SC_MOVE_RIGHT) return; else if(nNewCol == 0 && eDirection == SC_MOVE_LEFT) return; @@ -1284,7 +1284,7 @@ void ScTable::FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection else bFound = true; } - while(!bFound && nNextCol > 0 && nNextCol < pDocument->MaxCol()); + while(!bFound && nNextCol > 0 && nNextCol < rDocument.MaxCol()); } else { @@ -1298,8 +1298,8 @@ void ScTable::FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection if (nNewCol<0) nNewCol=0; - if (nNewCol>pDocument->MaxCol()) - nNewCol=pDocument->MaxCol(); + if (nNewCol>rDocument.MaxCol()) + nNewCol=rDocument.MaxCol(); rCol = nNewCol; } else @@ -1309,9 +1309,9 @@ void ScTable::FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection else { // The cell (rCol, rRow) is equivalent to an empty cell (although not allocated). - // Set rRow to 0 or pDocument->MaxRow() depending on eDirection to maintain the behaviour of + // Set rRow to 0 or rDocument.MaxRow() depending on eDirection to maintain the behaviour of // ScColumn::FindDataAreaPos() when the given column is empty. - rRow = ( eDirection == SC_MOVE_DOWN ) ? pDocument->MaxRow() : 0; + rRow = ( eDirection == SC_MOVE_DOWN ) ? rDocument.MaxRow() : 0; } } } @@ -1322,7 +1322,7 @@ bool ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark, if (!ValidCol(nCol) || !ValidRow(nRow)) return false; - if (pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Overlapped)) + if (rDocument.HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Overlapped)) // Skip an overlapped cell. return false; @@ -1332,7 +1332,7 @@ bool ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark, /* TODO: for cursor movement *only* this should even take the protection * options (select locked, select unlocked) into account, see * ScTabView::SkipCursorHorizontal() and ScTabView::SkipCursorVertical(). */ - if (bUnprotected && pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Protected)) + if (bUnprotected && rDocument.HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Protected)) return false; if (bMarked || bUnprotected) //TODO: also in other case ??? @@ -1359,10 +1359,10 @@ bool ScTable::SkipRow( const SCCOL nCol, SCROW& rRow, const SCROW nMovY, if ( !ValidRow( rRow )) return false; - if (bSheetProtected && pDocument->HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Protected)) + if (bSheetProtected && rDocument.HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Protected)) { if ( rRow > nUsedY ) - rRow = (bUp ? nUsedY : pDocument->MaxRow() + nMovY); + rRow = (bUp ? nUsedY : rDocument.MaxRow() + nMovY); else rRow += nMovY; @@ -1374,7 +1374,7 @@ bool ScTable::SkipRow( const SCCOL nCol, SCROW& rRow, const SCROW nMovY, else { bool bRowHidden = RowHidden( rRow ); - bool bOverlapped = pDocument->HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Overlapped ); + bool bOverlapped = rDocument.HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Overlapped ); if ( bRowHidden || bOverlapped ) { @@ -1433,13 +1433,13 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY, nStartRow = 0; nEndCol = rCol; nEndRow = rRow; - pDocument->GetPrintArea( nTab, nEndCol, nEndRow, true ); + rDocument.GetPrintArea( nTab, nEndCol, nEndRow, true ); // Add some cols/rows to the print area (which is "content or // visually different from empty") to enable travelling through // protected forms with empty cells and no visual indicator. // 42 might be good enough and not too much... - nEndCol = std::min<SCCOL>( nEndCol+42, pDocument->MaxCol()); - nEndRow = std::min<SCROW>( nEndRow+42, pDocument->MaxRow()); + nEndCol = std::min<SCCOL>( nEndCol+42, rDocument.MaxCol()); + nEndRow = std::min<SCROW>( nEndRow+42, rDocument.MaxRow()); } else { @@ -1641,10 +1641,10 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa while ( rCol < aCol.size() ) { ScMarkArray aArray( rMark.GetMarkArray( rCol ) ); - while ( rRow <= pDocument->MaxRow() ) + while ( rRow <= rDocument.MaxRow() ) { SCROW nStart = aArray.GetNextMarked( rRow, false ); - if ( nStart <= pDocument->MaxRow() ) + if ( nStart <= rDocument.MaxRow() ) { SCROW nEnd = aArray.GetMarkEnd( nStart, false ); @@ -1660,7 +1660,7 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa if (it == rCells.end()) { // No more block. Move on to the next column. - rRow = pDocument->MaxRow() + 1; + rRow = rDocument.MaxRow() + 1; continue; } } @@ -1675,14 +1675,14 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa rRow = nEnd + 1; // Search for next selected range } else - rRow = pDocument->MaxRow() + 1; // End of column + rRow = rDocument.MaxRow() + 1; // End of column } rRow = 0; ++rCol; // test next column } - // Though searched only the allocated columns, it is equivalent to a search till pDocument->MaxCol(). - rCol = pDocument->MaxCol() + 1; + // Though searched only the allocated columns, it is equivalent to a search till rDocument.MaxCol(). + rCol = rDocument.MaxCol() + 1; return false; // Through all columns } @@ -1693,7 +1693,7 @@ void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nR if ( !(nTab >= nTab1 && nTab <= nTab2 && nDz == 0) ) // only within the table return; - ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); + ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer(); if ( eUpdateRefMode != URM_COPY && pDrawLayer ) { if ( eUpdateRefMode == URM_MOVE ) @@ -1722,7 +1722,7 @@ void ScTable::UpdateReference( else { i = 0; - iMax = pDocument->MaxCol(); + iMax = rDocument.MaxCol(); } UpdateRefMode eUpdateRefMode = rCxt.meMode; @@ -1761,7 +1761,7 @@ void ScTable::UpdateReference( nERow = rPrintRange.aEnd.Row(); // do not try to modify sheet index of print range - if ( ScRefUpdate::Update( pDocument, eUpdateRefMode, + if ( ScRefUpdate::Update( &rDocument, eUpdateRefMode, nCol1,nRow1,nTab, nCol2,nRow2,nTab, nDx,nDy,0, nSCol,nSRow,nSTab, nECol,nERow,nETab ) ) @@ -1779,7 +1779,7 @@ void ScTable::UpdateReference( nERow = pRepeatColRange->aEnd.Row(); // do not try to modify sheet index of repeat range - if ( ScRefUpdate::Update( pDocument, eUpdateRefMode, + if ( ScRefUpdate::Update( &rDocument, eUpdateRefMode, nCol1,nRow1,nTab, nCol2,nRow2,nTab, nDx,nDy,0, nSCol,nSRow,nSTab, nECol,nERow,nETab ) ) @@ -1799,7 +1799,7 @@ void ScTable::UpdateReference( nERow = pRepeatRowRange->aEnd.Row(); // do not try to modify sheet index of repeat range - if ( ScRefUpdate::Update( pDocument, eUpdateRefMode, + if ( ScRefUpdate::Update( &rDocument, eUpdateRefMode, nCol1,nRow1,nTab, nCol2,nRow2,nTab, nDx,nDy,0, nSCol,nSRow,nSTab, nECol,nERow,nETab ) ) @@ -1816,7 +1816,7 @@ void ScTable::UpdateReference( { UpdatePageBreaks(nullptr); - pDocument->RepaintRange( ScRange(0,0,nTab,pDocument->MaxCol(),pDocument->MaxRow(),nTab) ); + rDocument.RepaintRange( ScRange(0,0,nTab,rDocument.MaxCol(),rDocument.MaxRow(),nTab) ); } } @@ -1827,7 +1827,7 @@ void ScTable::UpdateReference( mpCondFormatList->UpdateReference(rCxt); if (pTabProtection) - pTabProtection->updateReference( eUpdateRefMode, pDocument, rCxt.maRange, nDx, nDy, nDz); + pTabProtection->updateReference( eUpdateRefMode, &rDocument, rCxt.maRange, nDx, nDy, nDz); } void ScTable::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, @@ -1862,8 +1862,8 @@ void ScTable::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) mpCondFormatList->UpdateInsertTab(rCxt); if (pTabProtection) - pTabProtection->updateReference( URM_INSDEL, pDocument, - ScRange( 0, 0, rCxt.mnInsertPos, pDocument->MaxCol(), pDocument->MaxRow(), MAXTAB), + pTabProtection->updateReference( URM_INSDEL, &rDocument, + ScRange( 0, 0, rCxt.mnInsertPos, rDocument.MaxCol(), rDocument.MaxRow(), MAXTAB), 0, 0, rCxt.mnSheets); for (SCCOL i=0; i < aCol.size(); i++) @@ -1891,8 +1891,8 @@ void ScTable::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) mpCondFormatList->UpdateDeleteTab(rCxt); if (pTabProtection) - pTabProtection->updateReference( URM_INSDEL, pDocument, - ScRange( 0, 0, rCxt.mnDeletePos, pDocument->MaxCol(), pDocument->MaxRow(), MAXTAB), + pTabProtection->updateReference( URM_INSDEL, &rDocument, + ScRange( 0, 0, rCxt.mnDeletePos, rDocument.MaxCol(), rDocument.MaxRow(), MAXTAB), 0, 0, -rCxt.mnSheets); for (SCCOL i = 0; i < aCol.size(); ++i) @@ -1915,8 +1915,8 @@ void ScTable::UpdateMoveTab( mpCondFormatList->UpdateMoveTab(rCxt); if (pTabProtection) - pTabProtection->updateReference( URM_REORDER, pDocument, - ScRange( 0, 0, rCxt.mnOldPos, pDocument->MaxCol(), pDocument->MaxRow(), MAXTAB), + pTabProtection->updateReference( URM_REORDER, &rDocument, + ScRange( 0, 0, rCxt.mnOldPos, rDocument.MaxCol(), rDocument.MaxRow(), MAXTAB), 0, 0, rCxt.mnNewPos - rCxt.mnOldPos); for ( SCCOL i=0; i < aCol.size(); i++ ) @@ -1966,9 +1966,9 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev, // First, mark those columns that we need to skip i.e. hidden and empty columns. - ScFlatBoolColSegments aSkipCols(pDocument->MaxCol()); - aSkipCols.setFalse(0, pDocument->MaxCol()); - for (SCCOL i = 0; i <= pDocument->MaxCol(); ++i) + ScFlatBoolColSegments aSkipCols(rDocument.MaxCol()); + aSkipCols.setFalse(0, rDocument.MaxCol()); + for (SCCOL i = 0; i <= rDocument.MaxCol(); ++i) { SCCOL nLastCol = i; if (ColHidden(i, nullptr, &nLastCol)) @@ -1983,7 +1983,7 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev, { if ( j >= aCol.size() ) { - aSkipCols.setTrue( j, pDocument->MaxCol() ); + aSkipCols.setTrue( j, rDocument.MaxCol() ); break; } if (aCol[j].GetCellCount() == 0) @@ -2012,7 +2012,7 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev, for (SCCOL nDataCol = nCol; 0 <= nDataCol && nDataCol >= aColData.mnCol1; --nDataCol) { SCCOL nPrintCol = nDataCol; - VisibleDataCellIterator aIter(pDocument, *mpHiddenRows, aCol[nDataCol]); + VisibleDataCellIterator aIter(&rDocument, *mpHiddenRows, aCol[nDataCol]); ScRefCellValue aCell = aIter.reset(nStartRow); if (aCell.isEmpty()) // No visible cells found in this column. Skip it. @@ -2085,7 +2085,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d // look at alignment const ScPatternAttr* pPattern = GetPattern( rCol, nRow ); - const SfxItemSet* pCondSet = pDocument->GetCondResult( rCol, nRow, nTab ); + const SfxItemSet* pCondSet = rDocument.GetCondResult( rCol, nRow, nTab ); SvxCellHorJustify eHorJust = pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet ).GetValue(); @@ -2103,7 +2103,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d } SCCOL nNewCol = rCol; - while (nMissing > 0 && nNewCol < pDocument->MaxCol()) + while (nMissing > 0 && nNewCol < rDocument.MaxCol()) { auto nNextCol = nNewCol + 1; bool bNextEmpty = true; @@ -2617,8 +2617,8 @@ void ScTable::CreateColumnIfNotExistsImpl( const SCCOL nScCol ) const // which is bad since that code is not thread-safe. SolarMutexGuard aGuard; const SCCOL aOldColSize = aCol.size(); - aCol.resize( pDocument->GetSheetLimits(), static_cast< size_t >( nScCol + 1 ) ); + aCol.resize( rDocument.GetSheetLimits(), static_cast< size_t >( nScCol + 1 ) ); for (SCCOL i = aOldColSize; i <= nScCol; i++) - aCol[i].Init( i, nTab, pDocument, false ); + aCol[i].Init( i, nTab, &rDocument, false ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index e625fb037feb..a5ecf2b228f9 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -134,7 +134,7 @@ bool ScTable::TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SC { bool bTest = true; - if ( nStartCol==0 && nEndCol==pDocument->MaxCol() && pOutlineTable ) + if ( nStartCol==0 && nEndCol==rDocument.MaxCol() && pOutlineTable ) bTest = pOutlineTable->TestInsertRow(nSize); for (SCCOL i=nStartCol; (i<=nEndCol) && bTest; i++) @@ -145,7 +145,7 @@ bool ScTable::TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SC void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) { - if (nStartCol==0 && nEndCol==pDocument->MaxCol()) + if (nStartCol==0 && nEndCol==rDocument.MaxCol()) { if (mpRowHeights && pRowFlags) { @@ -195,7 +195,7 @@ void ScTable::DeleteRow( const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize, bool* pUndoOutline, std::vector<ScAddress>* pGroupPos ) { - if (nStartCol==0 && nEndCol==pDocument->MaxCol()) + if (nStartCol==0 && nEndCol==rDocument.MaxCol()) { if (pRowFlags) pRowFlags->Remove( nStartRow, nSize); @@ -232,7 +232,7 @@ void ScTable::DeleteRow( } { // scope for bulk broadcast - ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM(), SfxHintId::ScDataChanged); + ScBulkBroadcast aBulkBroadcast( rDocument.GetBASM(), SfxHintId::ScDataChanged); for (SCCOL j=nStartCol; j<=nEndCol; j++) aCol[j].DeleteRow(nStartRow, nSize, pGroupPos); } @@ -251,14 +251,14 @@ void ScTable::DeleteRow( bool ScTable::TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const { - if ( nSize > o3tl::make_unsigned(pDocument->MaxCol()) ) + if ( nSize > o3tl::make_unsigned(rDocument.MaxCol()) ) return false; - if ( nStartRow==0 && nEndRow==pDocument->MaxRow() && pOutlineTable + if ( nStartRow==0 && nEndRow==rDocument.MaxRow() && pOutlineTable && ! pOutlineTable->TestInsertCol(nSize) ) return false; - auto range = GetColumnsRange( pDocument->MaxCol() - static_cast<SCCOL>(nSize) + 1, pDocument->MaxCol() ); + auto range = GetColumnsRange( rDocument.MaxCol() - static_cast<SCCOL>(nSize) + 1, rDocument.MaxCol() ); for (auto it = range.rbegin(); it != range.rend(); ++it ) if (! aCol[*it].TestInsertCol(nStartRow, nEndRow)) return false; @@ -269,13 +269,13 @@ bool ScTable::TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) cons void ScTable::InsertCol( const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) { - if (nStartRow==0 && nEndRow==pDocument->MaxRow()) + if (nStartRow==0 && nEndRow==rDocument.MaxRow()) { if (mpColWidth && mpColFlags) { mpColWidth->InsertPreservingSize(nStartCol, nSize, STD_COL_WIDTH); // The inserted columns have the same widths as the columns, which were selected for insert. - for (SCSIZE i=0; i < std::min(pDocument->MaxCol()-nSize-nStartCol, nSize); ++i) + for (SCSIZE i=0; i < std::min(rDocument.MaxCol()-nSize-nStartCol, nSize); ++i) mpColWidth->SetValue(nStartCol + i, mpColWidth->GetValue(nStartCol+i+nSize)); mpColFlags->InsertPreservingSize(nStartCol, nSize, CRFlags::NONE); } @@ -301,7 +301,7 @@ void ScTable::InsertCol( } } - if ((nStartRow == 0) && (nEndRow == pDocument->MaxRow())) + if ((nStartRow == 0) && (nEndRow == rDocument.MaxRow())) { for (SCSIZE i=0; i < nSize; i++) for (SCCOL nCol = aCol.size() - 1; nCol > nStartCol; nCol--) @@ -323,7 +323,7 @@ void ScTable::InsertCol( nWhichArray[0] = ATTR_MERGE; nWhichArray[1] = 0; - sc::CopyToDocContext aCxt(*pDocument); + sc::CopyToDocContext aCxt(rDocument); for (SCSIZE i=0; i<nSize; i++) { aCol[nStartCol-1].CopyToColumn(aCxt, nStartRow, nEndRow, InsertDeleteFlags::ATTRIB, @@ -346,11 +346,11 @@ void ScTable::InsertCol( void ScTable::DeleteCol( const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline ) { - if (nStartRow==0 && nEndRow==pDocument->MaxRow()) + if (nStartRow==0 && nEndRow==rDocument.MaxRow()) { if (mpColWidth && mpColFlags) { - assert( nStartCol + nSize <= o3tl::make_unsigned(pDocument->MaxCol()+1) ); // moving 0 if ==pDocument->MaxCol()+1 is correct + assert( nStartCol + nSize <= o3tl::make_unsigned(rDocument.MaxCol()+1) ); // moving 0 if ==rDocument.MaxCol()+1 is correct mpColWidth->RemovePreservingSize(nStartCol, nSize, STD_COL_WIDTH); mpColFlags->RemovePreservingSize(nStartCol, nSize, CRFlags::NONE); } @@ -386,7 +386,7 @@ void ScTable::DeleteCol( for (SCSIZE i = 0; i < nSize; i++) aCol[nStartCol + i].DeleteArea(nStartRow, nEndRow, InsertDeleteFlags::ALL, false); - if ((nStartRow == 0) && (nEndRow == pDocument->MaxRow())) + if ((nStartRow == 0) && (nEndRow == rDocument.MaxRow())) { for (SCSIZE i=0; i < nSize; i++) for (SCCOL nCol = nStartCol; nCol < aCol.size() - 1; nCol++) @@ -414,11 +414,11 @@ void ScTable::DeleteArea( bool bBroadcast, sc::ColumnSpanSet* pBroadcastSpans ) { if ( nCol2 >= aCol.size() ) nCol2 = aCol.size() - 1; - if (nRow2 > pDocument->MaxRow()) nRow2 = pDocument->MaxRow(); + if (nRow2 > rDocument.MaxRow()) nRow2 = rDocument.MaxRow(); if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)) { { // scope for bulk broadcast - ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM(), SfxHintId::ScDataChanged); + ScBulkBroadcast aBulkBroadcast( rDocument.GetBASM(), SfxHintId::ScDataChanged); for (SCCOL i = nCol1; i <= nCol2; i++) aCol[i].DeleteArea(nRow1, nRow2, nDelFlag, bBroadcast, pBroadcastSpans); } @@ -427,7 +427,7 @@ void ScTable::DeleteArea( if ( IsProtected() && (nDelFlag & InsertDeleteFlags::ATTRIB) ) { - ScPatternAttr aPattern(pDocument->GetPool()); + ScPatternAttr aPattern(rDocument.GetPool()); aPattern.GetItemSet().Put( ScProtectionAttr( false ) ); ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern ); } @@ -444,7 +444,7 @@ void ScTable::DeleteArea( void ScTable::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast ) { { // scope for bulk broadcast - ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM(), SfxHintId::ScDataChanged); + ScBulkBroadcast aBulkBroadcast( rDocument.GetBASM(), SfxHintId::ScDataChanged); for (SCCOL i=0; i < aCol.size(); i++) aCol[i].DeleteSelection(nDelFlag, rMark, bBroadcast); } @@ -464,7 +464,7 @@ void ScTable::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMa if ( IsProtected() && (nDelFlag & InsertDeleteFlags::ATTRIB) ) { - ScDocumentPool* pPool = pDocument->GetPool(); + ScDocumentPool* pPool = rDocument.GetPool(); SfxItemSet aSet( *pPool, svl::Items<ATTR_PATTERN_START, ATTR_PATTERN_END>{} ); aSet.Put( ScProtectionAttr( false ) ); SfxItemPoolCache aCache( pPool, &aSet ); @@ -520,7 +520,7 @@ void ScTable::CopyToClip( for (SCCOL i = nCol1; i <= nCol2; i++) pTable->aCol[i].RemoveProtected(nRow1, nRow2); - pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->pDocument, *mpCondFormatList)); + pTable->mpCondFormatList.reset(new ScConditionalFormatList(&pTable->rDocument, *mpCondFormatList)); } void ScTable::CopyToClip( @@ -560,7 +560,7 @@ void ScTable::CopyStaticToDocument( for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) { sal_uInt32 nNumFmt = aDefaultColAttrArray.GetPattern(nRow)->GetNumberFormat( - pDocument->GetNonThreadedContext().GetFormatTable()); + rDocument.GetNonThreadedContext().GetFormatTable()); SvNumberFormatterMergeMap::const_iterator itNum = rMap.find(nNumFmt); if (itNum != rMap.end()) nNumFmt = itNum->second; @@ -623,7 +623,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { ScRange aOldRange( nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab); ScRange aNewRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); - bool bSameDoc = pDocument->GetStyleSheetPool() == pTable->pDocument->GetStyleSheetPool(); + bool bSameDoc = rDocument.GetStyleSheetPool() == pTable->rDocument.GetStyleSheetPool(); for(const auto& rxCondFormat : *pTable->mpCondFormatList) { @@ -632,10 +632,10 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO continue; ScRangeList aIntersectedRange = rCondFormatRange.GetIntersectedRange(aOldRange); - std::unique_ptr<ScConditionalFormat> pNewFormat = rxCondFormat->Clone(pDocument); + std::unique_ptr<ScConditionalFormat> pNewFormat = rxCondFormat->Clone(&rDocument); pNewFormat->SetRange(aIntersectedRange); - sc::RefUpdateContext aRefCxt(*pDocument); + sc::RefUpdateContext aRefCxt(rDocument); aRefCxt.meMode = URM_COPY; aRefCxt.maRange = aNewRange; aRefCxt.mnColDelta = nDx; @@ -643,7 +643,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO aRefCxt.mnTabDelta = nTab - pTable->nTab; pNewFormat->UpdateReference(aRefCxt, true); - if (bSameDoc && pTable->nTab == nTab && CheckAndDeduplicateCondFormat(pDocument, mpCondFormatList->GetFormat(rxCondFormat->GetKey()), pNewFormat.get(), nTab)) + if (bSameDoc && pTable->nTab == nTab && CheckAndDeduplicateCondFormat(&rDocument, mpCondFormatList->GetFormat(rxCondFormat->GetKey()), pNewFormat.get(), nTab)) { continue; } @@ -653,7 +653,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { // Check if there is the same format in the destination // If there is, then simply expand its range - if (CheckAndDeduplicateCondFormat(pDocument, rxCond.get(), pNewFormat.get(), nTab)) + if (CheckAndDeduplicateCondFormat(&rDocument, rxCond.get(), pNewFormat.get(), nTab)) { bDuplicate = true; break; @@ -687,16 +687,16 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO if(!aStyleName.isEmpty()) { - if(pDocument->GetStyleSheetPool()->Find(aStyleName, SfxStyleFamily::Para)) + if(rDocument.GetStyleSheetPool()->Find(aStyleName, SfxStyleFamily::Para)) continue; - pDocument->GetStyleSheetPool()->CopyStyleFrom( - pTable->pDocument->GetStyleSheetPool(), aStyleName, SfxStyleFamily::Para ); + rDocument.GetStyleSheetPool()->CopyStyleFrom( + pTable->rDocument.GetStyleSheetPool(), aStyleName, SfxStyleFamily::Para ); } } } - pDocument->AddCondFormatData( pNewFormatTmp->GetRange(), nTab, pNewFormatTmp->GetKey() ); + rDocument.AddCondFormatData( pNewFormatTmp->GetRange(), nTab, pNewFormatTmp->GetKey() ); } } @@ -715,10 +715,10 @@ void ScTable::CopyFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCCOL nDx, SCROW nDy, ScTable* pTable ) { - if (nCol2 > pDocument->MaxCol()) - nCol2 = pDocument->MaxCol(); - if (nRow2 > pDocument->MaxRow()) - nRow2 = pDocument->MaxRow(); + if (nCol2 > rDocument.MaxCol()) + nCol2 = rDocument.MaxCol(); + if (nRow2 > rDocument.MaxRow()) + nRow2 = rDocument.MaxRow(); if (!(ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))) return; @@ -743,10 +743,10 @@ void ScTable::CopyFromClip( if ((rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB) == InsertDeleteFlags::NONE) return; - if (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pTable->mpColWidth) + if (nRow1==0 && nRow2==rDocument.MaxRow() && mpColWidth && pTable->mpColWidth) mpColWidth->CopyFrom(*pTable->mpColWidth, nCol1, nCol2, nCol1 - nDx); - if (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pTable->mpRowHeights && + if (nCol1==0 && nCol2==rDocument.MaxCol() && mpRowHeights && pTable->mpRowHeights && pRowFlags && pTable->pRowFlags) { CopyRowHeight(*pTable, nRow1, nRow2, -nDy); @@ -763,7 +763,7 @@ void ScTable::CopyFromClip( // Do not set protected cell in a protected sheet if (IsProtected() && (rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB)) { - ScPatternAttr aPattern(pDocument->GetPool()); + ScPatternAttr aPattern(rDocument.GetPool()); aPattern.GetItemSet().Put( ScProtectionAttr( false ) ); ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern ); } @@ -893,9 +893,9 @@ public: void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTransClip, InsertDeleteFlags nFlags, bool bAsLink ) { - bool bWasCut = pDocument->IsCutMode(); + bool bWasCut = rDocument.IsCutMode(); - ScDocument* pDestDoc = pTransClip->pDocument; + ScDocument& rDestDoc = pTransClip->rDocument; for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++) { @@ -912,12 +912,12 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScSingleRefData aRef; aRef.InitAddress(ScAddress(nCol,nRow,nTab)); aRef.SetFlag3D(true); - ScTokenArray aArr(*pDestDoc); + ScTokenArray aArr(rDestDoc); aArr.AddSingleReference( aRef ); pTransClip->SetFormulaCell( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), - new ScFormulaCell(pDestDoc, aDestPos, aArr)); + new ScFormulaCell(&rDestDoc, aDestPos, aArr)); } } else @@ -971,10 +971,10 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if (rOldMerge.IsMerged()) rNewSet.Put( ScMergeAttr( std::min( static_cast<SCCOL>(rOldMerge.GetRowMerge()), - static_cast<SCCOL>(pDocument->MaxCol()+1 - (nAttrRow2-nRow1))), + static_cast<SCCOL>(rDocument.MaxCol()+1 - (nAttrRow2-nRow1))), std::min( static_cast<SCROW>(rOldMerge.GetColMerge()), - static_cast<SCROW>(pDocument->MaxRow()+1 - (nCol-nCol1))))); + static_cast<SCROW>(rDocument.MaxRow()+1 - (nCol-nCol1))))); const ScMergeFlagAttr& rOldFlag = rSet.Get(ATTR_MERGE_FLAG); if (rOldFlag.IsOverlapped()) { @@ -993,7 +993,7 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } // Cell Notes - fdo#68381 paste cell notes on Transpose - if ( pDocument->HasColNotes(nCol, nTab) ) + if ( rDocument.HasColNotes(nCol, nTab) ) TransposeColNotes(pTransClip, nCol1, nCol, nRow1, nRow2); } } @@ -1043,12 +1043,12 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC for (; itData != itDataEnd; ++itData, ++curRow) { ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab ); - pTransClip->pDocument->ReleaseNote(aDestPos); + pTransClip->rDocument.ReleaseNote(aDestPos); ScPostIt* pNote = *itData; if (pNote) { - std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true ); - pTransClip->pDocument->SetNote(aDestPos, std::move(pClonedNote)); + std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), pTransClip->rDocument, aDestPos, true ); + pTransClip->rDocument.SetNote(aDestPos, std::move(pClonedNote)); } } break; // we reached the last valid block @@ -1060,12 +1060,12 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC for (; itData != itDataEnd; ++itData, ++curRow) { ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab ); - pTransClip->pDocument->ReleaseNote(aDestPos); + pTransClip->rDocument.ReleaseNote(aDestPos); ScPostIt* pNote = *itData; if (pNote) { - std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true ); - pTransClip->pDocument->SetNote(aDestPos, std::move(pClonedNote)); + std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), pTransClip->rDocument, aDestPos, true ); + pTransClip->rDocument.SetNote(aDestPos, std::move(pClonedNote)); } } } @@ -1076,7 +1076,7 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC for ( curRow = nBlockStart + nOffsetInBlock; curRow <= nBlockEnd && curRow <= nRowPos; ++curRow) { ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab ); - pTransClip->pDocument->ReleaseNote(aDestPos); + pTransClip->rDocument.ReleaseNote(aDestPos); } if (curRow == nRowPos) break; @@ -1140,8 +1140,8 @@ void ScTable::SetDirtyFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans ) { if ( nCol2 >= aCol.size() ) nCol2 = aCol.size() - 1; - if (nCol2 > pDocument->MaxCol()) nCol2 = pDocument->MaxCol(); - if (nRow2 > pDocument->MaxRow()) nRow2 = pDocument->MaxRow(); + if (nCol2 > rDocument.MaxCol()) nCol2 = rDocument.MaxCol(); + if (nRow2 > rDocument.MaxRow()) nRow2 = rDocument.MaxRow(); if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)) for (SCCOL i = nCol1; i <= nCol2; i++) aCol[i].SetDirtyFromClip(nRow1, nRow2, rBroadcastSpans); @@ -1152,8 +1152,8 @@ void ScTable::StartListeningFormulaCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) { if ( nCol2 >= aCol.size() ) nCol2 = aCol.size() - 1; - if (nCol2 > pDocument->MaxCol()) nCol2 = pDocument->MaxCol(); - if (nRow2 > pDocument->MaxRow()) nRow2 = pDocument->MaxRow(); + if (nCol2 > rDocument.MaxCol()) nCol2 = rDocument.MaxCol(); + if (nRow2 > rDocument.MaxRow()) nRow2 = rDocument.MaxRow(); if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)) for (SCCOL i = nCol1; i <= nCol2; i++) aCol[i].StartListeningFormulaCells(rStartCxt, rEndCxt, nRow1, nRow2); @@ -1167,7 +1167,7 @@ void ScTable::CopyToTable( if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2)) return; - bool bIsUndoDoc = pDestTab->pDocument->IsUndo(); + bool bIsUndoDoc = pDestTab->rDocument.IsUndo(); if (bIsUndoDoc && (nFlags & InsertDeleteFlags::CONTENTS)) { @@ -1183,7 +1183,7 @@ void ScTable::CopyToTable( // tdf#102364 - in some pathological cases CopyToTable() replacing cells with new cells // can lead to repetitive splitting and rejoining of the same formula group, which can get // quadratically expensive with large groups. So do the grouping just once at the end. - sc::DelayFormulaGroupingSwitch delayGrouping( *pDestTab->pDocument, true ); + sc::DelayFormulaGroupingSwitch delayGrouping( pDestTab->rDocument, true ); for (SCCOL i = nCol1; i <= ClampToAllocatedColumns(nCol2); i++) aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bIsUndoDoc ? nFlags : nTempFlags, bMarked, pDestTab->CreateColumnIfNotExists(i), pMarkData, bAsLink, bGlobalNamesToLocal); @@ -1194,7 +1194,7 @@ void ScTable::CopyToTable( if(bIsUndoDoc && (nFlags & InsertDeleteFlags::ATTRIB)) { - pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->pDocument, *mpCondFormatList)); + pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(&pDestTab->rDocument, *mpCondFormatList)); } if (pDBDataNoName) @@ -1208,12 +1208,12 @@ void ScTable::CopyToTable( pDestTab->SetAnonymousDBData(std::move(pNewDBData)); } // Charts have to be adjusted when hide/show - ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection(); + ScChartListenerCollection* pCharts = pDestTab->rDocument.GetChartListenerCollection(); bool bFlagChange = false; - bool bWidth = (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pDestTab->mpColWidth); - bool bHeight = (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pDestTab->mpRowHeights); + bool bWidth = (nRow1==0 && nRow2==rDocument.MaxRow() && mpColWidth && pDestTab->mpColWidth); + bool bHeight = (nCol1==0 && nCol2==rDocument.MaxCol() && mpRowHeights && pDestTab->mpRowHeights); if (bWidth || bHeight) { @@ -1231,7 +1231,7 @@ void ScTable::CopyToTable( pDestTab->SetColHidden(i, i, bThisHidden); //TODO: collect changes? if (bHiddenChange && pCharts) - pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, pDocument->MaxRow(), nTab )); + pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, rDocument.MaxRow(), nTab )); if (bChange) bFlagChange = true; @@ -1264,7 +1264,7 @@ void ScTable::CopyToTable( bool bHiddenChanged = pDestTab->SetRowHidden(i, nLastRow, bHidden); if (bHiddenChanged && pCharts) // Hidden flags differ. - pCharts->SetRangeDirty(ScRange(0, i, nTab, pDocument->MaxCol(), nLastRow, nTab)); + pCharts->SetRangeDirty(ScRange(0, i, nTab, rDocument.MaxCol(), nLastRow, nTab)); if (bHiddenChanged) bFlagChange = true; @@ -1328,8 +1328,8 @@ void ScTable::UndoToTable( if (!(ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))) return; - bool bWidth = (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pDestTab->mpColWidth); - bool bHeight = (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pDestTab->mpRowHeights); + bool bWidth = (nRow1==0 && nRow2==rDocument.MaxRow() && mpColWidth && pDestTab->mpColWidth); + bool bHeight = (nCol1==0 && nCol2==rDocument.MaxCol() && mpRowHeights && pDestTab->mpRowHeights); if ((nFlags & InsertDeleteFlags::CONTENTS) && mpRangeName) { @@ -1337,9 +1337,9 @@ void ScTable::UndoToTable( // formulas. If mpRangeName is not set then the Undo wasn't even // set to an empty ScRangeName map so don't "undo" that. pDestTab->SetRangeName( std::unique_ptr<ScRangeName>( new ScRangeName( *GetRangeName()))); - if (!pDestTab->pDocument->IsClipOrUndo()) + if (!pDestTab->rDocument.IsClipOrUndo()) { - ScDocShell* pDocSh = static_cast<ScDocShell*>(pDestTab->pDocument->GetDocumentShell()); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pDestTab->rDocument.GetDocumentShell()); if (pDocSh) pDocSh->SetAreasChangedNeedBroadcast(); } @@ -1352,11 +1352,11 @@ void ScTable::UndoToTable( if ( i >= nCol1 && i <= nCol2 ) aCol[i].UndoToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, rDestCol); else - aCol[i].CopyToColumn(rCxt, 0, pDocument->MaxRow(), InsertDeleteFlags::FORMULA, false, rDestCol); + aCol[i].CopyToColumn(rCxt, 0, rDocument.MaxRow(), InsertDeleteFlags::FORMULA, false, rDestCol); } if (nFlags & InsertDeleteFlags::ATTRIB) - pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->pDocument, *mpCondFormatList)); + pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(&pDestTab->rDocument, *mpCondFormatList)); if (!(bWidth||bHeight)) return; @@ -1455,7 +1455,7 @@ const ScRangeList* ScTable::GetScenarioRanges() const if (!pScenarioRanges) { const_cast<ScTable*>(this)->pScenarioRanges.reset(new ScRangeList); - ScMarkData aMark(pDocument->GetSheetLimits()); + ScMarkData aMark(rDocument.GetSheetLimits()); MarkScenarioIn( aMark, ScScenarioFlags::NONE ); // always aMark.FillRangeListWithMarks( pScenarioRanges.get(), false ); } @@ -1484,7 +1484,7 @@ bool ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB nTabP, const OUString& rS } return CreateColumnIfNotExists(nCol).SetString( - nRow, nTabP, rString, pDocument->GetAddressConvention(), pParam); + nRow, nTabP, rString, rDocument.GetAddressConvention(), pParam); } bool ScTable::SetEditText( SCCOL nCol, SCROW nRow, std::unique_ptr<EditTextObject> pEditText ) @@ -1515,7 +1515,7 @@ SCROW ScTable::GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW return -1; nCol2 = ClampToAllocatedColumns(nCol2); - SCROW nFirst = pDocument->MaxRow()+1; + SCROW nFirst = rDocument.MaxRow()+1; for (SCCOL i = nCol1; i <= nCol2; ++i) { const ScColumn& rCol = aCol[i]; @@ -1530,7 +1530,7 @@ SCROW ScTable::GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW } } - return nFirst == (pDocument->MaxRow()+1) ? -1 : nFirst; + return nFirst == (rDocument.MaxRow()+1) ? -1 : nFirst; } void ScTable::SetEmptyCell( SCCOL nCol, SCROW nRow ) @@ -1731,19 +1731,19 @@ CommentCaptionState ScTable::GetAllNoteCaptionsState(const ScRange& rRange, std: bool bIsFirstNoteShownState = true; // because of error: -Werror=maybe-uninitialized bool bFirstControl = true; - ScTable* pTab = pDocument->FetchTable(nTab); + ScTable* pTab = rDocument.FetchTable(nTab); assert(pTab); const SCCOL nEndCol = pTab->ClampToAllocatedColumns(rRange.aEnd.Col()); for (SCCOL nCol = rRange.aStart.Col(); nCol <= nEndCol; ++nCol) { - if (bFirstControl && pDocument->HasColNotes(nCol, nTab)) // detect status of first note caption + if (bFirstControl && rDocument.HasColNotes(nCol, nTab)) // detect status of first note caption { aCol[nCol].GetNotesInRange(nStartRow, nEndRow, rNotes); bIsFirstNoteShownState = rNotes.begin()->mpNote->IsCaptionShown(); bFirstControl = false; } - if (pDocument->HasColNotes(nCol, nTab)) + if (rDocument.HasColNotes(nCol, nTab)) { aCol[nCol].GetNotesInRange(nStartRow, nEndRow, rNotes); @@ -1760,7 +1760,7 @@ CommentCaptionState ScTable::GetAllNoteCaptionsState(const ScRange& rRange, std: void ScTable::GetUnprotectedCells( ScRangeList& rRangeList ) const { for (auto const & pCol : aCol) - pCol->GetUnprotectedCells(0, pDocument->MaxRow(), rRangeList); + pCol->GetUnprotectedCells(0, rDocument.MaxRow(), rRangeList); } bool ScTable::ContainsNotesInRange( const ScRange& rRange ) const @@ -1796,7 +1796,7 @@ ScRefCellValue ScTable::GetCellValue( SCCOL nCol, SCROW nRow ) const void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const { rCol = 0; - rRow = pDocument->MaxRow()+1; + rRow = rDocument.MaxRow()+1; while (rCol < (aCol.size() - 1) && aCol[rCol].IsEmptyData() ) ++rCol; SCCOL nCol = rCol; @@ -1815,7 +1815,7 @@ void ScTable::GetLastDataPos(SCCOL& rCol, SCROW& rRow) const while (aCol[rCol].IsEmptyData() && (rCol > 0)) rCol--; SCCOL nCol = rCol; - while (nCol >= 0 && rRow < pDocument->MaxRow()) + while (nCol >= 0 && rRow < rDocument.MaxRow()) rRow = ::std::max( rRow, aCol[nCol--].GetLastDataPos()); } @@ -1865,7 +1865,7 @@ void ScTable::SetDirtyVar() void ScTable::CheckVectorizationState() { - sc::AutoCalcSwitch aACSwitch(*pDocument, false); + sc::AutoCalcSwitch aACSwitch(rDocument, false); for (SCCOL i = 0; i < aCol.size(); i++) aCol[i].CheckVectorizationState(); @@ -1873,7 +1873,7 @@ void ScTable::CheckVectorizationState() void ScTable::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ) { - sc::AutoCalcSwitch aACSwitch(*pDocument, false); + sc::AutoCalcSwitch aACSwitch(rDocument, false); for (SCCOL i=0; i < aCol.size(); i++) aCol[i].SetAllFormulasDirty(rCxt); @@ -1881,46 +1881,46 @@ void ScTable::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ) void ScTable::SetDirty( const ScRange& rRange, ScColumn::BroadcastMode eMode ) { - bool bOldAutoCalc = pDocument->GetAutoCalc(); - pDocument->SetAutoCalc( false ); // avoid multiple recalculations + bool bOldAutoCalc = rDocument.GetAutoCalc(); + rDocument.SetAutoCalc( false ); // avoid multiple recalculations SCCOL nCol2 = rRange.aEnd.Col(); nCol2 = ClampToAllocatedColumns(nCol2); for (SCCOL i=rRange.aStart.Col(); i<=nCol2; i++) aCol[i].SetDirty(rRange.aStart.Row(), rRange.aEnd.Row(), eMode); - pDocument->SetAutoCalc( bOldAutoCalc ); + rDocument.SetAutoCalc( bOldAutoCalc ); } void ScTable::SetTableOpDirty( const ScRange& rRange ) { - bool bOldAutoCalc = pDocument->GetAutoCalc(); - pDocument->SetAutoCalc( false ); // no multiple recalculation + bool bOldAutoCalc = rDocument.GetAutoCalc(); + rDocument.SetAutoCalc( false ); // no multiple recalculation const SCCOL nCol2 = ClampToAllocatedColumns(rRange.aEnd.Col()); for (SCCOL i=rRange.aStart.Col(); i<=nCol2; i++) aCol[i].SetTableOpDirty( rRange ); - pDocument->SetAutoCalc( bOldAutoCalc ); + rDocument.SetAutoCalc( bOldAutoCalc ); } void ScTable::SetDirtyAfterLoad() { - bool bOldAutoCalc = pDocument->GetAutoCalc(); - pDocument->SetAutoCalc( false ); // avoid multiple recalculations + bool bOldAutoCalc = rDocument.GetAutoCalc(); + rDocument.SetAutoCalc( false ); // avoid multiple recalculations for (SCCOL i=0; i < aCol.size(); i++) aCol[i].SetDirtyAfterLoad(); - pDocument->SetAutoCalc( bOldAutoCalc ); + rDocument.SetAutoCalc( bOldAutoCalc ); } void ScTable::SetDirtyIfPostponed() { - bool bOldAutoCalc = pDocument->GetAutoCalc(); - pDocument->SetAutoCalc( false ); // avoid multiple recalculations + bool bOldAutoCalc = rDocument.GetAutoCalc(); + rDocument.SetAutoCalc( false ); // avoid multiple recalculations for (SCCOL i=0; i < aCol.size(); i++) aCol[i].SetDirtyIfPostponed(); - pDocument->SetAutoCalc( bOldAutoCalc ); + rDocument.SetAutoCalc( bOldAutoCalc ); } void ScTable::BroadcastRecalcOnRefMove() { - sc::AutoCalcSwitch aSwitch(*pDocument, false); + sc::AutoCalcSwitch aSwitch(rDocument, false); for (SCCOL i = 0; i < aCol.size(); ++i) aCol[i].BroadcastRecalcOnRefMove(); } @@ -1928,7 +1928,7 @@ void ScTable::BroadcastRecalcOnRefMove() bool ScTable::BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint ) { bool bBroadcasted = false; - sc::AutoCalcSwitch aSwitch(*pDocument, false); + sc::AutoCalcSwitch aSwitch(rDocument, false); rHint.GetAddress().SetTab(nTab); nCol2 = ClampToAllocatedColumns(nCol2); for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) @@ -2026,7 +2026,7 @@ sal_uInt32 ScTable::GetNumberFormat( const ScInterpreterContext& rContext, const sal_uInt32 ScTable::GetNumberFormat( SCCOL nCol, SCROW nRow ) const { if (ValidColRow(nCol,nRow)) - return CreateColumnIfNotExists(nCol).GetNumberFormat(pDocument->GetNonThreadedContext(), nRow); + return CreateColumnIfNotExists(nCol).GetNumberFormat(rDocument.GetNonThreadedContext(), nRow); else return 0; } @@ -2054,7 +2054,7 @@ const ScPatternAttr* ScTable::GetPattern( SCCOL nCol, SCROW nRow ) const else { OSL_FAIL("wrong column or row"); - return pDocument->GetDefPattern(); // for safety + return rDocument.GetDefPattern(); // for safety } } @@ -2234,12 +2234,12 @@ void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCC SCROW nY1 = pRowInfo[0].nRowNo; SCROW nY2 = pRowInfo[nArrCount-1].nRowNo; - for (SCCOL nCol : GetColumnsRange(0, pDocument->MaxCol())) + for (SCCOL nCol : GetColumnsRange(0, rDocument.MaxCol())) { if (!ColHidden(nCol)) { SCSIZE nArrY = 0; - ScDocAttrIterator aIter( pDocument, nTab, nCol, nY1, nCol, nY2 ); + ScDocAttrIterator aIter( &rDocument, nTab, nCol, nY1, nCol, nY2 ); SCCOL nAttrCol; SCROW nAttrRow1, nAttrRow2; const ScPatternAttr* pPattern = aIter.GetNext( nAttrCol, nAttrRow1, nAttrRow2 ); @@ -2253,7 +2253,7 @@ void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCC // handled individually const ScCondFormatIndexes& rCondFormatData = static_cast<const ScCondFormatItem*>(pCondItem)->GetCondFormatData(); - ScStyleSheetPool* pStylePool = pDocument->GetStyleSheetPool(); + ScStyleSheetPool* pStylePool = rDocument.GetStyleSheetPool(); if (mpCondFormatList && pStylePool && !rCondFormatData.empty()) { for(const auto& rItem : rCondFormatData) @@ -2427,7 +2427,7 @@ bool ScTable::IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, bool bIsEditable = true; if ( nLockCount ) bIsEditable = false; - else if ( IsProtected() && !pDocument->IsScenario(nTab) ) + else if ( IsProtected() && !rDocument.IsScenario(nTab) ) { bIsEditable = !HasAttrib( nCol1, nRow1, nCol2, nRow2, HasAttrFlags::Protected ); if (!bIsEditable) @@ -2443,13 +2443,13 @@ bool ScTable::IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, // on the active scenario range. Note the 'copy back' must also // be set to apply protection. sal_uInt16 nScenTab = nTab+1; - while(pDocument->IsScenario(nScenTab)) + while(rDocument.IsScenario(nScenTab)) { ScRange aEditRange(nCol1, nRow1, nScenTab, nCol2, nRow2, nScenTab); - if(pDocument->IsActiveScenario(nScenTab) && pDocument->HasScenarioRange(nScenTab, aEditRange)) + if(rDocument.IsActiveScenario(nScenTab) && rDocument.HasScenarioRange(nScenTab, aEditRange)) { ScScenarioFlags nFlags; - pDocument->GetScenarioFlags(nScenTab,nFlags); + rDocument.GetScenarioFlags(nScenTab,nFlags); bIsEditable = !((nFlags & ScScenarioFlags::Protected) && (nFlags & ScScenarioFlags::TwoWay)); break; } @@ -2457,7 +2457,7 @@ bool ScTable::IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, } } } - else if (pDocument->IsScenario(nTab)) + else if (rDocument.IsScenario(nTab)) { // Determine if the preceding sheet is protected SCTAB nActualTab = nTab; @@ -2465,15 +2465,15 @@ bool ScTable::IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, { nActualTab--; } - while(pDocument->IsScenario(nActualTab)); + while(rDocument.IsScenario(nActualTab)); - if(pDocument->IsTabProtected(nActualTab)) + if(rDocument.IsTabProtected(nActualTab)) { ScRange aEditRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab); - if(pDocument->HasScenarioRange(nTab, aEditRange)) + if(rDocument.HasScenarioRange(nTab, aEditRange)) { ScScenarioFlags nFlags; - pDocument->GetScenarioFlags(nTab,nFlags); + rDocument.GetScenarioFlags(nTab,nFlags); bIsEditable = !(nFlags & ScScenarioFlags::Protected); } } @@ -2500,7 +2500,7 @@ bool ScTable::IsSelectionEditable( const ScMarkData& rMark, bool bIsEditable = true; if ( nLockCount ) bIsEditable = false; - else if ( IsProtected() && !pDocument->IsScenario(nTab) ) + else if ( IsProtected() && !rDocument.IsScenario(nTab) ) { ScRangeList aRanges; rMark.FillRangeListWithMarks( &aRanges, false ); @@ -2517,17 +2517,17 @@ bool ScTable::IsSelectionEditable( const ScMarkData& rMark, // check the active scenario protect flag if this area is // in the active scenario range. SCTAB nScenTab = nTab+1; - while(pDocument->IsScenario(nScenTab) && bIsEditable) + while(rDocument.IsScenario(nScenTab) && bIsEditable) { - if(pDocument->IsActiveScenario(nScenTab)) + if(rDocument.IsActiveScenario(nScenTab)) { for (size_t i=0, nRange = aRanges.size(); (i < nRange) && bIsEditable; i++ ) { const ScRange & rRange = aRanges[ i ]; - if(pDocument->HasScenarioRange(nScenTab, rRange)) + if(rDocument.HasScenarioRange(nScenTab, rRange)) { ScScenarioFlags nFlags; - pDocument->GetScenarioFlags(nScenTab,nFlags); + rDocument.GetScenarioFlags(nScenTab,nFlags); bIsEditable = !((nFlags & ScScenarioFlags::Protected) && (nFlags & ScScenarioFlags::TwoWay)); } } @@ -2536,7 +2536,7 @@ bool ScTable::IsSelectionEditable( const ScMarkData& rMark, } } } - else if (pDocument->IsScenario(nTab)) + else if (rDocument.IsScenario(nTab)) { // Determine if the preceding sheet is protected SCTAB nActualTab = nTab; @@ -2544,19 +2544,19 @@ bool ScTable::IsSelectionEditable( const ScMarkData& rMark, { nActualTab--; } - while(pDocument->IsScenario(nActualTab)); + while(rDocument.IsScenario(nActualTab)); - if(pDocument->IsTabProtected(nActualTab)) + if(rDocument.IsTabProtected(nActualTab)) { ScRangeList aRanges; rMark.FillRangeListWithMarks( &aRanges, false ); for (size_t i = 0, nRange = aRanges.size(); (i < nRange) && bIsEditable; i++) { const ScRange & rRange = aRanges[ i ]; - if(pDocument->HasScenarioRange(nTab, rRange)) + if(rDocument.HasScenarioRange(nTab, rRange)) { ScScenarioFlags nFlags; - pDocument->GetScenarioFlags(nTab,nFlags); + rDocument.GetScenarioFlags(nTab,nFlags); bIsEditable = !(nFlags & ScScenarioFlags::Protected); } } @@ -2736,7 +2736,7 @@ void ScTable::ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, S PutInOrder(nStartCol, nEndCol); PutInOrder(nStartRow, nEndRow); - if ( nEndCol == pDocument->MaxCol() ) + if ( nEndCol == rDocument.MaxCol() ) { if ( nStartCol < aCol.size() ) { @@ -2858,13 +2858,13 @@ void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRem double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY ) { - ScFlatBoolRowSegments aUsedRows(pDocument->MaxRow()); + ScFlatBoolRowSegments aUsedRows(rDocument.MaxRow()); for (SCCOL i = 0; i < aCol.size(); ++i) aCol[i].FindStyleSheet(pStyleSheet, aUsedRows, bRemoved); - sc::RowHeightContext aCxt(pDocument->MaxRow(), nPPTX, nPPTY, rZoomX, rZoomY, pDev); + sc::RowHeightContext aCxt(rDocument.MaxRow(), nPPTX, nPPTY, rZoomX, rZoomY, pDev); SCROW nRow = 0; - while (nRow <= pDocument->MaxRow()) + while (nRow <= rDocument.MaxRow()) { ScFlatBoolRowSegments::RangeData aData; if (!aUsedRows.getRangeData(nRow, aData)) @@ -3050,7 +3050,7 @@ bool ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNew } bool bSingle = false; // true = process every row for its own - ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); + ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer(); if (pDrawLayer) if (pDrawLayer->HasObjectsInRows( nTab, nStartRow, nEndRow )) bSingle = true; @@ -3170,7 +3170,7 @@ sal_uInt16 ScTable::GetCommonWidth( SCCOL nEndCol ) const if ( !ValidCol(nEndCol) ) { OSL_FAIL("wrong column"); - nEndCol = pDocument->MaxCol(); + nEndCol = rDocument.MaxCol(); } sal_uInt16 nMaxWidth = 0; @@ -3379,9 +3379,9 @@ void ScTable::ShowCol(SCCOL nCol, bool bShow) { SetColHidden(nCol, nCol, !bShow); - ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); + ScChartListenerCollection* pCharts = rDocument.GetChartListenerCollection(); if ( pCharts ) - pCharts->SetRangeDirty(ScRange( nCol, 0, nTab, nCol, pDocument->MaxRow(), nTab )); + pCharts->SetRangeDirty(ScRange( nCol, 0, nTab, nCol, rDocument.MaxRow(), nTab )); } } else @@ -3400,9 +3400,9 @@ void ScTable::ShowRow(SCROW nRow, bool bShow) SetRowHidden(nRow, nRow, !bShow); if (bShow) SetRowFiltered(nRow, nRow, false); - ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); + ScChartListenerCollection* pCharts = rDocument.GetChartListenerCollection(); if ( pCharts ) - pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, pDocument->MaxCol(), nRow, nTab )); + pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, rDocument.MaxCol(), nRow, nTab )); InvalidatePageBreaks(); } @@ -3423,9 +3423,9 @@ void ScTable::DBShowRow(SCROW nRow, bool bShow) if (bChanged) { - ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); + ScChartListenerCollection* pCharts = rDocument.GetChartListenerCollection(); if ( pCharts ) - pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, pDocument->MaxCol(), nRow, nTab )); + pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, rDocument.MaxCol(), nRow, nTab )); if (pOutlineTable) UpdateOutlineRow( nRow, nRow, bShow ); @@ -3456,9 +3456,9 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow) if ( bChanged ) { - ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); + ScChartListenerCollection* pCharts = rDocument.GetChartListenerCollection(); if ( pCharts ) - pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, pDocument->MaxCol(), nEndRow, nTab )); + pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, rDocument.MaxCol(), nEndRow, nTab )); } nStartRow = nEndRow + 1; @@ -3476,7 +3476,7 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow) SCROW nStartRow = nRow1; // #i116164# if there are no drawing objects within the row range, a single HeightChanged call is enough - ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); + ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer(); bool bHasObjects = pDrawLayer && pDrawLayer->HasObjectsInRows( nTab, nRow1, nRow2 ); while (nStartRow <= nRow2) @@ -3494,9 +3494,9 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow) if ( bChanged ) { - ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); + ScChartListenerCollection* pCharts = rDocument.GetChartListenerCollection(); if ( pCharts ) - pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, pDocument->MaxCol(), nEndRow, nTab )); + pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, rDocument.MaxCol(), nEndRow, nTab )); InvalidatePageBreaks(); } @@ -3657,7 +3657,7 @@ void ScTable::ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ) while (rX1 > 0 && ColHidden(rX1-1)) --rX1; - while (rX2 < pDocument->MaxCol() && ColHidden(rX2+1)) + while (rX2 < rDocument.MaxCol() && ColHidden(rX2+1)) ++rX2; // Row-wise expansion @@ -3672,7 +3672,7 @@ void ScTable::ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ) rY1 = nStartRow; } } - if (rY2 < pDocument->MaxRow()) + if (rY2 < rDocument.MaxRow()) { SCROW nEndRow = -1; if (RowHidden(rY2+1, nullptr, &nEndRow) && ValidRow(nEndRow)) @@ -3767,7 +3767,7 @@ void ScTable::DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SC // Rows - UsedRowsType aUsed(0, pDocument->MaxRow()+1, false); + UsedRowsType aUsed(0, rDocument.MaxRow()+1, false); for (nCol=nStartCol; nCol<=nEndCol; nCol++) aCol[nCol].FindUsed(nStartRow, nEndRow, aUsed); aUsed.build_tree(); @@ -3842,11 +3842,11 @@ void ScTable::CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW n aSrc.SetCol( nCol ); aDest.SetCol( nDestX ); ScCellValue aCell; - aCell.assign(*pDocument, ScAddress(nCol, nRow, nTab)); + aCell.assign(rDocument, ScAddress(nCol, nRow, nTab)); if (aCell.meType == CELLTYPE_FORMULA) { - sc::RefUpdateContext aCxt(*pDocument); + sc::RefUpdateContext aCxt(rDocument); aCxt.meMode = URM_COPY; aCxt.maRange = aRange; aCxt.mnColDelta = nDestCol - nStartCol; @@ -3863,8 +3863,8 @@ void ScTable::CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW n } else { - aCell.release(*pDocument, aDest); - pDocument->SetPattern( aDest, *GetPattern( nCol, nRow ) ); + aCell.release(rDocument, aDest); + rDocument.SetPattern( aDest, *GetPattern( nCol, nRow ) ); } ++nDestX; @@ -3905,11 +3905,11 @@ void ScTable::GetUpperCellString(SCCOL nCol, SCROW nRow, OUString& rStr) void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos) { - ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); + ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer(); if( pDrawLayer ) { - double fValX = GetColOffset( pDocument->MaxCol() + 1 ) * HMM_PER_TWIPS; - double fValY = GetRowOffset( pDocument->MaxRow() + 1 ) * HMM_PER_TWIPS; + double fValX = GetColOffset( rDocument.MaxCol() + 1 ) * HMM_PER_TWIPS; + double fValY = GetRowOffset( rDocument.MaxRow() + 1 ) * HMM_PER_TWIPS; const long nMax = ::std::numeric_limits<long>::max(); // #i113884# Avoid int32 overflow with possible negative results than can cause bad effects. // If the draw page size is smaller than all rows, only the bottom of the sheet is affected. @@ -3976,7 +3976,7 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const aRowHeightRange.mnRow2 = -1; aRowHeightRange.mnValue = 0; // silence MSVC C4701 - for (SCROW nRow = 0; nRow <= pDocument->MaxRow(); ++nRow) + for (SCROW nRow = 0; nRow <= rDocument.MaxRow(); ++nRow) { if (!mpHiddenRows->getRangeData(nRow, aData)) // Failed to fetch the range data for whatever reason. @@ -4000,8 +4000,8 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const if (nSum > nHeight) { - if (nRow >= pDocument->MaxRow()) - return pDocument->MaxRow(); + if (nRow >= rDocument.MaxRow()) + return rDocument.MaxRow(); // Find the next visible row. ++nRow; @@ -4014,7 +4014,7 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const // These rows are hidden. nRow = aData.mnRow2 + 1; - return nRow <= pDocument->MaxRow() ? nRow : pDocument->MaxRow(); + return nRow <= rDocument.MaxRow() ? nRow : rDocument.MaxRow(); } } return -1; diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 7a34da65b1ca..1c8d5db104bc 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -957,12 +957,12 @@ void ScTable::SortReorderByColumn( // Get all area listeners that listen on one column within the range // and end their listening. ScRange aMoveRange( nStart, nRow1, nTab, nLast, nRow2, nTab); - std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners( + std::vector<sc::AreaListener> aAreaListeners = rDocument.GetBASM()->GetAllListeners( aMoveRange, sc::AreaOverlapType::OneColumnInside); { for (auto& rAreaListener : aAreaListeners) { - pDocument->EndListeningArea(rAreaListener.maArea, rAreaListener.mbGroupListening, rAreaListener.mpListener); + rDocument.EndListeningArea(rAreaListener.maArea, rAreaListener.mbGroupListening, rAreaListener.mpListener); aListeners.push_back( rAreaListener.mpListener); } } @@ -986,7 +986,7 @@ void ScTable::SortReorderByColumn( aNewRange.aStart.SetCol( itCol->second); aNewRange.aEnd.SetCol( itCol->second); } - pDocument->StartListeningArea(aNewRange, rAreaListener.mbGroupListening, rAreaListener.mpListener); + rDocument.StartListeningArea(aNewRange, rAreaListener.mbGroupListening, rAreaListener.mpListener); } } } @@ -1005,7 +1005,7 @@ void ScTable::SortReorderByColumn( sc::CellStoreType& rCells = aCol[nCol].maCells; sc::CellStoreType::position_type aPos = rCells.position(nRow1); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); - if (nRow2 < pDocument->MaxRow()) + if (nRow2 < rDocument.MaxRow()) { aPos = rCells.position(aPos.first, nRow2+1); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); @@ -1031,7 +1031,7 @@ void ScTable::SortReorderByRow( // cells in the sorted range before reordering, and re-start them // afterward. { - sc::EndListeningContext aCxt(*pDocument); + sc::EndListeningContext aCxt(rDocument); DetachFormulaCells(aCxt, nCol1, nRow1, nCol2, nRow2); } @@ -1106,13 +1106,13 @@ void ScTable::SortReorderByRow( for (const auto& rSpan : aSpans) { assert(rSpan.mpPattern); // should never be NULL. - pDocument->GetPool()->Put(*rSpan.mpPattern); + rDocument.GetPool()->Put(*rSpan.mpPattern); } for (const auto& rSpan : aSpans) { aCol[nThisCol].SetPatternArea(rSpan.mnRow1, rSpan.mnRow2, *rSpan.mpPattern); - pDocument->GetPool()->Remove(*rSpan.mpPattern); + rDocument.GetPool()->Remove(*rSpan.mpPattern); } } @@ -1152,7 +1152,7 @@ void ScTable::SortReorderByRow( aCol[i].RegroupFormulaCells(); { - sc::StartListeningContext aCxt(*pDocument); + sc::StartListeningContext aCxt(rDocument); AttachFormulaCells(aCxt, nCol1, nRow1, nCol2, nRow2); } } @@ -1175,7 +1175,7 @@ void ScTable::SortReorderByRowRefUpdate( // Get the range of formula group listeners within sorted range (if any). sc::QueryRange aQuery; - ScBroadcastAreaSlotMachine* pBASM = pDocument->GetBASM(); + ScBroadcastAreaSlotMachine* pBASM = rDocument.GetBASM(); std::vector<sc::AreaListener> aGrpListeners = pBASM->GetAllListeners( aMoveRange, sc::AreaOverlapType::InsideOrOverlap, sc::ListenerGroupType::Group); @@ -1186,7 +1186,7 @@ void ScTable::SortReorderByRowRefUpdate( assert(rGrpListener.mbGroupListening); SvtListener* pGrpLis = rGrpListener.mpListener; pGrpLis->Query(aQuery); - pDocument->EndListeningArea(rGrpListener.maArea, rGrpListener.mbGroupListening, pGrpLis); + rDocument.EndListeningArea(rGrpListener.maArea, rGrpListener.mbGroupListening, pGrpLis); } } @@ -1303,13 +1303,13 @@ void ScTable::SortReorderByRowRefUpdate( for (const auto& rSpan : aSpans) { assert(rSpan.mpPattern); // should never be NULL. - pDocument->GetPool()->Put(*rSpan.mpPattern); + rDocument.GetPool()->Put(*rSpan.mpPattern); } for (const auto& rSpan : aSpans) { aCol[nThisCol].SetPatternArea(rSpan.mnRow1, rSpan.mnRow2, *rSpan.mpPattern); - pDocument->GetPool()->Remove(*rSpan.mpPattern); + rDocument.GetPool()->Remove(*rSpan.mpPattern); } } @@ -1356,12 +1356,12 @@ void ScTable::SortReorderByRowRefUpdate( // Get all area listeners that listen on one row within the range and end // their listening. - std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners( + std::vector<sc::AreaListener> aAreaListeners = rDocument.GetBASM()->GetAllListeners( aMoveRange, sc::AreaOverlapType::OneRowInside); { for (auto& rAreaListener : aAreaListeners) { - pDocument->EndListeningArea(rAreaListener.maArea, rAreaListener.mbGroupListening, rAreaListener.mpListener); + rDocument.EndListeningArea(rAreaListener.maArea, rAreaListener.mbGroupListening, rAreaListener.mpListener); aListeners.push_back( rAreaListener.mpListener); } } @@ -1371,7 +1371,7 @@ void ScTable::SortReorderByRowRefUpdate( std::vector<ScFormulaCell*> aFCells; FormulaCellCollectAction aAction(aFCells); - aGrpListenerRanges.executeColumnAction(*pDocument, aAction); + aGrpListenerRanges.executeColumnAction(rDocument, aAction); aListeners.insert( aListeners.end(), aFCells.begin(), aFCells.end() ); } @@ -1393,7 +1393,7 @@ void ScTable::SortReorderByRowRefUpdate( for (const auto& [nCol, rCol] : rCols) { std::vector<SCROW> aBounds(rCol); - pDocument->UnshareFormulaCells(rTab, nCol, aBounds); + rDocument.UnshareFormulaCells(rTab, nCol, aBounds); } } @@ -1405,7 +1405,7 @@ void ScTable::SortReorderByRowRefUpdate( for (const auto& [rTab, rCols] : rGroupTabs) { for (const auto& rEntry : rCols) - pDocument->RegroupFormulaCells(rTab, rEntry.first); + rDocument.RegroupFormulaCells(rTab, rEntry.first); } // Re-start area listeners on the reordered rows. @@ -1418,7 +1418,7 @@ void ScTable::SortReorderByRowRefUpdate( aNewRange.aStart.SetRow( itRow->second); aNewRange.aEnd.SetRow( itRow->second); } - pDocument->StartListeningArea(aNewRange, rAreaListener.mbGroupListening, rAreaListener.mpListener); + rDocument.StartListeningArea(aNewRange, rAreaListener.mbGroupListening, rAreaListener.mpListener); } // Re-group columns in the sorted range too. @@ -1427,8 +1427,8 @@ void ScTable::SortReorderByRowRefUpdate( { // Re-start area listeners on the old group listener ranges. - ListenerStartAction aAction(*pDocument); - aGrpListenerRanges.executeColumnAction(*pDocument, aAction); + ListenerStartAction aAction(rDocument); + aGrpListenerRanges.executeColumnAction(rDocument, aAction); } } @@ -1876,7 +1876,7 @@ void ScTable::RemoveSubTotals( ScSubTotalParam& rParam ) std::for_each(aRows.rbegin(), aRows.rend(), [this](const SCROW nRow) { RemoveRowBreak(nRow+1, false, true); - pDocument->DeleteRow(0, nTab, pDocument->MaxCol(), nTab, nRow, 1); + rDocument.DeleteRow(0, nTab, rDocument.MaxCol(), nTab, nRow, 1); }); rParam.nRow2 -= aRows.size(); @@ -1946,7 +1946,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) sal_uInt16 i; // Remove empty rows at the end - // so that all exceeding (pDocument->MaxRow()) can be found by InsertRow (#35180#) + // so that all exceeding (rDocument.MaxRow()) can be found by InsertRow (#35180#) // If sorted, all empty rows are at the end. SCSIZE nEmpty = GetEmptyLinesInBlock( nStartCol, nStartRow, nEndCol, nEndRow, DIR_BOTTOM ); nEndRow -= nEmpty; @@ -1977,7 +1977,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) //TODO: sort? - ScStyleSheet* pStyle = static_cast<ScStyleSheet*>(pDocument->GetStyleSheetPool()->Find( + ScStyleSheet* pStyle = static_cast<ScStyleSheet*>(rDocument.GetStyleSheetPool()->Find( ScResId(STR_STYLENAME_RESULT), SfxStyleFamily::Para )); bool bSpaceLeft = true; // Success when inserting? @@ -2042,10 +2042,10 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) aRowEntry.nFuncStart = aRowEntry.nSubStartRow; aRowEntry.nFuncEnd = nRow-1; - bSpaceLeft = pDocument->InsertRow( 0, nTab, pDocument->MaxCol(), nTab, + bSpaceLeft = rDocument.InsertRow( 0, nTab, rDocument.MaxCol(), nTab, aRowEntry.nDestRow, 1 ); DBShowRow( aRowEntry.nDestRow, bBlockVis ); - if ( rParam.bPagebreak && nRow < pDocument->MaxRow() && + if ( rParam.bPagebreak && nRow < rDocument.MaxRow() && aRowEntry.nSubStartRow != nStartRow && nLevel == 0) SetRowBreak(aRowEntry.nSubStartRow, false, true); @@ -2131,7 +2131,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) // increment row nGlobalEndFunc++; - bSpaceLeft = pDocument->InsertRow(0, nTab, pDocument->MaxCol(), nTab, aRowEntry.nDestRow, 1); + bSpaceLeft = rDocument.InsertRow(0, nTab, rDocument.MaxCol(), nTab, aRowEntry.nDestRow, 1); if (bSpaceLeft) { @@ -2164,7 +2164,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) aRef.Ref2.SetAbsCol(nResCols[nResult]); aRef.Ref2.SetAbsRow(rRowEntry.nFuncEnd); - ScTokenArray aArr(*pDocument); + ScTokenArray aArr(rDocument); aArr.AddOpCode( ocSubTotal ); aArr.AddOpCode( ocOpen ); aArr.AddDouble( static_cast<double>(pResFunc[nResult]) ); @@ -2173,7 +2173,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) aArr.AddOpCode( ocClose ); aArr.AddOpCode( ocStop ); ScFormulaCell* pCell = new ScFormulaCell( - pDocument, ScAddress(nResCols[nResult], rRowEntry.nDestRow, nTab), aArr); + &rDocument, ScAddress(nResCols[nResult], rRowEntry.nDestRow, nTab), aArr); if ( rParam.bIncludePattern ) pCell->SetNeedNumberFormat(true); @@ -2749,7 +2749,7 @@ bool ScTable::ValidQuery( bool* pTest = ( nEntryCount <= nFixedBools ? &aTest[0] : new bool[nEntryCount] ); long nPos = -1; - QueryEvaluator aEval(*pDocument, *this, rParam, pbTestEqualCondition != nullptr); + QueryEvaluator aEval(rDocument, *this, rParam, pbTestEqualCondition != nullptr); ScQueryParam::const_iterator it, itBeg = rParam.begin(), itEnd = rParam.end(); for (it = itBeg; it != itEnd && (*it)->bDoQuery; ++it) { @@ -3068,7 +3068,7 @@ SCSIZE ScTable::Query(const ScQueryParam& rParamOrg, bool bKeepSub) SCROW nOutRow = 0; SCROW nHeader = aParam.bHasHeader ? 1 : 0; - lcl_PrepareQuery(pDocument, this, aParam); + lcl_PrepareQuery(&rDocument, this, aParam); if (!aParam.bInplace) { @@ -3178,7 +3178,7 @@ bool ScTable::CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow if ( nTab == nDBTab ) GetUpperCellString(i, nDBRow1, aCellStr); else - pDocument->GetUpperCellString(i, nDBRow1, nDBTab, aCellStr); + rDocument.GetUpperCellString(i, nDBRow1, nDBTab, aCellStr); bFound = (aCellStr == aQueryStr); if (!bFound) i++; } @@ -3205,7 +3205,7 @@ bool ScTable::CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow SCSIZE nIndex = 0; SCROW nRow = nRow1 + 1; - svl::SharedStringPool& rPool = pDocument->GetSharedStringPool(); + svl::SharedStringPool& rPool = rDocument.GetSharedStringPool(); while (nRow <= nRow2) { nCol = nCol1; @@ -3259,7 +3259,7 @@ bool ScTable::CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 SCSIZE nNewEntries = static_cast<SCSIZE>(nRow2-nRow1+1); rQueryParam.Resize( nNewEntries ); - svl::SharedStringPool& rPool = pDocument->GetSharedStringPool(); + svl::SharedStringPool& rPool = rDocument.GetSharedStringPool(); do { ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits