diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-15 12:22:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-09-16 18:04:44 +0200 |
commit | 91313ea13f9dc846a141e5106fb9ba2f70a970f5 (patch) | |
tree | bf3f03929b5fc8f5609317c6b481154ee4070f22 | |
parent | 17bc0abdbe2ec7bd8068fdf963339a6883c19653 (diff) |
ScAttrArray never has a null ScDocument* member
Change-Id: I06e4190235799d6ff231179ae3bbc8f76d4a3342
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102867
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/inc/attarray.hxx | 6 | ||||
-rw-r--r-- | sc/inc/column.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/attarray.cxx | 250 | ||||
-rw-r--r-- | sc/source/core/data/cellvalue.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 198 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 160 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 258 | ||||
-rw-r--r-- | sc/source/core/data/column4.cxx | 114 | ||||
-rw-r--r-- | sc/source/core/data/dociter.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/table4.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/scopetools.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 4 |
13 files changed, 508 insertions, 508 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx index b0238adcdd78..7489cbc627b3 100644 --- a/sc/inc/attarray.hxx +++ b/sc/inc/attarray.hxx @@ -88,7 +88,7 @@ class ScAttrArray private: SCCOL nCol; SCTAB nTab; - ScDocument* const pDocument; + ScDocument& rDocument; std::vector<ScAttrEntry> mvData; @@ -110,10 +110,10 @@ friend class ScHorizontalAttrIterator; ScAttrArray& operator=(const ScAttrArray&) = delete; public: - ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttrArray* pNextColAttrArray ); + ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, ScAttrArray* pNextColAttrArray ); ~ScAttrArray(); - ScDocument* GetDoc() { return pDocument; } + ScDocument& GetDoc() { return rDocument; } void SetTab(SCTAB nNewTab) { nTab = nNewTab; } void SetCol(SCCOL nNewCol) { nCol = nNewCol; } #if DEBUG_SC_TESTATTRARRAY diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index aeb978fbc391..40298a3b52d7 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -179,7 +179,7 @@ public: void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, bool bEmptyAttrArray); - ScDocument* GetDoc() const { return pAttrArray->GetDoc(); } + ScDocument& GetDoc() const { return pAttrArray->GetDoc(); } SCTAB GetTab() const { return nTab; } SCCOL GetCol() const { return nCol; } sc::CellStoreType& GetCellStore() { return maCells; } diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 06f8638038e9..6a6e59890d45 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -47,10 +47,10 @@ using ::editeng::SvxBorderLine; -ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttrArray* pDefaultColAttrArray ) : +ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, ScAttrArray* pDefaultColAttrArray ) : nCol( nNewCol ), nTab( nNewTab ), - pDocument( pDoc ) + rDocument( rDoc ) { if ( nCol == -1 || !pDefaultColAttrArray || pDefaultColAttrArray->mvData.empty() ) return; @@ -62,14 +62,14 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttr { mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow; ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) ); - mvData[nIdx].pPattern = &pDocument->GetPool()->Put( aNewPattern ); + mvData[nIdx].pPattern = &rDocument.GetPool()->Put( aNewPattern ); bool bNumFormatChanged = false; if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, - mvData[nIdx].pPattern->GetItemSet(), pDocument->GetDefPattern()->GetItemSet() ) ) + mvData[nIdx].pPattern->GetItemSet(), rDocument.GetDefPattern()->GetItemSet() ) ) { aAdrStart.SetRow( nIdx ? mvData[nIdx-1].nEndRow+1 : 0 ); aAdrEnd.SetRow( mvData[nIdx].nEndRow ); - pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); + rDocument.InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); } } } @@ -80,7 +80,7 @@ ScAttrArray::~ScAttrArray() TestData(); #endif - ScDocumentPool* pDocPool = pDocument->GetPool(); + ScDocumentPool* pDocPool = rDocument.GetPool(); for (auto const & rEntry : mvData) pDocPool->Remove(*rEntry.pPattern); } @@ -99,7 +99,7 @@ void ScAttrArray::TestData() const if (mvData[nPos].pPattern->Which() != ATTR_PATTERN) ++nErr; } - if ( nPos && mvData[nPos-1].nRow != pDocument->MaxRow() ) + if ( nPos && mvData[nPos-1].nRow != rDocument.MaxRow() ) ++nErr; SAL_WARN_IF( nErr, "sc", nErr << " errors in attribute array, column " << nCol ); @@ -114,13 +114,13 @@ void ScAttrArray::SetDefaultIfNotInit( SCSIZE nNeeded ) SCSIZE nNewLimit = std::max<SCSIZE>( SC_ATTRARRAY_DELTA, nNeeded ); mvData.reserve( nNewLimit ); mvData.emplace_back(); - mvData[0].nEndRow = pDocument->MaxRow(); - mvData[0].pPattern = pDocument->GetDefPattern(); // no put + mvData[0].nEndRow = rDocument.MaxRow(); + mvData[0].pPattern = rDocument.GetDefPattern(); // no put } void ScAttrArray::Reset( const ScPatternAttr* pPattern ) { - ScDocumentPool* pDocPool = pDocument->GetPool(); + ScDocumentPool* pDocPool = rDocument.GetPool(); ScAddress aAdrStart( nCol, 0, nTab ); ScAddress aAdrEnd ( nCol, 0, nTab ); @@ -136,18 +136,18 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern ) { aAdrStart.SetRow( i ? mvData[i-1].nEndRow+1 : 0 ); aAdrEnd .SetRow( mvData[i].nEndRow ); - pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); + rDocument.InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); } } pDocPool->Remove(*pOldPattern); } mvData.resize(0); - pDocument->SetStreamValid(nTab, false); + rDocument.SetStreamValid(nTab, false); mvData.resize(1); const ScPatternAttr* pNewPattern = &pDocPool->Put(*pPattern); - mvData[0].nEndRow = pDocument->MaxRow(); + mvData[0].nEndRow = rDocument.MaxRow(); mvData[0].pPattern = pNewPattern; } @@ -161,7 +161,7 @@ bool ScAttrArray::Concat(SCSIZE nPos) if (mvData[nPos - 1].pPattern == mvData[nPos].pPattern) { mvData[nPos - 1].nEndRow = mvData[nPos].nEndRow; - pDocument->GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->Remove(*mvData[nPos].pPattern); mvData.erase(mvData.begin() + nPos); nPos--; bRet = true; @@ -172,7 +172,7 @@ bool ScAttrArray::Concat(SCSIZE nPos) if (mvData[nPos + 1].pPattern == mvData[nPos].pPattern) { mvData[nPos].nEndRow = mvData[nPos + 1].nEndRow; - pDocument->GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->Remove(*mvData[nPos].pPattern); mvData.erase(mvData.begin() + nPos + 1); bRet = true; } @@ -240,9 +240,9 @@ const ScPatternAttr* ScAttrArray::GetPattern( SCROW nRow ) const { if ( mvData.empty() ) { - if ( !pDocument->ValidRow(nRow) ) + if ( !rDocument.ValidRow(nRow) ) return nullptr; - return pDocument->GetDefPattern(); + return rDocument.GetDefPattern(); } SCSIZE i; if (Search( nRow, i )) @@ -256,11 +256,11 @@ const ScPatternAttr* ScAttrArray::GetPatternRange( SCROW& rStartRow, { if ( mvData.empty() ) { - if ( !pDocument->ValidRow( nRow ) ) + if ( !rDocument.ValidRow( nRow ) ) return nullptr; rStartRow = 0; - rEndRow = pDocument->MaxRow(); - return pDocument->GetDefPattern(); + rEndRow = rDocument.MaxRow(); + return rDocument.GetDefPattern(); } SCSIZE nIndex; if ( Search( nRow, nIndex ) ) @@ -277,7 +277,7 @@ const ScPatternAttr* ScAttrArray::GetPatternRange( SCROW& rStartRow, void ScAttrArray::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ) { - if(!pDocument->ValidRow(nStartRow) || !pDocument->ValidRow(nEndRow)) + if(!rDocument.ValidRow(nStartRow) || !rDocument.ValidRow(nEndRow)) return; if(nEndRow < nStartRow) @@ -322,7 +322,7 @@ void ScAttrArray::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nInd } else { - pNewPattern.reset( new ScPatternAttr( pDocument->GetPool() ) ); + pNewPattern.reset( new ScPatternAttr( rDocument.GetPool() ) ); ScCondFormatItem aItem(nIndex); pNewPattern->GetItemSet().Put( aItem ); nTempEndRow = nEndRow; @@ -337,7 +337,7 @@ void ScAttrArray::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nInd void ScAttrArray::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ) { - if(!pDocument->ValidRow(nStartRow) || !pDocument->ValidRow(nEndRow)) + if(!rDocument.ValidRow(nStartRow) || !rDocument.ValidRow(nEndRow)) return; if(nEndRow < nStartRow) @@ -400,11 +400,11 @@ void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow, assert( nCol != -1 ); // cache mdds position, this doesn't modify the mdds container, just EditTextObject's sc::ColumnBlockPosition blockPos; - pDocument->InitColumnBlockPosition( blockPos, nTab, nCol ); + rDocument.InitColumnBlockPosition( blockPos, nTab, nCol ); for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow) { ScAddress aPos(nCol, nRow, nTab); - ScRefCellValue aCell(*pDocument, aPos, blockPos); + ScRefCellValue aCell(rDocument, aPos, blockPos); if (aCell.meType != CELLTYPE_EDIT || !aCell.mpEditText) continue; @@ -431,8 +431,8 @@ bool ScAttrArray::Reserve( SCSIZE nReserve ) try { mvData.reserve(nReserve); mvData.emplace_back(); - mvData[0].nEndRow = pDocument->MaxRow(); - mvData[0].pPattern = pDocument->GetDefPattern(); // no put + mvData[0].nEndRow = rDocument.MaxRow(); + mvData[0].pPattern = rDocument.GetDefPattern(); // no put return true; } catch (std::bad_alloc const &) { return false; @@ -454,16 +454,16 @@ bool ScAttrArray::Reserve( SCSIZE nReserve ) const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern, bool bPutToPool, ScEditDataArray* pDataArray, bool bPassingOwnership ) { - if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)) + if (rDocument.ValidRow(nStartRow) && rDocument.ValidRow(nEndRow)) { if (bPutToPool) { if (bPassingOwnership) - pPattern = &pDocument->GetPool()->Put(std::unique_ptr<ScPatternAttr>(const_cast<ScPatternAttr*>(pPattern))); + pPattern = &rDocument.GetPool()->Put(std::unique_ptr<ScPatternAttr>(const_cast<ScPatternAttr*>(pPattern))); else - pPattern = &pDocument->GetPool()->Put(*pPattern); + pPattern = &rDocument.GetPool()->Put(*pPattern); } - if ((nStartRow == 0) && (nEndRow == pDocument->MaxRow())) + if ((nStartRow == 0) && (nEndRow == rDocument.MaxRow())) Reset(pPattern); else { @@ -492,7 +492,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd // ensure that attributing changes text width of cell // otherwise, conditional formats need to be reset or deleted - bool bIsLoading = !pDocument->GetDocumentShell() || pDocument->GetDocumentShell()->IsLoading(); + bool bIsLoading = !rDocument.GetDocumentShell() || rDocument.GetDocumentShell()->IsLoading(); while ( ns <= nEndRow ) { if ( nCol != -1 && !bIsLoading ) @@ -505,7 +505,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd { aAdrStart.SetRow( std::max(nStartRow,ns) ); aAdrEnd .SetRow( std::min(nEndRow,mvData[nx].nEndRow) ); - pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); + rDocument.InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); } } ns = mvData[nx].nEndRow + 1; @@ -519,7 +519,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd bool bSplit = false; if ( nStartRow > 0 ) { - nInsert = pDocument->MaxRow() + 1; + nInsert = rDocument.MaxRow() + 1; if ( mvData[ni].pPattern != pPattern ) { if ( ni == 0 || (mvData[ni-1].nEndRow < nStartRow - 1) ) @@ -536,7 +536,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd if ( ni > 0 && mvData[ni-1].pPattern == pPattern ) { // combine mvData[ni-1].nEndRow = nEndRow; - nInsert = pDocument->MaxRow() + 1; + nInsert = rDocument.MaxRow() + 1; bCombined = true; } } @@ -560,13 +560,13 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd else if ( ni == nInsert ) mvData[ni-1].nEndRow = nStartRow - 1; // shrink } - nInsert = pDocument->MaxRow() + 1; + nInsert = rDocument.MaxRow() + 1; bCombined = true; } else if ( ni > 0 && ni == nInsert ) mvData[ni-1].nEndRow = nStartRow - 1; // shrink } - ScDocumentPool* pDocPool = pDocument->GetPool(); + ScDocumentPool* pDocPool = rDocument.GetPool(); if ( bSplit ) { // duplicate split entry in pool pDocPool->Put( *mvData[ni-1].pPattern ); @@ -582,7 +582,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd mvData[ni].nEndRow = nEndRow; mvData[ni].pPattern = pPattern; ni++; - nInsert = pDocument->MaxRow() + 1; + nInsert = rDocument.MaxRow() + 1; } if ( ni < nj ) { // remove entries @@ -590,7 +590,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd } } - if ( nInsert < sal::static_int_cast<SCSIZE>(pDocument->MaxRow() + 1) ) + if ( nInsert < sal::static_int_cast<SCSIZE>(rDocument.MaxRow() + 1) ) { // insert or append new entry if ( nInsert <= mvData.size() ) { @@ -613,7 +613,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd RemoveCellCharAttribs(nStartRow, nEndRow, pPattern, pDataArray); } - pDocument->SetStreamValid(nTab, false); + rDocument.SetStreamValid(nTab, false); } } @@ -625,7 +625,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle ) { - if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))) + if (!(rDocument.ValidRow(nStartRow) && rDocument.ValidRow(nEndRow))) return; SetDefaultIfNotInit(); @@ -677,12 +677,12 @@ void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleS { aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 ); aAdrEnd .SetRow( mvData[nPos].nEndRow ); - pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); + rDocument.InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); } } - pDocument->GetPool()->Remove(*mvData[nPos].pPattern); - mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern); + rDocument.GetPool()->Remove(*mvData[nPos].pPattern); + mvData[nPos].pPattern = &rDocument.GetPool()->Put(*pNewPattern); if (Concat(nPos)) Search(nStart, nPos); else @@ -691,7 +691,7 @@ void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleS } while ((nStart <= nEndRow) && (nPos < mvData.size())); - pDocument->SetStreamValid(nTab, false); + rDocument.SetStreamValid(nTab, false); #if DEBUG_SC_TESTATTRARRAY TestData(); @@ -723,7 +723,7 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, if ( bColorOnly && !pLine ) return; - if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))) + if (!(rDocument.ValidRow(nStartRow) && rDocument.ValidRow(nEndRow))) return; SCSIZE nPos; @@ -821,9 +821,9 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, else { // remove from pool ? - pDocument->GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->Remove(*mvData[nPos].pPattern); mvData[nPos].pPattern = - &pDocument->GetPool()->Put(std::move(pNewPattern)); + &rDocument.GetPool()->Put(std::move(pNewPattern)); if (Concat(nPos)) Search(nStart, nPos); @@ -846,7 +846,7 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac TestData(); #endif - if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))) + if (!(rDocument.ValidRow(nStartRow) && rDocument.ValidRow(nEndRow))) return; SCSIZE nPos; @@ -896,11 +896,11 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac { aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 ); aAdrEnd .SetRow( mvData[nPos].nEndRow ); - pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); + rDocument.InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); } } - pDocument->GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->Remove(*mvData[nPos].pPattern); mvData[nPos].pPattern = pNewPattern; if (Concat(nPos)) Search(nStart, nPos); @@ -916,7 +916,7 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac } while (nStart <= nEndRow); - pDocument->SetStreamValid(nTab, false); + rDocument.SetStreamValid(nTab, false); #if DEBUG_SC_TESTATTRARRAY TestData(); @@ -925,7 +925,7 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac void ScAttrArray::SetAttrEntries(std::vector<ScAttrEntry> && vNewData) { - ScDocumentPool* pDocPool = pDocument->GetPool(); + ScDocumentPool* pDocPool = rDocument.GetPool(); for (auto const & rEntry : mvData) pDocPool->Remove(*rEntry.pPattern); @@ -971,7 +971,7 @@ static void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource ) void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const { - if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))) + if (!(rDocument.ValidRow(nStartRow) && rDocument.ValidRow(nEndRow))) return; SCSIZE nPos = 0; @@ -989,7 +989,7 @@ void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow, if ( !mvData.empty() ) pPattern = mvData[nPos].pPattern; else - pPattern = pDocument->GetDefPattern(); + pPattern = rDocument.GetDefPattern(); if ( pPattern != rState.pOld1 && pPattern != rState.pOld2 ) { const SfxItemSet& rThisSet = pPattern->GetItemSet(); @@ -1016,7 +1016,7 @@ void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow, if ( !mvData.empty() ) nStart = mvData[nPos].nEndRow + 1; else - nStart = pDocument->MaxRow() + 1; + nStart = rDocument.MaxRow() + 1; ++nPos; } while (nStart <= nEndRow); @@ -1152,7 +1152,7 @@ void ScAttrArray::MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLine } else { - lcl_MergeToFrame( pLineOuter, pLineInner, rFlags, pDocument->GetDefPattern(), bLeft, nDistRight, true, 0 ); + lcl_MergeToFrame( pLineOuter, pLineInner, rFlags, rDocument.GetDefPattern(), bLeft, nDistRight, true, 0 ); } } @@ -1178,7 +1178,7 @@ bool ScAttrArray::ApplyFrame( const SvxBoxItem* pBoxItem, nDistBottom = 0; SvxBoxItem aNewFrame( *pOldFrame ); - bool bRTL=pDocument->IsLayoutRTL(nTab); + bool bRTL=rDocument.IsLayoutRTL(nTab); // fdo#37464 check if the sheet are RTL then replace right <=> left if (bRTL) { @@ -1222,7 +1222,7 @@ bool ScAttrArray::ApplyFrame( const SvxBoxItem* pBoxItem, } else { - SfxItemPoolCache aCache( pDocument->GetPool(), &aNewFrame ); + SfxItemPoolCache aCache( rDocument.GetPool(), &aNewFrame ); ApplyCacheArea( nStartRow, nEndRow, &aCache ); return true; @@ -1317,14 +1317,14 @@ bool ScAttrArray::HasAttrib_Impl(const ScPatternAttr* pPattern, HasAttrFlags nMa bool bContainsCondFormat = !mvData.empty() && !pPattern->GetItem( ATTR_CONDITIONAL ).GetCondFormatData().empty(); - if ( bContainsCondFormat && nCol != -1 ) // pDocument->GetCondResult() is valid only for real columns. + if ( bContainsCondFormat && nCol != -1 ) // rDocument.GetCondResult() is valid only for real columns. { SCROW nRowStartCond = std::max<SCROW>( nRow1, i ? mvData[i-1].nEndRow + 1: 0 ); SCROW nRowEndCond = std::min<SCROW>( nRow2, mvData[i].nEndRow ); bool bFoundCond = false; for(SCROW nRowCond = nRowStartCond; nRowCond <= nRowEndCond && !bFoundCond; ++nRowCond) { - const SfxItemSet* pSet = pDocument->GetCondResult( nCol, nRowCond, nTab ); + const SfxItemSet* pSet = rDocument.GetCondResult( nCol, nRowCond, nTab ); const SfxPoolItem* pItem; if( pSet && pSet->GetItemState( ATTR_PROTECTION, true, &pItem ) == SfxItemState::SET ) @@ -1400,7 +1400,7 @@ bool ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) cons { if (mvData.empty()) { - return HasAttrib_Impl(pDocument->GetDefPattern(), nMask, 0, pDocument->MaxRow(), 0); + return HasAttrib_Impl(rDocument.GetDefPattern(), nMask, 0, rDocument.MaxRow(), 0); } SCSIZE nStartIndex; @@ -1432,7 +1432,7 @@ bool ScAttrArray::IsMerged( SCROW nRow ) const return rItem.IsMerged(); } - return pDocument->GetDefPattern()->GetItem(ATTR_MERGE).IsMerged(); + return rDocument.GetDefPattern()->GetItem(ATTR_MERGE).IsMerged(); } /** @@ -1463,22 +1463,22 @@ bool ScAttrArray::ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow, SCROW nThisRow = (i>0) ? mvData[i-1].nEndRow+1 : 0; SCCOL nMergeEndCol = nThisCol + nCountX - 1; SCROW nMergeEndRow = nThisRow + nCountY - 1; - if (nMergeEndCol > rPaintCol && nMergeEndCol <= pDocument->MaxCol()) + if (nMergeEndCol > rPaintCol && nMergeEndCol <= rDocument.MaxCol()) rPaintCol = nMergeEndCol; - if (nMergeEndRow > rPaintRow && nMergeEndRow <= pDocument->MaxRow()) + if (nMergeEndRow > rPaintRow && nMergeEndRow <= rDocument.MaxRow()) rPaintRow = nMergeEndRow; bFound = true; if (bRefresh) { if ( nMergeEndCol > nThisCol ) - pDocument->ApplyFlagsTab( nThisCol+1, nThisRow, nMergeEndCol, mvData[i].nEndRow, + rDocument.ApplyFlagsTab( nThisCol+1, nThisRow, nMergeEndCol, mvData[i].nEndRow, nTab, ScMF::Hor ); if ( nMergeEndRow > nThisRow ) - pDocument->ApplyFlagsTab( nThisCol, nThisRow+1, nThisCol, nMergeEndRow, + rDocument.ApplyFlagsTab( nThisCol, nThisRow+1, nThisCol, nMergeEndRow, nTab, ScMF::Ver ); if ( nMergeEndCol > nThisCol && nMergeEndRow > nThisRow ) - pDocument->ApplyFlagsTab( nThisCol+1, nThisRow+1, nMergeEndCol, nMergeEndRow, + rDocument.ApplyFlagsTab( nThisCol+1, nThisRow+1, nMergeEndCol, nMergeEndRow, nTab, ScMF::Hor | ScMF::Ver ); Search( nThisRow, i ); // Data changed @@ -1516,8 +1516,8 @@ void ScAttrArray::RemoveAreaMerge(SCROW nStartRow, SCROW nEndRow) SCROW nCountY = pItem->GetRowMerge(); if (nCountX>1 || nCountY>1) { - const ScMergeAttr* pAttr = &pDocument->GetPool()->GetDefaultItem( ATTR_MERGE ); - const ScMergeFlagAttr* pFlagAttr = &pDocument->GetPool()->GetDefaultItem( ATTR_MERGE_FLAG ); + const ScMergeAttr* pAttr = &rDocument.GetPool()->GetDefaultItem( ATTR_MERGE ); + const ScMergeFlagAttr* pFlagAttr = &rDocument.GetPool()->GetDefaultItem( ATTR_MERGE_FLAG ); OSL_ENSURE( nCountY==1 || nThisStart==nThisEnd, "What's up?" ); @@ -1527,12 +1527,12 @@ void ScAttrArray::RemoveAreaMerge(SCROW nStartRow, SCROW nEndRow) // ApplyAttr for areas for (SCROW nThisRow = nThisStart; nThisRow <= nThisEnd; nThisRow++) - pDocument->ApplyAttr( nThisCol, nThisRow, nTab, *pAttr ); + rDocument.ApplyAttr( nThisCol, nThisRow, nTab, *pAttr ); - std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr( pDocument->GetPool() )); + std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr( rDocument.GetPool() )); SfxItemSet* pSet = &pNewPattern->GetItemSet(); pSet->Put( *pFlagAttr ); - pDocument->ApplyPatternAreaTab( nThisCol, nThisStart, nMergeEndCol, nMergeEndRow, + rDocument.ApplyPatternAreaTab( nThisCol, nThisStart, nMergeEndCol, nMergeEndRow, nTab, *pNewPattern ); pNewPattern.reset(); @@ -1543,7 +1543,7 @@ void ScAttrArray::RemoveAreaMerge(SCROW nStartRow, SCROW nEndRow) if ( nIndex < mvData.size() ) nThisStart = mvData[nIndex-1].nEndRow+1; else - nThisStart = pDocument->MaxRow()+1; // End + nThisStart = rDocument.MaxRow()+1; // End } } @@ -1589,7 +1589,7 @@ void ScAttrArray::SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow, bFirstUse = false; else // it's in the pool - pDocument->GetPool()->Put( *pWantedPattern ); + rDocument.GetPool()->Put( *pWantedPattern ); } SetPatternArea( nThisRow, nAttrRow, pWantedPattern ); } @@ -1726,7 +1726,7 @@ void ScAttrArray::ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement sal_uInt16 nOldValue = rOldSet.Get( ATTR_INDENT ).GetValue(); sal_uInt16 nNewValue = nOldValue; // To keep Increment indent from running outside the cell1659 - long nColWidth = static_cast<long>(pDocument->GetColWidth(nCol,nTab)); + long nColWidth = static_cast<long>(rDocument.GetColWidth(nCol,nTab)); if ( bIncrement ) { if ( nNewValue < nColWidth-SC_INDENT_STEP ) @@ -1771,14 +1771,14 @@ void ScAttrArray::ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement SCROW ScAttrArray::GetNextUnprotected( SCROW nRow, bool bUp ) const { long nRet = nRow; - if (pDocument->ValidRow(nRow)) + if (rDocument.ValidRow(nRow)) { if ( mvData.empty() ) { if ( bUp ) return -1; else - return pDocument->MaxRow()+1; + return rDocument.MaxRow()+1; } SCSIZE nIndex; @@ -1798,7 +1798,7 @@ SCROW ScAttrArray::GetNextUnprotected( SCROW nRow, bool bUp ) const nRet = mvData[nIndex].nEndRow+1; ++nIndex; if (nIndex >= mvData.size()) - return pDocument->MaxRow()+1; // not found + return rDocument.MaxRow()+1; // not found } } } @@ -1820,13 +1820,13 @@ void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBo if (bReset) { std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*mvData[nPos].pPattern)); - pDocument->GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->Remove(*mvData[nPos].pPattern); pNewPattern->SetStyleSheet( static_cast<ScStyleSheet*>( - pDocument->GetStyleSheetPool()-> + rDocument.GetStyleSheetPool()-> Find( ScResId(STR_STYLENAME_STANDARD_CELL), SfxStyleFamily::Para, SfxStyleSearchBits::Auto | SfxStyleSearchBits::ScStandard ) ) ); - mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern); + mvData[nPos].pPattern = &rDocument.GetPool()->Put(*pNewPattern); pNewPattern.reset(); if (Concat(nPos)) @@ -1845,7 +1845,7 @@ bool ScAttrArray::IsStyleSheetUsed( const ScStyleSheet& rStyle ) const { if ( mvData.empty() ) { - const ScStyleSheet* pStyle = pDocument->GetDefPattern()->GetStyleSheet(); + const ScStyleSheet* pStyle = rDocument.GetDefPattern()->GetStyleSheet(); if ( pStyle ) { pStyle->SetUsage( ScStyleSheet::Usage::USED ); @@ -1882,7 +1882,7 @@ bool ScAttrArray::IsEmpty() const if (mvData.size() == 1) { - return mvData[0].pPattern == pDocument->GetDefPattern(); + return mvData[0].pPattern == rDocument.GetDefPattern(); } else return false; @@ -1936,9 +1936,9 @@ bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const // ignore all attributes starting with the first run of SC_VISATTR_STOP equal rows // below the last content cell - if ( nLastData == pDocument->MaxRow() ) + if ( nLastData == rDocument.MaxRow() ) { - rLastRow = pDocument->MaxRow(); // can't look for attributes below pDocument->MaxRow() + rLastRow = rDocument.MaxRow(); // can't look for attributes below rDocument.MaxRow() return true; } @@ -1949,7 +1949,7 @@ bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const if (nStartRow <= nLastData + 1) { // Ignore here a few rows if data happens to end within - // SC_VISATTR_STOP rows before pDocument->MaxRow(). + // SC_VISATTR_STOP rows before rDocument.MaxRow(). rLastRow = nLastData; return false; } @@ -1984,7 +1984,7 @@ bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const bool ScAttrArray::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const { if ( mvData.empty() ) - return pDocument->GetDefPattern()->IsVisible(); + return rDocument.GetDefPattern()->IsVisible(); SCSIZE nIndex; Search( nStartRow, nIndex ); @@ -2007,8 +2007,8 @@ bool ScAttrArray::IsVisibleEqual( const ScAttrArray& rOther, { if ( mvData.empty() && rOther.mvData.empty() ) { - const ScPatternAttr* pDefPattern1 = pDocument->GetDefPattern(); - const ScPatternAttr* pDefPattern2 = rOther.pDocument->GetDefPattern(); + const ScPatternAttr* pDefPattern1 = rDocument.GetDefPattern(); + const ScPatternAttr* pDefPattern2 = rOther.rDocument.GetDefPattern(); return ( pDefPattern1 == pDefPattern2 || pDefPattern1->IsVisibleEqual( *pDefPattern2 ) ); } @@ -2019,13 +2019,13 @@ bool ScAttrArray::IsVisibleEqual( const ScAttrArray& rOther, if ( mvData.empty() && !rOther.mvData.empty() ) { pNonDefault = &rOther; - pDefPattern = pDocument->GetDefPattern(); + pDefPattern = rDocument.GetDefPattern(); bDefNonDefCase = true; } else if ( !mvData.empty() && rOther.mvData.empty() ) { pNonDefault = this; - pDefPattern = rOther.pDocument->GetDefPattern(); + pDefPattern = rOther.rDocument.GetDefPattern(); bDefNonDefCase = true; } @@ -2087,8 +2087,8 @@ bool ScAttrArray::IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW // summarised with IsVisibleEqual if ( mvData.empty() && rOther.mvData.empty() ) { - const ScPatternAttr* pDefPattern1 = pDocument->GetDefPattern(); - const ScPatternAttr* pDefPattern2 = rOther.pDocument->GetDefPattern(); + const ScPatternAttr* pDefPattern1 = rDocument.GetDefPattern(); + const ScPatternAttr* pDefPattern2 = rOther.rDocument.GetDefPattern(); return ( pDefPattern1 == pDefPattern2 ); } @@ -2099,13 +2099,13 @@ bool ScAttrArray::IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW if ( mvData.empty() && !rOther.mvData.empty() ) { pNonDefault = &rOther; - pDefPattern = pDocument->GetDefPattern(); + pDefPattern = rDocument.GetDefPattern(); bDefNonDefCase = true; } else if ( !mvData.empty() && rOther.mvData.empty() ) { pNonDefault = this; - pDefPattern = rOther.pDocument->GetDefPattern(); + pDefPattern = rOther.rDocument.GetDefPattern(); bDefNonDefCase = true; } @@ -2191,14 +2191,14 @@ bool ScAttrArray::TestInsertRow( SCSIZE nSize ) const { // if 1st row pushed out is vertically overlapped, summary would be broken - // pDocument->MaxRow() + 1 - nSize = 1st row pushed out + // rDocument.MaxRow() + 1 - nSize = 1st row pushed out if ( mvData.empty() ) - return !pDocument->GetDefPattern()-> + return !rDocument.GetDefPattern()-> GetItem(ATTR_MERGE_FLAG).IsVerOverlapped(); SCSIZE nFirstLost = mvData.size()-1; - while ( nFirstLost && mvData[nFirstLost-1].nEndRow >= sal::static_int_cast<SCROW>(pDocument->MaxRow() + 1 - nSize) ) + while ( nFirstLost && mvData[nFirstLost-1].nEndRow >= sal::static_int_cast<SCROW>(rDocument.MaxRow() + 1 - nSize) ) --nFirstLost; return !mvData[nFirstLost].pPattern-> @@ -2224,9 +2224,9 @@ void ScAttrArray::InsertRow( SCROW nStartRow, SCSIZE nSize ) for (i = nIndex; i < mvData.size()-1; i++) { SCROW nNew = mvData[i].nEndRow + nSize; - if ( nNew >= pDocument->MaxRow() ) // at end? + if ( nNew >= rDocument.MaxRow() ) // at end? { - nNew = pDocument->MaxRow(); + nNew = rDocument.MaxRow(); if (!nRemove) nRemove = i+1; // remove the following? } @@ -2242,9 +2242,9 @@ void ScAttrArray::InsertRow( SCROW nStartRow, SCSIZE nSize ) { // ApplyAttr for areas - const SfxPoolItem& rDef = pDocument->GetPool()->GetDefaultItem( ATTR_MERGE ); + const SfxPoolItem& rDef = rDocument.GetPool()->GetDefaultItem( ATTR_MERGE ); for (SCSIZE nAdd=0; nAdd<nSize; nAdd++) - pDocument->ApplyAttr( nCol, nStartRow+nAdd, nTab, rDef ); + rDocument.ApplyAttr( nCol, nStartRow+nAdd, nTab, rDef ); // reply inserts in this area not summarized } @@ -2299,13 +2299,13 @@ void ScAttrArray::DeleteRow( SCROW nStartRow, SCSIZE nSize ) // Below does not follow the pattern to detect pressure ranges; // instead, only remove merge flags. - RemoveFlags( pDocument->MaxRow()-nSize+1, pDocument->MaxRow(), ScMF::Hor | ScMF::Ver | ScMF::Auto ); + RemoveFlags( rDocument.MaxRow()-nSize+1, rDocument.MaxRow(), ScMF::Hor | ScMF::Ver | ScMF::Auto ); } void ScAttrArray::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex ) { SetDefaultIfNotInit(); - ScDocumentPool* pDocPool = pDocument->GetPool(); + ScDocumentPool* pDocPool = rDocument.GetPool(); for (SCSIZE i = nStartIndex; i <= nEndIndex; i++) pDocPool->Remove(*mvData[i].pPattern); @@ -2319,15 +2319,15 @@ void ScAttrArray::DeleteArea(SCROW nStartRow, SCROW nEndRow) RemoveAreaMerge( nStartRow, nEndRow ); // remove from combined flags if ( !HasAttrib( nStartRow, nEndRow, HasAttrFlags::Overlapped | HasAttrFlags::AutoFilter) ) - SetPatternArea( nStartRow, nEndRow, pDocument->GetDefPattern() ); + SetPatternArea( nStartRow, nEndRow, rDocument.GetDefPattern() ); else - SetPatternAreaSafe( nStartRow, nEndRow, pDocument->GetDefPattern(), true ); // leave merge flags + SetPatternAreaSafe( nStartRow, nEndRow, rDocument.GetDefPattern(), true ); // leave merge flags } void ScAttrArray::DeleteHardAttr(SCROW nStartRow, SCROW nEndRow) { SetDefaultIfNotInit(); - const ScPatternAttr* pDefPattern = pDocument->GetDefPattern(); + const ScPatternAttr* pDefPattern = rDocument.GetDefPattern(); SCSIZE nIndex; SCROW nRow; @@ -2395,10 +2395,10 @@ void ScAttrArray::CopyArea( nEndRow -= nDy; SCROW nDestStart = std::max(static_cast<long>(static_cast<long>(nStartRow) + nDy), long(0)); - SCROW nDestEnd = std::min(static_cast<long>(static_cast<long>(nEndRow) + nDy), long(pDocument->MaxRow())); + SCROW nDestEnd = std::min(static_cast<long>(static_cast<long>(nEndRow) + nDy), long(rDocument.MaxRow())); - ScDocumentPool* pSourceDocPool = pDocument->GetPool(); - ScDocumentPool* pDestDocPool = rAttrArray.pDocument->GetPool(); + ScDocumentPool* pSourceDocPool = rDocument.GetPool(); + ScDocumentPool* pDestDocPool = rAttrArray.rDocument.GetPool(); bool bSamePool = (pSourceDocPool==pDestDocPool); if ( mvData.empty() ) @@ -2436,14 +2436,14 @@ void ScAttrArray::CopyArea( if (bSamePool) pNewPattern = &pDestDocPool->Put(*pTmpPattern); else - pNewPattern = pTmpPattern->PutInPool( rAttrArray.pDocument, pDocument ); + pNewPattern = pTmpPattern->PutInPool( &rAttrArray.rDocument, &rDocument ); } else { if (bSamePool) pNewPattern = &pDestDocPool->Put(*pOldPattern); else - pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument ); + pNewPattern = pOldPattern->PutInPool( &rAttrArray.rDocument, &rDocument ); } rAttrArray.SetPatternArea(nDestStart, @@ -2466,7 +2466,7 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttr nEndRow -= nDy; SCROW nDestStart = std::max(static_cast<long>(static_cast<long>(nStartRow) + nDy), long(0)); - SCROW nDestEnd = std::min(static_cast<long>(static_cast<long>(nEndRow) + nDy), long(pDocument->MaxRow())); + SCROW nDestEnd = std::min(static_cast<long>(static_cast<long>(nEndRow) + nDy), long(rDocument.MaxRow())); if ( !rAttrArray.HasAttrib( nDestStart, nDestEnd, HasAttrFlags::Overlapped ) ) { @@ -2474,17 +2474,17 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttr return; } - ScDocumentPool* pSourceDocPool = pDocument->GetPool(); - ScDocumentPool* pDestDocPool = rAttrArray.pDocument->GetPool(); + ScDocumentPool* pSourceDocPool = rDocument.GetPool(); + ScDocumentPool* pDestDocPool = rAttrArray.rDocument.GetPool(); bool bSamePool = (pSourceDocPool==pDestDocPool); if ( mvData.empty() ) { const ScPatternAttr* pNewPattern; if (bSamePool) - pNewPattern = &pDestDocPool->Put(*pDocument->GetDefPattern()); + pNewPattern = &pDestDocPool->Put(*rDocument.GetDefPattern()); else - pNewPattern = pDocument->GetDefPattern()->PutInPool( rAttrArray.pDocument, pDocument ); + pNewPattern = rDocument.GetDefPattern()->PutInPool( &rAttrArray.rDocument, &rDocument ); rAttrArray.SetPatternAreaSafe(nDestStart, nDestEnd, pNewPattern, false); return; @@ -2501,7 +2501,7 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttr if (bSamePool) pNewPattern = &pDestDocPool->Put(*pOldPattern); else - pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument ); + pNewPattern = pOldPattern->PutInPool( &rAttrArray.rDocument, &rDocument ); rAttrArray.SetPatternAreaSafe(nDestStart, std::min(static_cast<SCROW>(mvData[i].nEndRow + nDy), nDestEnd), pNewPattern, false); @@ -2522,16 +2522,16 @@ SCROW ScAttrArray::SearchStyle( if (pMarkArray) { nRow = pMarkArray->GetNextMarked( nRow, bUp ); - if (!pDocument->ValidRow(nRow)) + if (!rDocument.ValidRow(nRow)) return nRow; } if ( mvData.empty() ) { - if (pDocument->GetDefPattern()->GetStyleSheet() == pSearchStyle) + if (rDocument.GetDefPattern()->GetStyleSheet() == pSearchStyle) return nRow; - nRow = bUp ? -1 : pDocument->MaxRow() + 1; + nRow = bUp ? -1 : rDocument.MaxRow() + 1; return nRow; } @@ -2580,7 +2580,7 @@ SCROW ScAttrArray::SearchStyle( } } - OSL_ENSURE( bFound || !pDocument->ValidRow(nRow), "Internal failure in ScAttrArray::SearchStyle" ); + OSL_ENSURE( bFound || !rDocument.ValidRow(nRow), "Internal failure in ScAttrArray::SearchStyle" ); return nRow; } @@ -2590,7 +2590,7 @@ bool ScAttrArray::SearchStyleRange( const ScMarkArray* pMarkArray) const { SCROW nStartRow = SearchStyle( rRow, pSearchStyle, bUp, pMarkArray ); - if (pDocument->ValidRow(nStartRow)) + if (rDocument.ValidRow(nStartRow)) { if ( mvData.empty() ) { @@ -2607,7 +2607,7 @@ bool ScAttrArray::SearchStyleRange( } else { - rEndRow = pDocument->MaxRow(); + rEndRow = rDocument.MaxRow(); if (pMarkArray) { SCROW nMarkEnd = pMarkArray->GetMarkEnd( nStartRow, false ); diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx index 77e2513bf160..85d6bb808583 100644 --- a/sc/source/core/data/cellvalue.cxx +++ b/sc/source/core/data/cellvalue.cxx @@ -115,7 +115,7 @@ void commitToColumn( const ScCellValue& rCell, ScColumn& rColumn, SCROW nRow ) rColumn.SetRawString(nRow, *rCell.mpString); break; case CELLTYPE_EDIT: - rColumn.SetEditText(nRow, ScEditUtil::Clone(*rCell.mpEditText, *rColumn.GetDoc())); + rColumn.SetEditText(nRow, ScEditUtil::Clone(*rCell.mpEditText, rColumn.GetDoc())); break; case CELLTYPE_VALUE: rColumn.SetValue(nRow, rCell.mfValue); @@ -123,7 +123,7 @@ void commitToColumn( const ScCellValue& rCell, ScColumn& rColumn, SCROW nRow ) case CELLTYPE_FORMULA: { ScAddress aDestPos(rColumn.GetCol(), nRow, rColumn.GetTab()); - rColumn.SetFormulaCell(nRow, new ScFormulaCell(*rCell.mpFormula, *rColumn.GetDoc(), aDestPos)); + rColumn.SetFormulaCell(nRow, new ScFormulaCell(*rCell.mpFormula, rColumn.GetDoc(), aDestPos)); } break; default: diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index e3adff2de24f..f5dbcb96f16f 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -100,9 +100,9 @@ void ScColumn::Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, bool bEmptyA nCol = nNewCol; nTab = nNewTab; if ( bEmptyAttrArray ) - pAttrArray.reset(new ScAttrArray( nCol, nTab, &rDoc, nullptr )); + pAttrArray.reset(new ScAttrArray( nCol, nTab, rDoc, nullptr )); else - pAttrArray.reset(new ScAttrArray( nCol, nTab, &rDoc, &rDoc.maTabs[nTab]->aDefaultColAttrArray )); + pAttrArray.reset(new ScAttrArray( nCol, nTab, rDoc, &rDoc.maTabs[nTab]->aDefaultColAttrArray )); } SCROW ScColumn::GetNextUnprotected( SCROW nRow, bool bUp ) const @@ -115,7 +115,7 @@ sc::MatrixEdge ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sc::Matr { using namespace sc; - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2) || nRow1 > nRow2) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return MatrixEdge::Nothing; ScAddress aOrigin(ScAddress::INITIALIZE_INVALID); @@ -130,7 +130,7 @@ sc::MatrixEdge ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sc::Matr if (pCell->GetMatrixFlag() == ScMatrixMode::NONE) return MatrixEdge::Nothing; - return pCell->GetMatrixEdge(GetDoc(), aOrigin); + return pCell->GetMatrixEdge(&GetDoc(), aOrigin); } bool bOpen = false; @@ -160,7 +160,7 @@ sc::MatrixEdge ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sc::Matr if (pCell->GetMatrixFlag() == ScMatrixMode::NONE) continue; - nEdges = pCell->GetMatrixEdge(GetDoc(), aOrigin); + nEdges = pCell->GetMatrixEdge(&GetDoc(), aOrigin); if (nEdges == MatrixEdge::Nothing) continue; @@ -240,7 +240,7 @@ bool ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const // cell is not a part of a matrix. continue; - MatrixEdge nEdges = pCell->GetMatrixEdge(GetDoc(), aOrigin); + MatrixEdge nEdges = pCell->GetMatrixEdge(&GetDoc(), aOrigin); if (nEdges == MatrixEdge::Nothing) continue; @@ -273,7 +273,7 @@ bool ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const aCurOrigin = aOrigin; const ScFormulaCell* pFCell; if (pCell->GetMatrixFlag() == ScMatrixMode::Reference) - pFCell = GetDoc()->GetFormulaCell(aOrigin); + pFCell = GetDoc().GetFormulaCell(aOrigin); else pFCell = pCell; @@ -382,7 +382,7 @@ const ScPatternAttr* ScColumn::GetMostUsedPattern( SCROW nStartRow, SCROW nEndRo const ScPatternAttr* pMaxPattern = nullptr; size_t nMaxCount = 0; - ScAttrIterator aAttrIter( pAttrArray.get(), nStartRow, nEndRow, GetDoc()->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), nStartRow, nEndRow, GetDoc().GetDefPattern() ); const ScPatternAttr* pPattern; SCROW nAttrRow1 = 0, nAttrRow2 = 0; @@ -402,15 +402,15 @@ const ScPatternAttr* ScColumn::GetMostUsedPattern( SCROW nStartRow, SCROW nEndRo sal_uInt32 ScColumn::GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const { - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); SCROW nPatStartRow, nPatEndRow; const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nPatStartRow, nPatEndRow, nStartRow); - sal_uInt32 nFormat = pPattern->GetNumberFormat(pDocument->GetFormatTable()); + sal_uInt32 nFormat = pPattern->GetNumberFormat(rDocument.GetFormatTable()); while (nEndRow > nPatEndRow) { nStartRow = nPatEndRow + 1; pPattern = pAttrArray->GetPatternRange(nPatStartRow, nPatEndRow, nStartRow); - sal_uInt32 nTmpFormat = pPattern->GetNumberFormat(pDocument->GetFormatTable()); + sal_uInt32 nTmpFormat = pPattern->GetNumberFormat(rDocument.GetFormatTable()); if (nFormat != nTmpFormat) return 0; } @@ -440,7 +440,7 @@ SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& if (!bFound) return -1; - else if (nTop==0 && nBottom==GetDoc()->MaxRow()) + else if (nTop==0 && nBottom==GetDoc().MaxRow()) return 0; else return nBottom; @@ -500,7 +500,7 @@ void ScColumn::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rM void ScColumn::ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr ) { const SfxItemSet* pSet = &rPatAttr.GetItemSet(); - SfxItemPoolCache aCache( GetDoc()->GetPool(), pSet ); + SfxItemPoolCache aCache( GetDoc().GetPool(), pSet ); const ScPatternAttr* pPattern = pAttrArray->GetPattern( nRow ); @@ -516,7 +516,7 @@ void ScColumn::ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPattern ScEditDataArray* pDataArray, bool* const pIsChanged ) { const SfxItemSet* pSet = &rPatAttr.GetItemSet(); - SfxItemPoolCache aCache( GetDoc()->GetPool(), pSet ); + SfxItemPoolCache aCache( GetDoc().GetPool(), pSet ); pAttrArray->ApplyCacheArea( nStartRow, nEndRow, &aCache, pDataArray, pIsChanged ); } @@ -524,8 +524,8 @@ void ScColumn::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange, const ScPatternAttr& rPattern, SvNumFormatType nNewType ) { const SfxItemSet* pSet = &rPattern.GetItemSet(); - SfxItemPoolCache aCache( GetDoc()->GetPool(), pSet ); - SvNumberFormatter* pFormatter = GetDoc()->GetFormatTable(); + SfxItemPoolCache aCache( GetDoc().GetPool(), pSet ); + SvNumberFormatter* pFormatter = GetDoc().GetFormatTable(); SCROW nEndRow = rRange.aEnd.Row(); for ( SCROW nRow = rRange.aStart.Row(); nRow <= nEndRow; nRow++ ) { @@ -618,13 +618,13 @@ const ScStyleSheet* ScColumn::GetSelectionStyle( const ScMarkData& rMark, bool& const ScStyleSheet* pStyle = nullptr; const ScStyleSheet* pNewStyle; - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol ); SCROW nTop; SCROW nBottom; while (bEqual && aMultiIter.Next( nTop, nBottom )) { - ScAttrIterator aAttrIter( pAttrArray.get(), nTop, nBottom, pDocument->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), nTop, nBottom, rDocument.GetDefPattern() ); SCROW nRow; SCROW nDummy; while (bEqual) @@ -652,7 +652,7 @@ const ScStyleSheet* ScColumn::GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRo const ScStyleSheet* pStyle = nullptr; const ScStyleSheet* pNewStyle; - ScAttrIterator aAttrIter( pAttrArray.get(), nRow1, nRow2, GetDoc()->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), nRow1, nRow2, GetDoc().GetDefPattern() ); SCROW nRow; SCROW nDummy; while (bEqual) @@ -716,7 +716,7 @@ void ScColumn::ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr ) // in order to only create a new SetItem, we don't need SfxItemPoolCache. //TODO: Warning: SfxItemPoolCache seems to create too many Refs for the new SetItem ?? - ScDocumentPool* pDocPool = GetDoc()->GetPool(); + ScDocumentPool* pDocPool = GetDoc().GetPool(); const ScPatternAttr* pOldPattern = pAttrArray->GetPattern( nRow ); std::unique_ptr<ScPatternAttr> pTemp(new ScPatternAttr(*pOldPattern)); @@ -847,7 +847,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 = GetDoc()->MaxRow(); + size_t nLastNonEmptyRow = GetDoc().MaxRow(); sc::CellStoreType::const_reverse_iterator it = maCells.rbegin(); if (it->type == sc::element_type_empty) nLastNonEmptyRow -= it->size; @@ -856,7 +856,7 @@ bool ScColumn::TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const // No cells would get pushed out. return pAttrArray->TestInsertRow(nSize); - if (nLastNonEmptyRow + nSize > o3tl::make_unsigned(GetDoc()->MaxRow())) + if (nLastNonEmptyRow + nSize > o3tl::make_unsigned(GetDoc().MaxRow())) // At least one cell would get pushed out. Not good. return false; @@ -868,16 +868,16 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) pAttrArray->InsertRow( nStartRow, nSize ); maCellNotes.insert_empty(nStartRow, nSize); - maCellNotes.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maCellNotes.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); maBroadcasters.insert_empty(nStartRow, nSize); - maBroadcasters.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maBroadcasters.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); maCellTextAttrs.insert_empty(nStartRow, nSize); - maCellTextAttrs.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maCellTextAttrs.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); maCells.insert_empty(nStartRow, nSize); - maCells.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maCells.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); CellStorageModified(); @@ -955,7 +955,7 @@ public: std::vector<EditTextObject*> aCloned; aCloned.reserve(nDataSize); for (; it != itEnd; ++it) - aCloned.push_back(ScEditUtil::Clone(**it, *mrDestCol.GetDoc()).release()); + aCloned.push_back(ScEditUtil::Clone(**it, mrDestCol.GetDoc()).release()); maDestPos.miCellPos = mrDestCol.GetCellStore().set( maDestPos.miCellPos, nTopRow, aCloned.begin(), aCloned.end()); @@ -974,10 +974,10 @@ public: for (; it != itEnd; ++it, aDestPos.IncRow()) { const ScFormulaCell& rOld = **it; - if (rOld.GetDirty() && mrSrcCol.GetDoc()->GetAutoCalc()) + if (rOld.GetDirty() && mrSrcCol.GetDoc().GetAutoCalc()) const_cast<ScFormulaCell&>(rOld).Interpret(); - aCloned.push_back(new ScFormulaCell(rOld, *mrDestCol.GetDoc(), aDestPos)); + aCloned.push_back(new ScFormulaCell(rOld, mrDestCol.GetDoc(), aDestPos)); } // Group the cloned formula cells. @@ -1046,7 +1046,7 @@ void ScColumn::CopyToClip( rCxt.isKeepScenarioFlags() ? (ScMF::All & ~ScMF::Scenario) : ScMF::All ); { - CopyToClipHandler aFunc(*GetDoc(), *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); } @@ -1073,7 +1073,7 @@ void ScColumn::CopyStaticToDocument( aDestPos.miCellPos = rDestCol.maCells.begin(); - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow1); sc::CellStoreType::const_iterator it = aPos.first; size_t nOffset = aPos.second; @@ -1124,7 +1124,7 @@ void ScColumn::CopyStaticToDocument( for (; itData != itDataEnd; ++itData) { const EditTextObject& rObj = **itData; - svl::SharedString aSS = pDocument->GetSharedStringPool().intern(ScEditUtil::GetString(rObj, pDocument)); + svl::SharedString aSS = rDocument.GetSharedStringPool().intern(ScEditUtil::GetString(rObj, &rDocument)); aConverted.push_back(aSS); } aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nCurRow, aConverted.begin(), aConverted.end()); @@ -1143,7 +1143,7 @@ void ScColumn::CopyStaticToDocument( SCROW nRow = nCurRow + i; ScFormulaCell& rFC = **itData; - if (rFC.GetDirty() && pDocument->GetAutoCalc()) + if (rFC.GetDirty() && rDocument.GetAutoCalc()) rFC.Interpret(); if (rFC.GetErrCode() != FormulaError::NONE) @@ -1172,7 +1172,7 @@ void ScColumn::CopyStaticToDocument( // Don't forget to copy the number formats over. Charts may reference them. for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) { - sal_uInt32 nNumFmt = GetNumberFormat(pDocument->GetNonThreadedContext(), nRow); + sal_uInt32 nNumFmt = GetNumberFormat(rDocument.GetNonThreadedContext(), nRow); SvNumberFormatterMergeMap::const_iterator itNum = rMap.find(nNumFmt); if (itNum != rMap.end()) nNumFmt = itNum->second; @@ -1185,7 +1185,7 @@ void ScColumn::CopyStaticToDocument( void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol ) { - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nSrcRow); sc::CellStoreType::const_iterator it = aPos.first; bool bSet = true; @@ -1200,21 +1200,21 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDes case sc::element_type_edittext: { EditTextObject* p = sc::edittext_block::at(*it->data, aPos.second); - if (pDocument == rDestCol.GetDoc()) + if (&rDocument == &rDestCol.GetDoc()) rDestCol.maCells.set(nDestRow, p->Clone().release()); else - rDestCol.maCells.set(nDestRow, ScEditUtil::Clone(*p, *rDestCol.GetDoc()).release()); + rDestCol.maCells.set(nDestRow, ScEditUtil::Clone(*p, rDestCol.GetDoc()).release()); } break; case sc::element_type_formula: { ScFormulaCell* p = sc::formula_block::at(*it->data, aPos.second); - if (p->GetDirty() && pDocument->GetAutoCalc()) + if (p->GetDirty() && rDocument.GetAutoCalc()) p->Interpret(); ScAddress aDestPos = p->aPos; aDestPos.SetRow(nDestRow); - ScFormulaCell* pNew = new ScFormulaCell(*p, *rDestCol.GetDoc(), aDestPos); + ScFormulaCell* pNew = new ScFormulaCell(*p, rDestCol.GetDoc(), aDestPos); rDestCol.SetFormulaCell(nDestRow, pNew); } break; @@ -1232,7 +1232,7 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDes if (pNote) { pNote = pNote->Clone(ScAddress(nCol, nSrcRow, nTab), - *rDestCol.GetDoc(), + rDestCol.GetDoc(), ScAddress(rDestCol.nCol, nDestRow, rDestCol.nTab), false).release(); rDestCol.maCellNotes.set(nDestRow, pNote); @@ -1291,9 +1291,9 @@ class CopyAsLinkHandler aRef.InitAddress(ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab())); // Absolute reference. aRef.SetFlag3D(true); - ScTokenArray aArr(*mrDestCol.GetDoc()); + ScTokenArray aArr(mrDestCol.GetDoc()); aArr.AddSingleReference(aRef); - return new ScFormulaCell(mrDestCol.GetDoc(), ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()), aArr); + return new ScFormulaCell(&mrDestCol.GetDoc(), ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()), aArr); } void createRefBlock(const sc::CellStoreType::value_type& aNode, size_t nOffset, size_t nDataSize) @@ -1366,7 +1366,7 @@ public: ScAddress aSrcPos(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab()); for (; it != itEnd; ++it, aSrcPos.IncRow(), ++nRow) { - if (!canCopyValue(*mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags)) + if (!canCopyValue(mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags)) continue; maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, createRefCell(nRow)); @@ -1450,14 +1450,14 @@ class CopyByCloneHandler if (bForceFormula || bCloneFormula) { // Clone as formula cell. - ScFormulaCell* pCell = new ScFormulaCell(rSrcCell, *mrDestCol.GetDoc(), aDestPos, mnFormulaCellCloneFlags); + ScFormulaCell* pCell = new ScFormulaCell(rSrcCell, mrDestCol.GetDoc(), aDestPos, mnFormulaCellCloneFlags); pCell->SetDirtyVar(); mrDestCol.SetFormulaCell(maDestPos, nRow, pCell, meListenType, rSrcCell.NeedsNumberFormat()); setDefaultAttrToDest(nRow); return; } - if (mrDestCol.GetDoc()->IsUndo()) + if (mrDestCol.GetDoc().IsUndo()) return; if (bCloneValue) @@ -1466,7 +1466,7 @@ class CopyByCloneHandler if (nErr != FormulaError::NONE) { // error codes are cloned with values - ScFormulaCell* pErrCell = new ScFormulaCell(*mrDestCol.GetDoc(), aDestPos); + ScFormulaCell* pErrCell = new ScFormulaCell(mrDestCol.GetDoc(), aDestPos); pErrCell->SetErrCode(nErr); mrDestCol.SetFormulaCell(maDestPos, nRow, pErrCell, meListenType); setDefaultAttrToDest(nRow); @@ -1478,7 +1478,7 @@ class CopyByCloneHandler { if (rSrcCell.IsValue()) { - if (canCopyValue(*mrSrcCol.GetDoc(), ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab()), mnCopyFlags)) + if (canCopyValue(mrSrcCol.GetDoc(), ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab()), mnCopyFlags)) { maDestPos.miCellPos = mrDestCol.GetCellStore().set( maDestPos.miCellPos, nRow, rSrcCell.GetValue()); @@ -1500,7 +1500,7 @@ class CopyByCloneHandler if (rSrcCell.IsMultilineResult()) { // Clone as an edit text object. - EditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine(); + EditEngine& rEngine = mrDestCol.GetDoc().GetEditEngine(); rEngine.SetText(aStr.getString()); maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rEngine.CreateTextObject().release()); @@ -1585,7 +1585,7 @@ public: ScAddress aSrcPos(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab()); for (; it != itEnd; ++it, aSrcPos.IncRow(), ++nRow) { - if (!canCopyValue(*mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags)) + if (!canCopyValue(mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags)) continue; maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, *it); @@ -1646,7 +1646,7 @@ public: std::vector<EditTextObject*> aCloned; aCloned.reserve(nDataSize); for (; it != itEnd; ++it) - aCloned.push_back(ScEditUtil::Clone(**it, *mrDestCol.GetDoc()).release()); + aCloned.push_back(ScEditUtil::Clone(**it, mrDestCol.GetDoc()).release()); maDestPos.miCellPos = mrDestCol.GetCellStore().set( maDestPos.miCellPos, nRow, aCloned.begin(), aCloned.end()); @@ -1667,7 +1667,7 @@ public: // If the column to be replaced contains a long formula group (tdf#102364), there can // be so many listeners in a single vector that the quadratic cost of repeatedly removing // the first element becomes very high. Optimize this by removing them in one go. - sc::EndListeningContext context(*mrDestCol.GetDoc()); + sc::EndListeningContext context(mrDestCol.GetDoc()); mrDestCol.EndListeningFormulaCells( context, nRow, nRow + nDataSize - 1, nullptr, nullptr ); // There can be a similar problem with starting to listen to cells repeatedly (tdf#133302). // Delay it. @@ -1745,8 +1745,8 @@ void ScColumn::CopyToColumn( // Compare the ScDocumentPool* to determine if we are copying // within the same document. If not, re-intern shared strings. svl::SharedStringPool* pSharedStringPool = - (GetDoc()->GetPool() != rColumn.GetDoc()->GetPool()) ? - &rColumn.GetDoc()->GetSharedStringPool() : nullptr; + (GetDoc().GetPool() != rColumn.GetDoc().GetPool()) ? + &rColumn.GetDoc().GetSharedStringPool() : nullptr; CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags, pSharedStringPool, bGlobalNamesToLocal); aFunc.setStartListening(rCxt.isStartListening()); @@ -1765,8 +1765,8 @@ void ScColumn::UndoToColumn( CopyToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, rColumn); //TODO: bMarked ???? - if (nRow2 < GetDoc()->MaxRow()) - CopyToColumn(rCxt, nRow2+1, GetDoc()->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 @@ -1775,7 +1775,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const // rows that are present in the position column (rPosCol). // First, mark all the non-empty cell ranges from the position column. - sc::SingleColumnSpanSet aRangeSet(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aRangeSet(GetDoc().GetSheetLimits()); aRangeSet.scan(rPosCol); // Now, copy cells from this column to the destination column for those @@ -1783,7 +1783,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const sc::SingleColumnSpanSet::SpansType aRanges; aRangeSet.getSpans(aRanges); - CopyToClipHandler aFunc(*GetDoc(), *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); @@ -1794,8 +1794,8 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const 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, GetDoc()->MaxRow(), pDocument->GetDefPattern() ); + ScDocument& rDocument = GetDoc(); + ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc().MaxRow(), rDocument.GetDefPattern() ); SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) @@ -1803,13 +1803,13 @@ void ScColumn::CopyScenarioFrom( const ScColumn& rSrcCol ) if ( pPattern->GetItem( ATTR_MERGE_FLAG ).IsScenario() ) { DeleteArea( nStart, nEnd, InsertDeleteFlags::CONTENTS ); - sc::CopyToDocContext aCxt(*pDocument); + sc::CopyToDocContext aCxt(rDocument); rSrcCol. CopyToColumn(aCxt, nStart, nEnd, InsertDeleteFlags::CONTENTS, false, *this); // UpdateUsed not needed, already done in TestCopyScenario (obsolete comment ?) - sc::RefUpdateContext aRefCxt(*pDocument); + sc::RefUpdateContext aRefCxt(rDocument); aRefCxt.meMode = URM_COPY; aRefCxt.maRange = ScRange(nCol, nStart, nTab, nCol, nEnd, nTab); aRefCxt.mnTabDelta = nTab - rSrcCol.nTab; @@ -1823,8 +1823,8 @@ void ScColumn::CopyScenarioFrom( const ScColumn& rSrcCol ) 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, GetDoc()->MaxRow(), pDocument->GetDefPattern() ); + ScDocument& rDocument = GetDoc(); + ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc().MaxRow(), rDocument.GetDefPattern() ); SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) @@ -1832,10 +1832,10 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const if ( pPattern->GetItem( ATTR_MERGE_FLAG ).IsScenario() ) { rDestCol.DeleteArea( nStart, nEnd, InsertDeleteFlags::CONTENTS ); - sc::CopyToDocContext aCxt(*rDestCol.GetDoc()); + sc::CopyToDocContext aCxt(rDestCol.GetDoc()); CopyToColumn(aCxt, nStart, nEnd, InsertDeleteFlags::CONTENTS, false, rDestCol); - sc::RefUpdateContext aRefCxt(*pDocument); + sc::RefUpdateContext aRefCxt(rDocument); aRefCxt.meMode = URM_COPY; aRefCxt.maRange = ScRange(rDestCol.nCol, nStart, rDestCol.nTab, rDestCol.nCol, nEnd, rDestCol.nTab); aRefCxt.mnTabDelta = rDestCol.nTab - nTab; @@ -1849,7 +1849,7 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const bool ScColumn::TestCopyScenarioTo( const ScColumn& rDestCol ) const { bool bOk = true; - ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc()->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) @@ -1867,7 +1867,7 @@ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const { ScRange aRange( nCol, 0, nTab ); - ScAttrIterator aAttrIter( pAttrArray.get(), 0, GetDoc()->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) @@ -1944,7 +1944,7 @@ void ScColumn::UpdateDrawObjectsForRow( std::vector<SdrObject*>& pObjects, SCCOL ScAddress aNewAddress(nTargetCol, nTargetRow, nTab); // Update draw object according to new anchor - ScDrawLayer* pDrawLayer = GetDoc()->GetDrawLayer(); + ScDrawLayer* pDrawLayer = GetDoc().GetDrawLayer(); if (pDrawLayer) pDrawLayer->MoveObject(pObject, aNewAddress); } @@ -1952,7 +1952,7 @@ void ScColumn::UpdateDrawObjectsForRow( std::vector<SdrObject*>& pObjects, SCCOL bool ScColumn::IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const { - ScDrawLayer* pDrawLayer = GetDoc()->GetDrawLayer(); + ScDrawLayer* pDrawLayer = GetDoc().GetDrawLayer(); if (!pDrawLayer) return true; @@ -1971,8 +1971,8 @@ void ScColumn::SwapCol(ScColumn& rCol) std::swap( mnBlkCountFormula, rCol.mnBlkCountFormula); // notes update caption - UpdateNoteCaptions(0, GetDoc()->MaxRow()); - rCol.UpdateNoteCaptions(0, GetDoc()->MaxRow()); + UpdateNoteCaptions(0, GetDoc().MaxRow()); + rCol.UpdateNoteCaptions(0, GetDoc().MaxRow()); std::swap(pAttrArray, rCol.pAttrArray); @@ -1993,7 +1993,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) pAttrArray->MoveTo(nStartRow, nEndRow, *rCol.pAttrArray); // Mark the non-empty cells within the specified range, for later broadcasting. - sc::SingleColumnSpanSet aNonEmpties(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aNonEmpties(GetDoc().GetSheetLimits()); aNonEmpties.scan(*this, nStartRow, nEndRow); sc::SingleColumnSpanSet::SpansType aRanges; aNonEmpties.getSpans(aRanges); @@ -2001,7 +2001,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) // Split the formula grouping at the top and bottom boundaries. sc::CellStoreType::position_type aPos = maCells.position(nStartRow); sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr); - if (GetDoc()->ValidRow(nEndRow+1)) + if (GetDoc().ValidRow(nEndRow+1)) { aPos = maCells.position(aPos.first, nEndRow+1); sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr); @@ -2010,7 +2010,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) // Do the same with the destination column. aPos = rCol.maCells.position(nStartRow); sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr); - if (GetDoc()->ValidRow(nEndRow+1)) + if (GetDoc().ValidRow(nEndRow+1)) { aPos = rCol.maCells.position(aPos.first, nEndRow+1); sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr); @@ -2023,12 +2023,12 @@ 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, GetDoc()->MaxRow()); + UpdateNoteCaptions(0, GetDoc().MaxRow()); // Re-group transferred formula cells. aPos = rCol.maCells.position(nStartRow); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); - if (GetDoc()->ValidRow(nEndRow+1)) + if (GetDoc().ValidRow(nEndRow+1)) { aPos = rCol.maCells.position(aPos.first, nEndRow+1); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); @@ -2038,7 +2038,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) rCol.CellStorageModified(); // Broadcast on moved ranges. Area-broadcast only. - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); ScHint aHint(SfxHintId::ScDataChanged, ScAddress(nCol, 0, nTab)); ScAddress& rPos = aHint.GetAddress(); for (const auto& rRange : aRanges) @@ -2046,7 +2046,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) for (SCROW nRow = rRange.mnRow1; nRow <= rRange.mnRow2; ++nRow) { rPos.SetRow(nRow); - pDocument->AreaBroadcast(aHint); + rDocument.AreaBroadcast(aHint); } } } @@ -2466,7 +2466,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() < GetDoc()->MaxRow()) + if (rCxt.maRange.aEnd.Row() < GetDoc().MaxRow()) { aPos = maCells.position(aPos.first, rCxt.maRange.aEnd.Row()+1); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); @@ -2480,7 +2480,7 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc if (rCxt.meMode == URM_COPY) return UpdateReferenceOnCopy(rCxt, pUndoDoc); - if (IsEmptyData() || GetDoc()->IsClipOrUndo()) + if (IsEmptyData() || GetDoc().IsClipOrUndo()) // Cells in this column are all empty, or clip or undo doc. No update needed. return false; @@ -2498,15 +2498,15 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc if (rCxt.mnRowDelta < 0) { nSplitPos = rCxt.maRange.aStart.Row() + rCxt.mnRowDelta; - if (GetDoc()->ValidRow(nSplitPos)) + if (GetDoc().ValidRow(nSplitPos)) aBounds.push_back(nSplitPos); } nSplitPos = rCxt.maRange.aStart.Row(); - if (GetDoc()->ValidRow(nSplitPos)) + if (GetDoc().ValidRow(nSplitPos)) { aBounds.push_back(nSplitPos); nSplitPos = rCxt.maRange.aEnd.Row() + 1; - if (GetDoc()->ValidRow(nSplitPos)) + if (GetDoc().ValidRow(nSplitPos)) aBounds.push_back(nSplitPos); } } @@ -2525,7 +2525,7 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc } // Do the actual splitting. - const bool bSplit = sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds); + const bool bSplit = sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds); // Collect all formula groups. std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries(); @@ -2823,7 +2823,7 @@ class SetDirtyOnRangeHandler ScColumn& mrColumn; public: explicit SetDirtyOnRangeHandler(ScColumn& rColumn) - : maValueRanges(rColumn.GetDoc()->GetSheetLimits()), + : maValueRanges(rColumn.GetDoc().GetSheetLimits()), mrColumn(rColumn) {} void operator() (size_t /*nRow*/, ScFormulaCell* p) @@ -2858,7 +2858,7 @@ public: maValueRanges.getSpans(aSpans); for (const auto& rSpan : aSpans) - rBroadcastSpans.set(*mrColumn.GetDoc(), nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); + rBroadcastSpans.set(mrColumn.GetDoc(), nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); } }; @@ -2868,7 +2868,7 @@ class SetTableOpDirtyOnRangeHandler ScColumn& mrColumn; public: explicit SetTableOpDirtyOnRangeHandler(ScColumn& rColumn) - : maValueRanges(rColumn.GetDoc()->GetSheetLimits()), + : maValueRanges(rColumn.GetDoc().GetSheetLimits()), mrColumn(rColumn) {} void operator() (size_t /*nRow*/, ScFormulaCell* p) @@ -2984,7 +2984,7 @@ public: void operator() (size_t nRow, ScFormulaCell* pCell) { - sal_uInt32 nFormat = mrCol.GetNumberFormat(mrCol.GetDoc()->GetNonThreadedContext(), nRow); + sal_uInt32 nFormat = mrCol.GetNumberFormat(mrCol.GetDoc().GetNonThreadedContext(), nRow); if( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0) // Non-default number format is set. pCell->SetNeedNumberFormat(false); @@ -3218,7 +3218,7 @@ void ScColumn::SetDirtyVar() bool ScColumn::IsFormulaDirty( SCROW nRow ) const { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return false; std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow); @@ -3233,7 +3233,7 @@ bool ScColumn::IsFormulaDirty( SCROW nRow ) const void ScColumn::CheckVectorizationState() { - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); CheckVectorizationHandler aFunc; sc::ProcessFormula(maCells, aFunc); } @@ -3241,8 +3241,8 @@ void ScColumn::CheckVectorizationState() void ScColumn::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ) { // is only done documentwide, no FormulaTracking - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); - SetDirtyHandler aFunc(*GetDoc(), rCxt); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); + SetDirtyHandler aFunc(GetDoc(), rCxt); sc::ProcessFormula(maCells, aFunc); } @@ -3250,7 +3250,7 @@ void ScColumn::SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rB { // Set all formula cells in the range dirty, and pick up all non-formula // cells for later broadcasting. We don't broadcast here. - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); SetDirtyOnRangeHandler aHdl(*this); sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aHdl, aHdl); @@ -3296,7 +3296,7 @@ bool ScColumn::BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint ) void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode ) { // broadcasts everything within the range, with FormulaTracking - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); switch (eMode) { @@ -3328,7 +3328,7 @@ void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode ) // formulas via ScDocument::Broadcast(), which // BroadcastBroadcastersHandler doesn't, so explicitly // track them here. - GetDoc()->TrackFormulas(); + GetDoc().TrackFormulas(); } } break; @@ -3337,7 +3337,7 @@ void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode ) void ScColumn::SetTableOpDirty( const ScRange& rRange ) { - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row(); SetTableOpDirtyOnRangeHandler aHdl(*this); @@ -3347,7 +3347,7 @@ void ScColumn::SetTableOpDirty( const ScRange& rRange ) void ScColumn::SetDirtyAfterLoad() { - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); SetDirtyAfterLoadHandler aFunc; sc::ProcessFormula(maCells, aFunc); } @@ -3374,14 +3374,14 @@ public: void ScColumn::SetDirtyIfPostponed() { - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); SetDirtyIfPostponedHandler aFunc; sc::ProcessFormula(maCells, aFunc); } void ScColumn::BroadcastRecalcOnRefMove() { - sc::AutoCalcSwitch aSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aSwitch(GetDoc(), false); RecalcOnRefMoveCollector aFunc; sc::ProcessFormula(maCells, aFunc); BroadcastCells(aFunc.getDirtyRows(), SfxHintId::ScDataChanged); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 32080e851d8c..ef354cd943bf 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -132,8 +132,8 @@ long ScColumn::GetNeededSize( } // conditional formatting - ScDocument* pDocument = GetDoc(); - const SfxItemSet* pCondSet = pDocument->GetCondResult( nCol, nRow, nTab ); + ScDocument& rDocument = GetDoc(); + const SfxItemSet* pCondSet = rDocument.GetCondResult( nCol, nRow, nTab ); //The pPattern may change in GetCondResult if (aCell.meType == CELLTYPE_FORMULA) @@ -160,7 +160,7 @@ long ScColumn::GetNeededSize( else bBreak = pPattern->GetItem(ATTR_LINEBREAK).GetValue(); - SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); + SvNumberFormatter* pFormatter = rDocument.GetFormatTable(); sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet ); // get "cell is value" flag @@ -258,7 +258,7 @@ long ScColumn::GetNeededSize( nIndent = pPattern->GetItem(ATTR_INDENT).GetValue(); } - SvtScriptType nScript = pDocument->GetScriptType(nCol, nRow, nTab); + SvtScriptType nScript = rDocument.GetScriptType(nCol, nRow, nTab); if (nScript == SvtScriptType::NONE) nScript = ScGlobal::GetDefaultScriptType(); // also call SetFont for edit cells, because bGetFont may be set only once @@ -285,7 +285,7 @@ long ScColumn::GetNeededSize( const Color* pColor; OUString aValStr; ScCellFormat::GetString( - aCell, nFormat, aValStr, &pColor, *pFormatter, pDocument, true, rOptions.bFormula); + aCell, nFormat, aValStr, &pColor, *pFormatter, &rDocument, true, rOptions.bFormula); if (!aValStr.isEmpty()) { @@ -311,12 +311,12 @@ long ScColumn::GetNeededSize( nWidth = static_cast<long>( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); else if ( rOptions.bTotalSize ) { - nWidth = conditionalScaleFunc(pDocument->GetColWidth( nCol,nTab ), nPPT); + nWidth = conditionalScaleFunc(rDocument.GetColWidth( nCol,nTab ), nPPT); bAddMargin = false; // only to the right: //TODO: differ on direction up/down (only Text/whole height) if ( pPattern->GetRotateDir( pCondSet ) == ScRotateDir::Right ) - nWidth += static_cast<long>( pDocument->GetRowHeight( nRow,nTab ) * + nWidth += static_cast<long>( rDocument.GetRowHeight( nRow,nTab ) * (bInPrintTwips ? 1.0 : nPPT) * nCosAbs / nSinAbs ); } else @@ -355,7 +355,7 @@ long ScColumn::GetNeededSize( // test with EditEngine the safety at 90% // (due to rounding errors and because EditEngine formats partially differently) - long nDocSize = conditionalScaleFunc((pDocument->GetColWidth( nCol,nTab ) - + long nDocSize = conditionalScaleFunc((rDocument.GetColWidth( nCol,nTab ) - pMargin->GetLeftMargin() - pMargin->GetRightMargin() - nIndent), nPPTX); nDocSize = (nDocSize * 9) / 10; // for safety @@ -374,7 +374,7 @@ long ScColumn::GetNeededSize( MapMode aTwipMode(MapUnit::MapTwip, Point(), rZoomX, rZoomY); // save in document ? - std::unique_ptr<ScFieldEditEngine> pEngine = pDocument->CreateFieldEditEngine(); + std::unique_ptr<ScFieldEditEngine> pEngine = rDocument.CreateFieldEditEngine(); pEngine->SetUpdateMode( false ); bool bTextWysiwyg = ( pDev->GetOutDevType() == OUTDEV_PRINTER ); @@ -387,9 +387,9 @@ long ScColumn::GetNeededSize( MapMode aOld = pDev->GetMapMode(); pDev->SetMapMode( aHMMMode ); pEngine->SetRefDevice( pDev ); - pDocument->ApplyAsianEditSettings( *pEngine ); + rDocument.ApplyAsianEditSettings( *pEngine ); std::unique_ptr<SfxItemSet> pSet(new SfxItemSet( pEngine->GetEmptyItemSet() )); - if ( ScStyleSheet* pPreviewStyle = pDocument->GetPreviewCellStyle( nCol, nRow, nTab ) ) + if ( ScStyleSheet* pPreviewStyle = rDocument.GetPreviewCellStyle( nCol, nRow, nTab ) ) { std::unique_ptr<ScPatternAttr> pPreviewPattern(new ScPatternAttr( *pPattern )); pPreviewPattern->SetStyleSheet(pPreviewStyle); @@ -397,7 +397,7 @@ long ScColumn::GetNeededSize( } else { - SfxItemSet* pFontSet = pDocument->GetPreviewFont( nCol, nRow, nTab ); + SfxItemSet* pFontSet = rDocument.GetPreviewFont( nCol, nRow, nTab ); pPattern->FillEditItemSet( pSet.get(), pFontSet ? pFontSet : pCondSet ); } // no longer needed, are set with the text (is faster) @@ -425,11 +425,11 @@ long ScColumn::GetNeededSize( } // use original width for hidden columns: - long nDocWidth = static_cast<long>( pDocument->GetOriginalWidth(nCol,nTab) * fWidthFactor ); + long nDocWidth = static_cast<long>( rDocument.GetOriginalWidth(nCol,nTab) * fWidthFactor ); SCCOL nColMerge = pMerge->GetColMerge(); if (nColMerge > 1) for (SCCOL nColAdd=1; nColAdd<nColMerge; nColAdd++) - nDocWidth += static_cast<long>( pDocument->GetColWidth(nCol+nColAdd,nTab) * fWidthFactor ); + nDocWidth += static_cast<long>( rDocument.GetColWidth(nCol+nColAdd,nTab) * fWidthFactor ); nDocWidth -= static_cast<long>( pMargin->GetLeftMargin() * fWidthFactor ) + static_cast<long>( pMargin->GetRightMargin() * fWidthFactor ) + 1; // output size is width-1 pixel (due to gridline) @@ -462,7 +462,7 @@ long ScColumn::GetNeededSize( const Color* pColor; OUString aString; ScCellFormat::GetString( - aCell, nFormat, aString, &pColor, *pFormatter, pDocument, true, + aCell, nFormat, aString, &pColor, *pFormatter, &rDocument, true, rOptions.bFormula); if (!aString.isEmpty()) @@ -492,10 +492,10 @@ long ScColumn::GetNeededSize( nWidth = static_cast<long>( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); else if ( rOptions.bTotalSize ) { - nWidth = conditionalScaleFunc(pDocument->GetColWidth( nCol,nTab ), nPPT); + nWidth = conditionalScaleFunc(rDocument.GetColWidth( nCol,nTab ), nPPT); bAddMargin = false; if ( pPattern->GetRotateDir( pCondSet ) == ScRotateDir::Right ) - nWidth += static_cast<long>( pDocument->GetRowHeight( nRow,nTab ) * + nWidth += static_cast<long>( rDocument.GetRowHeight( nRow,nTab ) * (bInPrintTwips ? 1.0 : nPPT) * nCosAbs / nSinAbs ); } else @@ -581,7 +581,7 @@ long ScColumn::GetNeededSize( // EditEngine is cached and re-used, so the old vertical flag must be restored pEngine->SetVertical( bEngineVertical ); - pDocument->DisposeFieldEditEngine(pEngine); + rDocument.DisposeFieldEditEngine(pEngine); pDev->SetMapMode( aOld ); pDev->SetFont( aOldFont ); @@ -669,7 +669,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( // All cells are empty. return nOldWidth; - sc::SingleColumnSpanSet aSpanSet(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aSpanSet(GetDoc().GetSheetLimits()); sc::SingleColumnSpanSet::SpansType aMarkedSpans; if (pMarkData && (pMarkData->IsMarked() || pMarkData->IsMultiMarked())) { @@ -678,11 +678,11 @@ sal_uInt16 ScColumn::GetOptimalColWidth( } else // "Select" the entire column if no selection exists. - aMarkedSpans.emplace_back(0, GetDoc()->MaxRow()); + aMarkedSpans.emplace_back(0, GetDoc().MaxRow()); sal_uInt16 nWidth = static_cast<sal_uInt16>(nOldWidth*nPPTX); bool bFound = false; - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); if ( pParam && pParam->mbSimpleText ) { // all the same except for number format @@ -696,7 +696,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( static_cast<long>( pMargin->GetRightMargin() * nPPTX ); // Try to find the row that has the longest string, and measure the width of that string. - SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); + SvNumberFormatter* pFormatter = rDocument.GetFormatTable(); sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter ); OUString aLongStr; const Color* pColor; @@ -704,12 +704,12 @@ sal_uInt16 ScColumn::GetOptimalColWidth( { ScRefCellValue aCell = GetCellValue(pParam->mnMaxTextRow); ScCellFormat::GetString( - aCell, nFormat, aLongStr, &pColor, *pFormatter, pDocument); + aCell, nFormat, aLongStr, &pColor, *pFormatter, &rDocument); } else { // Go though all non-empty cells within selection. - MaxStrLenFinder aFunc(*pDocument, nFormat); + MaxStrLenFinder aFunc(rDocument, nFormat); sc::CellStoreType::const_iterator itPos = maCells.begin(); for (const auto& rMarkedSpan : aMarkedSpans) itPos = sc::ParseAllNonEmpty(itPos, maCells, rMarkedSpan.mnRow1, rMarkedSpan.mnRow2, aFunc); @@ -748,7 +748,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( for (size_t nOffset = aPos.second; nOffset < itPos->size; ++nOffset, ++nRow) { - SvtScriptType nScript = pDocument->GetScriptType(nCol, nRow, nTab); + SvtScriptType nScript = rDocument.GetScriptType(nCol, nRow, nTab); if (nScript == SvtScriptType::NONE) nScript = ScGlobal::GetDefaultScriptType(); @@ -814,9 +814,9 @@ static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16 void ScColumn::GetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart ) { - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); RowHeightsArray& rHeights = rCxt.getHeightArray(); - ScAttrIterator aIter( pAttrArray.get(), nStartRow, nEndRow, pDocument->GetDefPattern() ); + ScAttrIterator aIter( pAttrArray.get(), nStartRow, nEndRow, rDocument.GetDefPattern() ); SCROW nStart = -1; SCROW nEnd = -1; @@ -889,7 +889,7 @@ void ScColumn::GetOptimalHeight( } } - sc::SingleColumnSpanSet aSpanSet(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aSpanSet(GetDoc().GetSheetLimits()); aSpanSet.scan(*this, nStart, nEnd); sc::SingleColumnSpanSet::SpansType aSpans; aSpanSet.getSpans(aSpans); @@ -980,7 +980,7 @@ void ScColumn::GetOptimalHeight( { // only calculate the cell height when it's used later (#37928#) - if (rCxt.isForceAutoSize() || !(pDocument->GetRowFlags(nRow, nTab) & CRFlags::ManualSize) ) + if (rCxt.isForceAutoSize() || !(rDocument.GetRowFlags(nRow, nTab) & CRFlags::ManualSize) ) { aOptions.pPattern = pPattern; const ScPatternAttr* pOldPattern = pPattern; @@ -1017,7 +1017,7 @@ void ScColumn::GetOptimalHeight( bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const { - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); bool bStop = false; sc::CellStoreType::const_iterator it = maCells.position(nRow).first; mdds::mtv::element_t eType = it->type; @@ -1025,7 +1025,7 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& r { if ( (eType == sc::element_type_string || eType == sc::element_type_edittext) && !(HasAttrib( nRow, nRow, HasAttrFlags::Protected) && - pDocument->IsTabProtected(nTab)) ) + rDocument.IsTabProtected(nTab)) ) return true; } while (!bStop) @@ -1033,9 +1033,9 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& r if (bInSel) { nRow = rData.GetNextMarked(nCol, nRow, false); - if (!pDocument->ValidRow(nRow)) + if (!rDocument.ValidRow(nRow)) { - nRow = GetDoc()->MaxRow()+1; + nRow = GetDoc().MaxRow()+1; bStop = true; } else @@ -1044,7 +1044,7 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& r eType = it->type; if ( (eType == sc::element_type_string || eType == sc::element_type_edittext) && !(HasAttrib( nRow, nRow, HasAttrFlags::Protected) && - pDocument->IsTabProtected(nTab)) ) + rDocument.IsTabProtected(nTab)) ) return true; else nRow++; @@ -1056,14 +1056,14 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& r eType = it->type; if ( (eType == sc::element_type_string || eType == sc::element_type_edittext) && !(HasAttrib( nRow, nRow, HasAttrFlags::Protected) && - pDocument->IsTabProtected(nTab)) ) + rDocument.IsTabProtected(nTab)) ) return true; else nRow++; } else { - nRow = GetDoc()->MaxRow()+1; + nRow = GetDoc().MaxRow()+1; bStop = true; } } @@ -1181,7 +1181,7 @@ public: void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) { - RemoveEditAttribsHandler aFunc(maCells, GetDoc()); + RemoveEditAttribsHandler aFunc(maCells, &GetDoc()); sc::ProcessEditText(maCells.begin(), maCells, nStartRow, nEndRow, aFunc); aFunc.commitStrings(); } @@ -1341,15 +1341,15 @@ SCROW ScColumn::GetLastDataPos() const sc::CellStoreType::const_reverse_iterator it = maCells.rbegin(); if (it->type != sc::element_type_empty) - return GetDoc()->MaxRow(); + return GetDoc().MaxRow(); - return GetDoc()->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,GetDoc()->MaxRow())); + sc::CellStoreType::const_position_type aPos = maCells.position(std::min(nLastRow,GetDoc().MaxRow())); if (bConsiderCellNotes && !IsNotesEmptyBlock(nLastRow, nLastRow)) return nLastRow; @@ -1511,17 +1511,17 @@ SCROW ScColumn::FindNextVisibleRow(SCROW nRow, bool bForward) const { nRow++; SCROW nEndRow = 0; - bool bHidden = GetDoc()->RowHidden(nRow, nTab, nullptr, &nEndRow); + bool bHidden = GetDoc().RowHidden(nRow, nTab, nullptr, &nEndRow); if(bHidden) - return std::min<SCROW>(GetDoc()->MaxRow(), nEndRow + 1); + return std::min<SCROW>(GetDoc().MaxRow(), nEndRow + 1); else return nRow; } else { nRow--; - SCROW nStartRow = GetDoc()->MaxRow(); - bool bHidden = GetDoc()->RowHidden(nRow, nTab, &nStartRow); + SCROW nStartRow = GetDoc().MaxRow(); + bool bHidden = GetDoc().RowHidden(nRow, nTab, &nStartRow); if(bHidden) return std::max<SCROW>(0, nStartRow - 1); else @@ -1532,26 +1532,26 @@ SCROW ScColumn::FindNextVisibleRow(SCROW nRow, bool bForward) const SCROW ScColumn::FindNextVisibleRowWithContent( sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const { - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); if (bForward) { do { nRow++; SCROW nEndRow = 0; - bool bHidden = pDocument->RowHidden(nRow, nTab, nullptr, &nEndRow); + bool bHidden = rDocument.RowHidden(nRow, nTab, nullptr, &nEndRow); if (bHidden) { nRow = nEndRow + 1; - if(nRow >= GetDoc()->MaxRow()) - return GetDoc()->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 GetDoc()->MaxRow(); + return GetDoc().MaxRow(); if (itPos->type != sc::element_type_empty) return nRow; @@ -1559,16 +1559,16 @@ SCROW ScColumn::FindNextVisibleRowWithContent( // Move to the last cell of the current empty block. nRow += itPos->size - aPos.second - 1; } - while (nRow < GetDoc()->MaxRow()); + while (nRow < GetDoc().MaxRow()); - return GetDoc()->MaxRow(); + return GetDoc().MaxRow(); } do { nRow--; - SCROW nStartRow = GetDoc()->MaxRow(); - bool bHidden = pDocument->RowHidden(nRow, nTab, &nStartRow); + SCROW nStartRow = GetDoc().MaxRow(); + bool bHidden = rDocument.RowHidden(nRow, nTab, &nStartRow); if (bHidden) { nRow = nStartRow - 1; @@ -1598,7 +1598,7 @@ void ScColumn::CellStorageModified() // Remove cached values. Given how often this function is called and how (not that) often // the cached values are used, it should be more efficient to just discard everything // instead of trying to figure out each time exactly what to discard. - GetDoc()->DiscardFormulaGroupContext(); + GetDoc().DiscardFormulaGroupContext(); // TODO: Update column's "last updated" timestamp here. @@ -1773,7 +1773,7 @@ struct ColumnStorageDumper void ScColumn::DumpColumnStorage() const { cout << "-- table: " << nTab << "; column: " << nCol << endl; - std::for_each(maCells.begin(), maCells.end(), ColumnStorageDumper(GetDoc())); + std::for_each(maCells.begin(), maCells.end(), ColumnStorageDumper(&GetDoc())); cout << "--" << endl; } #endif @@ -1866,9 +1866,9 @@ public: SCROW nDestRow = nRow + mnDestOffset; ScAddress aSrcPos(mnSrcCol, nRow, mnSrcTab); ScAddress aDestPos(mnDestCol, nDestRow, mnDestTab); - miPos = mrDestNotes.set(miPos, nDestRow, p->Clone(aSrcPos, *mrDestCol.GetDoc(), aDestPos, mbCloneCaption).release()); + miPos = mrDestNotes.set(miPos, nDestRow, p->Clone(aSrcPos, mrDestCol.GetDoc(), aDestPos, mbCloneCaption).release()); // Notify our LOK clients also - ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, mrDestCol.GetDoc(), aDestPos, p); + ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, &mrDestCol.GetDoc(), aDestPos, p); } }; @@ -1881,7 +1881,7 @@ void ScColumn::CopyCellNotesToDocument( // The column has no cell notes to copy between specified rows. return; - ScDrawLayer *pDrawLayer = rDestCol.GetDoc()->GetDrawLayer(); + ScDrawLayer *pDrawLayer = rDestCol.GetDoc().GetDrawLayer(); bool bWasLocked = bool(); if (pDrawLayer) { @@ -1995,7 +1995,7 @@ namespace { void ScColumn::CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership) { ScAddress aAddr(nCol, 0, nTab); - CellNoteHandler aFunc(GetDoc(), aAddr, bForgetCaptionOwnership); + CellNoteHandler aFunc(&GetDoc(), aAddr, bForgetCaptionOwnership); sc::ParseNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc); } @@ -2055,7 +2055,7 @@ void ScColumn::SetTextWidth(SCROW nRow, sal_uInt16 nWidth) SvtScriptType ScColumn::GetScriptType( SCROW nRow ) const { - if (!GetDoc()->ValidRow(nRow) || maCellTextAttrs.is_empty(nRow)) + if (!GetDoc().ValidRow(nRow) || maCellTextAttrs.is_empty(nRow)) return SvtScriptType::NONE; return maCellTextAttrs.get<sc::CellTextAttr>(nRow).mnScriptType; @@ -2064,7 +2064,7 @@ SvtScriptType ScColumn::GetScriptType( SCROW nRow ) const SvtScriptType ScColumn::GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2, const sc::CellStoreType::iterator& itrCells_ ) { - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2) || nRow1 > nRow2) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return SvtScriptType::NONE; SCROW nRow = nRow1; @@ -2134,7 +2134,7 @@ SvtScriptType ScColumn::GetRangeScriptType( void ScColumn::SetScriptType( SCROW nRow, SvtScriptType nType ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; sc::CellTextAttrStoreType::position_type aPos = maCellTextAttrs.position(nRow); @@ -2189,8 +2189,8 @@ formula::FormulaTokenRef ScColumn::ResolveStaticReference( SCROW nRow ) case sc::element_type_edittext: { const EditTextObject* pText = sc::edittext_block::at(*it->data, aPos.second); - OUString aStr = ScEditUtil::GetString(*pText, GetDoc()); - svl::SharedString aSS( GetDoc()->GetSharedStringPool().intern(aStr)); + OUString aStr = ScEditUtil::GetString(*pText, &GetDoc()); + svl::SharedString aSS( GetDoc().GetSharedStringPool().intern(aStr)); return formula::FormulaTokenRef(new formula::FormulaStringToken(aSS)); } case sc::element_type_empty: @@ -2247,7 +2247,7 @@ bool ScColumn::ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow if (nRow1 > nRow2) return false; - ToMatrixHandler aFunc(rMat, nMatCol, nRow1, GetDoc()); + ToMatrixHandler aFunc(rMat, nMatCol, nRow1, &GetDoc()); sc::ParseAllNonEmpty(maCells.begin(), maCells, nRow1, nRow2, aFunc); return true; } @@ -2445,7 +2445,7 @@ public: void ScColumn::FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool* pPool ) const { - FillMatrixHandler aFunc(rMat, nMatCol, nRow1, GetDoc(), pPool); + FillMatrixHandler aFunc(rMat, nMatCol, nRow1, &GetDoc(), pPool); sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2); } @@ -2724,8 +2724,8 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 return formula::VectorRefArray(formula::VectorRefArray::Invalid); // See if the requested range is already cached. - ScDocument* pDocument = GetDoc(); - sc::FormulaGroupContext& rCxt = *(pDocument->GetFormulaGroupContext()); + ScDocument& rDocument = GetDoc(); + sc::FormulaGroupContext& rCxt = *(rDocument.GetFormulaGroupContext()); sc::FormulaGroupContext::ColArray* pColArray = rCxt.getCachedColArray(nTab, nCol, nRow2+1); if (pColArray) { @@ -2744,7 +2744,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 // on any modification. However getting cell values may cause this to be called // if interpreting a cell results in a change to it (not just its result though). // So temporarily block the discarding. - ProtectFormulaGroupContext protectContext( GetDoc()); + ProtectFormulaGroupContext protectContext(&GetDoc()); double fNan; rtl::math::setNan(&fNan); @@ -2778,7 +2778,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 // Fill the remaining array with values from the following blocks. size_t nPos = itBlk->size; ++itBlk; - if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) { rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); @@ -2805,16 +2805,16 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 if (o3tl::make_unsigned(nRow2) < itBlk->size) { // Requested range falls within the first block. - copyFirstStringBlock(*pDocument, rArray, nRow2+1, itBlk); + copyFirstStringBlock(rDocument, rArray, nRow2+1, itBlk); return formula::VectorRefArray(&rArray[nRow1]); } - copyFirstStringBlock(*pDocument, rArray, itBlk->size, itBlk); + copyFirstStringBlock(rDocument, rArray, itBlk->size, itBlk); // Fill the remaining array with values from the following blocks. size_t nPos = itBlk->size; ++itBlk; - if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) { rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); @@ -2862,7 +2862,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 size_t nPos = itBlk->size; ++itBlk; - if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) { rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); @@ -2895,7 +2895,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 // Fill the remaining array with values from the following blocks. size_t nPos = itBlk->size; ++itBlk; - if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) { rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); @@ -2978,7 +2978,7 @@ void ScColumn::SetFormulaResults( SCROW nRow, const double* pResults, size_t nLe void ScColumn::CalculateInThread( ScInterpreterContext& rContext, SCROW nRow, size_t nLen, size_t nOffset, unsigned nThisThread, unsigned nThreadsTotal) { - assert(GetDoc()->IsThreadedGroupCalcInProgress()); + assert(GetDoc().IsThreadedGroupCalcInProgress()); sc::CellStoreType::position_type aPos = maCells.position(nRow); sc::CellStoreType::iterator it = aPos.first; @@ -3044,7 +3044,7 @@ void ScColumn::SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat ) ScFormulaCell * const * ScColumn::GetFormulaCellBlockAddress( SCROW nRow, size_t& rBlockSize ) const { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) { rBlockSize = 0; return nullptr; @@ -3297,7 +3297,7 @@ void ScColumn::EndListening( SvtListener& rLst, SCROW nRow ) void ScColumn::StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rLst ) { - if (!GetDoc()->ValidRow(rAddress.Row())) + if (!GetDoc().ValidRow(rAddress.Row())) return; sc::ColumnBlockPosition* p = rCxt.getBlockPosition(rAddress.Tab(), rAddress.Col()); @@ -3445,7 +3445,7 @@ public: void ScColumn::UpdateSelectionFunction( const ScRangeList& rRanges, ScFunctionData& rData, const ScFlatBoolRowSegments& rHiddenRows ) { - sc::SingleColumnSpanSet aSpanSet(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aSpanSet(GetDoc().GetSheetLimits()); aSpanSet.scan(rRanges, nTab, nCol); // mark all selected rows. if (aSpanSet.empty()) @@ -3454,7 +3454,7 @@ void ScColumn::UpdateSelectionFunction( // Exclude all hidden rows. ScFlatBoolRowSegments::RangeData aRange; SCROW nRow = 0; - while (nRow <= GetDoc()->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 4079fb04266c..f01d82c1058a 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -66,7 +66,7 @@ using namespace formula; void ScColumn::Broadcast( SCROW nRow ) { ScHint aHint(SfxHintId::ScDataChanged, ScAddress(nCol, nRow, nTab)); - GetDoc()->Broadcast(aHint); + GetDoc().Broadcast(aHint); } void ScColumn::BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint ) @@ -75,18 +75,18 @@ void ScColumn::BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint return; // Broadcast the changes. - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); ScHint aHint(nHint, ScAddress(nCol, 0, nTab)); for (const auto& rRow : rRows) { aHint.GetAddress().SetRow(rRow); - pDocument->Broadcast(aHint); + rDocument.Broadcast(aHint); } } void ScColumn::BroadcastRows( SCROW nStartRow, SCROW nEndRow, SfxHintId nHint ) { - sc::SingleColumnSpanSet aSpanSet(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aSpanSet(GetDoc().GetSheetLimits()); aSpanSet.scan(*this, nStartRow, nEndRow); std::vector<SCROW> aRows; aSpanSet.getRows(aRows); @@ -108,7 +108,7 @@ struct DirtyCellInterpreter void ScColumn::InterpretDirtyCells( SCROW nRow1, SCROW nRow2 ) { - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2) || nRow1 > nRow2) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return; DirtyCellInterpreter aFunc; @@ -125,7 +125,7 @@ void ScColumn::DeleteContent( SCROW nRow, bool bBroadcast ) if (it->type == sc::element_type_formula) { ScFormulaCell* p = sc::formula_block::at(*it->data, aPos.second); - p->EndListeningTo(*GetDoc()); + p->EndListeningTo(GetDoc()); sc::SharedFormulaUtil::unshareFormulaCell(aPos, *p); } maCells.set_empty(nRow, nRow); @@ -149,7 +149,7 @@ void ScColumn::Delete( SCROW nRow ) void ScColumn::FreeAll() { - auto maxRowCount = GetDoc()->GetSheetLimits().GetMaxRowCount(); + auto maxRowCount = GetDoc().GetSheetLimits().GetMaxRowCount(); // Keep a logical empty range of 0-rDoc.MaxRow() at all times. maCells.clear(); maCells.resize(maxRowCount); @@ -163,7 +163,7 @@ void ScColumn::FreeAll() void ScColumn::FreeNotes() { maCellNotes.clear(); - maCellNotes.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maCellNotes.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); } namespace { @@ -187,11 +187,11 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* SCROW nEndRow = nStartRow + nSize - 1; maBroadcasters.erase(nStartRow, nEndRow); - maBroadcasters.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maBroadcasters.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); CellNotesDeleting(nStartRow, nEndRow, false); maCellNotes.erase(nStartRow, nEndRow); - maCellNotes.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maCellNotes.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); // See if we have any cells that would get deleted or shifted by deletion. sc::CellStoreType::position_type aPos = maCells.position(nStartRow); @@ -211,7 +211,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 < GetDoc()->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; @@ -228,27 +228,27 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* bShiftCells = true; } - sc::SingleColumnSpanSet aNonEmptySpans(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aNonEmptySpans(GetDoc().GetSheetLimits()); if (bShiftCells) { // Mark all non-empty cell positions below the end row. sc::ColumnBlockConstPosition aBlockPos; aBlockPos.miCellPos = itCell; - aNonEmptySpans.scan(aBlockPos, *this, nEndRow+1, GetDoc()->MaxRow()); + aNonEmptySpans.scan(aBlockPos, *this, nEndRow+1, GetDoc().MaxRow()); } - sc::AutoCalcSwitch aACSwitch(*GetDoc(), false); + sc::AutoCalcSwitch aACSwitch(GetDoc(), false); // Remove the cells. maCells.erase(nStartRow, nEndRow); - maCells.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maCells.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); // Get the position again after the container change. aPos = maCells.position(nStartRow); // Shift the formula cell positions below the start row. ShiftFormulaPosHandler aShiftFormulaFunc; - sc::ProcessFormula(aPos.first, maCells, nStartRow, GetDoc()->MaxRow(), aShiftFormulaFunc); + sc::ProcessFormula(aPos.first, maCells, nStartRow, GetDoc().MaxRow(), aShiftFormulaFunc); bool bJoined = sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); if (bJoined && pGroupPos) @@ -256,7 +256,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* // Shift the text attribute array too (before the broadcast). maCellTextAttrs.erase(nStartRow, nEndRow); - maCellTextAttrs.resize(GetDoc()->GetSheetLimits().GetMaxRowCount()); + maCellTextAttrs.resize(GetDoc().GetSheetLimits().GetMaxRowCount()); CellStorageModified(); } @@ -290,7 +290,7 @@ void ScColumn::JoinNewFormulaCell( void ScColumn::DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, std::vector<SCROW>& rNewSharedRows ) { - if (!GetDoc()->IsClipOrUndo()) + if (!GetDoc().IsClipOrUndo()) { #if USE_FORMULA_GROUP_LISTENER if (rCell.IsShared() && rCell.GetSharedLength() > 1) @@ -334,7 +334,7 @@ void ScColumn::DetachFormulaCell( // Have the dying formula cell stop listening. // If in a shared formula group this ends the group listening. - rCell.EndListeningTo(*GetDoc()); + rCell.EndListeningTo(GetDoc()); } sc::SharedFormulaUtil::unshareFormulaCell(aPos, rCell); @@ -343,21 +343,21 @@ void ScColumn::DetachFormulaCell( void ScColumn::StartListeningUnshared( const std::vector<SCROW>& rNewSharedRows ) { assert(rNewSharedRows.empty() || rNewSharedRows.size() == 2 || rNewSharedRows.size() == 4); - ScDocument* pDoc = GetDoc(); - if (rNewSharedRows.empty() || pDoc->IsDelayedFormulaGrouping()) + ScDocument& rDoc = GetDoc(); + if (rNewSharedRows.empty() || rDoc.IsDelayedFormulaGrouping()) return; - auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*pDoc); - sc::StartListeningContext aStartCxt(*pDoc, pPosSet); - sc::EndListeningContext aEndCxt(*pDoc, pPosSet); + auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(rDoc); + sc::StartListeningContext aStartCxt(rDoc, pPosSet); + sc::EndListeningContext aEndCxt(rDoc, pPosSet); if (rNewSharedRows.size() >= 2) { - if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[0], rNewSharedRows[1])) + if(!rDoc.CanDelayStartListeningFormulaCells( this, rNewSharedRows[0], rNewSharedRows[1])) StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[0], rNewSharedRows[1]); } if (rNewSharedRows.size() >= 4) { - if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[2], rNewSharedRows[3])) + if(!rDoc.CanDelayStartListeningFormulaCells( this, rNewSharedRows[2], rNewSharedRows[3])) StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[2], rNewSharedRows[3]); } } @@ -405,7 +405,7 @@ void ScColumn::DetachFormulaCells( const size_t nNextTopRow = nRow + nLength; // start row of next formula group. bool bLowerSplitOff = false; - if (pNewSharedRows && !GetDoc()->IsClipOrUndo()) + if (pNewSharedRows && !GetDoc().IsClipOrUndo()) { const ScFormulaCell* pFC = sc::SharedFormulaUtil::getSharedTopFormulaCell(aPos); if (pFC) @@ -432,9 +432,9 @@ void ScColumn::DetachFormulaCells( // Split formula grouping at the top and bottom boundaries. sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr); - if (nLength > 0 && GetDoc()->ValidRow(nNextTopRow)) + if (nLength > 0 && GetDoc().ValidRow(nNextTopRow)) { - if (pNewSharedRows && !bLowerSplitOff && !GetDoc()->IsClipOrUndo()) + if (pNewSharedRows && !bLowerSplitOff && !GetDoc().IsClipOrUndo()) { sc::CellStoreType::position_type aPos2 = maCells.position(aPos.first, nNextTopRow-1); const ScFormulaCell* pFC = sc::SharedFormulaUtil::getSharedTopFormulaCell(aPos2); @@ -456,10 +456,10 @@ void ScColumn::DetachFormulaCells( sc::SharedFormulaUtil::splitFormulaCellGroup(aPos2, nullptr); } - if (GetDoc()->IsClipOrUndo()) + if (GetDoc().IsClipOrUndo()) return; - DetachFormulaCellsHandler aFunc(*GetDoc(), nullptr); + DetachFormulaCellsHandler aFunc(GetDoc(), nullptr); sc::ProcessFormula(aPos.first, maCells, nRow, nNextTopRow-1, aFunc); } @@ -469,13 +469,13 @@ void ScColumn::AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, sc::CellStoreType::iterator it = aPos.first; sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); - if (GetDoc()->ValidRow(nRow2+1)) + if (GetDoc().ValidRow(nRow2+1)) { aPos = maCells.position(it, nRow2+1); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); } - if (GetDoc()->IsClipOrUndo()) + if (GetDoc().IsClipOrUndo()) return; AttachFormulaCellsHandler aFunc(rCxt); @@ -489,7 +489,7 @@ void ScColumn::DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, S sc::CellStoreType::iterator it = aPos.first; bool bLowerSplitOff = false; - if (pNewSharedRows && !GetDoc()->IsClipOrUndo()) + if (pNewSharedRows && !GetDoc().IsClipOrUndo()) { const ScFormulaCell* pFC = sc::SharedFormulaUtil::getSharedTopFormulaCell(aPos); if (pFC) @@ -515,9 +515,9 @@ void ScColumn::DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, S // Split formula grouping at the top and bottom boundaries. sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, &rCxt); - if (GetDoc()->ValidRow(nRow2+1)) + if (GetDoc().ValidRow(nRow2+1)) { - if (pNewSharedRows && !bLowerSplitOff && !GetDoc()->IsClipOrUndo()) + if (pNewSharedRows && !bLowerSplitOff && !GetDoc().IsClipOrUndo()) { sc::CellStoreType::position_type aPos2 = maCells.position(aPos.first, nRow2); const ScFormulaCell* pFC = sc::SharedFormulaUtil::getSharedTopFormulaCell(aPos2); @@ -539,10 +539,10 @@ void ScColumn::DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, S sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, &rCxt); } - if (GetDoc()->IsClipOrUndo()) + if (GetDoc().IsClipOrUndo()) return; - DetachFormulaCellsHandler aFunc(*GetDoc(), &rCxt); + DetachFormulaCellsHandler aFunc(GetDoc(), &rCxt); sc::ProcessFormula(it, maCells, nRow1, nRow2, aFunc); } @@ -581,14 +581,14 @@ sc::CellStoreType::iterator ScColumn::GetPositionToInsert( const sc::CellStoreTy ScFormulaCell& rCell = *sc::formula_block::at(*itRet->data, aPos.second); DetachFormulaCell(aPos, rCell, rNewSharedRows); } - else if (bInsertFormula && !GetDoc()->IsClipOrUndo()) + else if (bInsertFormula && !GetDoc().IsClipOrUndo()) { if (nRow > 0) { sc::CellStoreType::position_type aPosBefore = maCells.position(maCells.begin(), nRow-1); lcl_AddFormulaGroupBoundaries(aPosBefore, rNewSharedRows); } - if (nRow < GetDoc()->MaxRow()) + if (nRow < GetDoc().MaxRow()) { sc::CellStoreType::position_type aPosAfter = maCells.position(maCells.begin(), nRow+1); lcl_AddFormulaGroupBoundaries(aPosAfter, rNewSharedRows); @@ -620,17 +620,17 @@ void ScColumn::AttachNewFormulaCell( // we call StartListeningFromClip and BroadcastFromClip. // If we insert into the Clipboard/andoDoc, we do not use a Broadcast. // After Import we call CalcAfterLoad and in there Listening. - ScDocument* pDocument = GetDoc(); - if (pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc()) + ScDocument& rDocument = GetDoc(); + if (rDocument.IsClipOrUndo() || rDocument.IsInsertingFromOtherDoc()) return; switch (eListenType) { case sc::ConvertToGroupListening: { - auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*pDocument); - sc::StartListeningContext aStartCxt(*pDocument, pPosSet); - sc::EndListeningContext aEndCxt(*pDocument, pPosSet); + auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(rDocument); + sc::StartListeningContext aStartCxt(rDocument, pPosSet); + sc::EndListeningContext aEndCxt(rDocument, pPosSet); SCROW nStartRow, nEndRow; nStartRow = nEndRow = aPos.first->position + aPos.second; for (const SCROW nR : rNewSharedRows) @@ -644,7 +644,7 @@ void ScColumn::AttachNewFormulaCell( } break; case sc::SingleCellListening: - rCell.StartListeningTo(*pDocument); + rCell.StartListeningTo(rDocument); StartListeningUnshared( rNewSharedRows); break; case sc::NoListening: @@ -669,7 +669,7 @@ void ScColumn::AttachNewFormulaCell( break; } - if (!pDocument->IsCalcingAfterLoad()) + if (!rDocument.IsCalcingAfterLoad()) rCell.SetDirty(); } @@ -693,8 +693,8 @@ void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aP ScFormulaCell* pCell2 = sc::formula_block::at(*aPosLast.first->data, aPosLast.second); JoinNewFormulaCell(aPosLast, *pCell2); - ScDocument* pDocument = GetDoc(); - if (pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc()) + ScDocument& rDocument = GetDoc(); + if (rDocument.IsClipOrUndo() || rDocument.IsInsertingFromOtherDoc()) return; const bool bShared = pCell1->IsShared() || pCell2->IsShared(); @@ -732,14 +732,14 @@ void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aP } StartListeningUnshared( rNewSharedRows); - sc::StartListeningContext aCxt(*pDocument); + sc::StartListeningContext aCxt(rDocument); ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second); ScFormulaCell** ppEnd = pp + nLength; for (; pp != ppEnd; ++pp) { if (!bShared) (*pp)->StartListeningTo(aCxt); - if (!pDocument->IsCalcingAfterLoad()) + if (!rDocument.IsCalcingAfterLoad()) (*pp)->SetDirty(); } } @@ -751,7 +751,7 @@ void ScColumn::BroadcastNewCell( SCROW nRow ) // we call StartListeningFromClip and BroadcastFromClip. // If we insert into the Clipboard/andoDoc, we do not use a Broadcast. // After Import we call CalcAfterLoad and in there Listening. - if (GetDoc()->IsClipOrUndo() || GetDoc()->IsInsertingFromOtherDoc() || GetDoc()->IsCalcingAfterLoad()) + if (GetDoc().IsClipOrUndo() || GetDoc().IsInsertingFromOtherDoc() || GetDoc().IsCalcingAfterLoad()) return; Broadcast(nRow); @@ -775,26 +775,26 @@ bool ScColumn::UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, sc::CellSt ScRefCellValue aCell = GetCellValue( itr, nOffset ); ScAddress aPos(nCol, nRow, nTab); - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); const SfxItemSet* pCondSet = nullptr; - ScConditionalFormatList* pCFList = pDocument->GetCondFormList(nTab); + ScConditionalFormatList* pCFList = rDocument.GetCondFormList(nTab); if (pCFList) { const ScCondFormatItem& rItem = pPattern->GetItem(ATTR_CONDITIONAL); const ScCondFormatIndexes& rData = rItem.GetCondFormatData(); - pCondSet = pDocument->GetCondResult(aCell, aPos, *pCFList, rData); + pCondSet = rDocument.GetCondResult(aCell, aPos, *pCFList, rData); } - SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); + SvNumberFormatter* pFormatter = rDocument.GetFormatTable(); OUString aStr; const Color* pColor; sal_uInt32 nFormat = pPattern->GetNumberFormat(pFormatter, pCondSet); - ScCellFormat::GetString(aCell, nFormat, aStr, &pColor, *pFormatter, pDocument); + ScCellFormat::GetString(aCell, nFormat, aStr, &pColor, *pFormatter, &rDocument); // Store the real script type to the array. - rAttr.mnScriptType = pDocument->GetStringScriptType(aStr); + rAttr.mnScriptType = rDocument.GetStringScriptType(aStr); return true; } @@ -969,7 +969,7 @@ void ScColumn::DeleteCells( sc::SingleColumnSpanSet& rDeleted ) { // Determine which cells to delete based on the deletion flags. - DeleteAreaHandler aFunc(*GetDoc(), nDelFlag, *this); + DeleteAreaHandler aFunc(GetDoc(), nDelFlag, *this); sc::CellStoreType::iterator itPos = maCells.position(rBlockPos.miCellPos, nRow1).first; sc::ProcessBlock(itPos, maCells, aFunc, nRow1, nRow2); aFunc.endFormulas(); // Have the formula cells stop listening. @@ -995,7 +995,7 @@ void ScColumn::DeleteArea( nContMask |= InsertDeleteFlags::NOCAPTIONS; InsertDeleteFlags nContFlag = nDelFlag & nContMask; - sc::SingleColumnSpanSet aDeletedRows(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aDeletedRows(GetDoc().GetSheetLimits()); sc::ColumnBlockPosition aBlockPos; InitBlockPosition(aBlockPos); @@ -1008,7 +1008,7 @@ void ScColumn::DeleteArea( sc::SingleColumnSpanSet::SpansType aSpans; aDeletedRows.getSpans(aSpans); for (const auto& rSpan : aSpans) - pBroadcastSpans->set(*GetDoc(), nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); + pBroadcastSpans->set(GetDoc(), nTab, nCol, rSpan.mnRow1, rSpan.mnRow2, true); } } @@ -1099,7 +1099,7 @@ class CopyCellsFromClipHandler aArr.AddSingleReference(aRef); mrDestCol.SetFormulaCell( - maDestBlockPos, nDestRow, new ScFormulaCell(mrDestCol.GetDoc(), aDestPos, aArr)); + maDestBlockPos, nDestRow, new ScFormulaCell(&mrDestCol.GetDoc(), aDestPos, aArr)); } void duplicateNotes(SCROW nStartRow, size_t nDataSize, bool bCloneCaption ) @@ -1255,7 +1255,7 @@ public: { mrDestCol.SetFormulaCell( maDestBlockPos, nSrcRow + mnRowOffset, - new ScFormulaCell(rSrcCell, *mrDestCol.GetDoc(), aDestPos), + new ScFormulaCell(rSrcCell, mrDestCol.GetDoc(), aDestPos), sc::SingleCellListening, rSrcCell.NeedsNumberFormat()); } @@ -1275,7 +1275,7 @@ public: insertRefCell(nSrcRow, nSrcRow + mnRowOffset); else { - ScFormulaCell* pErrCell = new ScFormulaCell(*mrDestCol.GetDoc(), aDestPos); + ScFormulaCell* pErrCell = new ScFormulaCell(mrDestCol.GetDoc(), aDestPos); pErrCell->SetErrCode(nErr); mrDestCol.SetFormulaCell( maDestBlockPos, nSrcRow + mnRowOffset, pErrCell); @@ -1310,7 +1310,7 @@ public: else if (rSrcCell.IsMultilineResult()) { // Clone as an edit text object. - ScFieldEditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine(); + ScFieldEditEngine& rEngine = mrDestCol.GetDoc().GetEditEngine(); rEngine.SetTextCurrentDefaults(aStr.getString()); mrDestCol.SetEditText(maDestBlockPos, nSrcRow + mnRowOffset, rEngine.CreateTextObject()); } @@ -1395,7 +1395,7 @@ void ScColumn::CopyFromClip( if (rCxt.isSkipAttrForEmptyCells()) { // copy only attributes for non-empty cells between nRow1-nDy and nRow2-nDy. - sc::SingleColumnSpanSet aSpanSet(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aSpanSet(GetDoc().GetSheetLimits()); aSpanSet.scan(rColumn, nRow1-nDy, nRow2-nDy); sc::SingleColumnSpanSet::SpansType aSpans; aSpanSet.getSpans(aSpans); @@ -1408,7 +1408,7 @@ void ScColumn::CopyFromClip( if ((rCxt.getInsertFlag() & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE) return; - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); if (rCxt.isAsLink() && rCxt.getInsertFlag() == InsertDeleteFlags::ALL) { // We also reference empty cells for "ALL" @@ -1429,9 +1429,9 @@ void ScColumn::CopyFromClip( aRef.SetAbsRow(nDestRow - nDy); // Source row aDestPos.SetRow( nDestRow ); - ScTokenArray aArr(*GetDoc()); + ScTokenArray aArr(GetDoc()); aArr.AddSingleReference( aRef ); - SetFormulaCell(nDestRow, new ScFormulaCell(pDocument, aDestPos, aArr)); + SetFormulaCell(nDestRow, new ScFormulaCell(&rDocument, aDestPos, aArr)); } // Don't forget to copy the cell text attributes. @@ -1443,8 +1443,8 @@ void ScColumn::CopyFromClip( // Compare the ScDocumentPool* to determine if we are copying within the // same document. If not, re-intern shared strings. - svl::SharedStringPool* pSharedStringPool = (rColumn.GetDoc()->GetPool() != pDocument->GetPool()) ? - &pDocument->GetSharedStringPool() : nullptr; + svl::SharedStringPool* pSharedStringPool = (rColumn.GetDoc().GetPool() != rDocument.GetPool()) ? + &rDocument.GetSharedStringPool() : nullptr; // nRow1 to nRow2 is for destination (this) column. Subtract nDy to get the source range. // Copy all cells in the source column (rColumn) from nRow1-nDy to nRow2-nDy to this column. @@ -1542,7 +1542,7 @@ class MixDataHandler { ScAddress aPos(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()); - ScFormulaCell* pFC = new ScFormulaCell(*mrDestColumn.GetDoc(), aPos); + ScFormulaCell* pFC = new ScFormulaCell(mrDestColumn.GetDoc(), aPos); pFC->SetErrCode(FormulaError::NoValue); miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, pFC); @@ -1585,7 +1585,7 @@ public: case sc::element_type_formula: { // Combination of value and at least one formula -> Create formula - ScTokenArray aArr(*mrDestColumn.GetDoc()); + ScTokenArray aArr(mrDestColumn.GetDoc()); // First row aArr.AddDouble(f); @@ -1609,7 +1609,7 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell( - mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); } break; case sc::element_type_string: @@ -1643,7 +1643,7 @@ public: case sc::element_type_numeric: { // Source is formula, and dest is value. - ScTokenArray aArr(*mrDestColumn.GetDoc()); + ScTokenArray aArr(mrDestColumn.GetDoc()); // First row lcl_AddCode(aArr, p); @@ -1666,13 +1666,13 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell( - mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); } break; case sc::element_type_formula: { // Both are formulas. - ScTokenArray aArr(*mrDestColumn.GetDoc()); + ScTokenArray aArr(mrDestColumn.GetDoc()); // First row lcl_AddCode(aArr, p); @@ -1696,7 +1696,7 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell( - mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); } break; case sc::element_type_string: @@ -1706,7 +1706,7 @@ public: // Destination cell is not a number. Just take the source cell. ScAddress aDestPos(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()); miNewCellsPos = maNewCells.set( - miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell(*p, *mrDestColumn.GetDoc(), aDestPos)); + miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell(*p, mrDestColumn.GetDoc(), aDestPos)); } break; default: @@ -1752,7 +1752,7 @@ public: break; case sc::element_type_formula: { - ScTokenArray aArr(*mrDestColumn.GetDoc()); + ScTokenArray aArr(mrDestColumn.GetDoc()); // First row ScFormulaCell* pSrc = sc::formula_block::at(*aPos.first->data, aPos.second); @@ -1775,7 +1775,7 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nDestRow-mnRowOffset, new ScFormulaCell( - mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()), aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()), aArr)); } break; default: @@ -1844,7 +1844,7 @@ public: // Merge with the next formula group (if any). size_t nNextRow = nDestRow + rNewCell.size; - if (mrDestColumn.GetDoc()->ValidRow(nNextRow)) + if (mrDestColumn.GetDoc().ValidRow(nNextRow)) { aPos = rDestCells.position(aPos.first, nNextRow); sc::SharedFormulaUtil::joinFormulaCellAbove(aPos); @@ -1896,7 +1896,7 @@ void ScColumn::MixData( std::unique_ptr<ScAttrIterator> ScColumn::CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const { - return std::make_unique<ScAttrIterator>( pAttrArray.get(), nStartRow, nEndRow, GetDoc()->GetDefPattern() ); + return std::make_unique<ScAttrIterator>( pAttrArray.get(), nStartRow, nEndRow, GetDoc().GetDefPattern() ); } namespace { @@ -1947,7 +1947,7 @@ namespace { void applyTextNumFormat( ScColumn& rCol, SCROW nRow, SvNumberFormatter* pFormatter ) { sal_uInt32 nFormat = pFormatter->GetStandardFormat(SvNumFormatType::TEXT); - ScPatternAttr aNewAttrs(rCol.GetDoc()->GetPool()); + ScPatternAttr aNewAttrs(rCol.GetDoc().GetPool()); SfxItemSet& rSet = aNewAttrs.GetItemSet(); rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat)); rCol.ApplyPattern(nRow, aNewAttrs); @@ -1974,10 +1974,10 @@ bool ScColumn::ParseString( sal_uInt32 nOldIndex = 0; SvNumFormatType eNumFormatType = SvNumFormatType::ALL; if (!aParam.mpNumFormatter) - aParam.mpNumFormatter = GetDoc()->GetFormatTable(); + aParam.mpNumFormatter = GetDoc().GetFormatTable(); sal_Unicode cFirstChar = 0; // Text - nIndex = nOldIndex = GetNumberFormat( GetDoc()->GetNonThreadedContext(), nRow ); + nIndex = nOldIndex = GetNumberFormat( GetDoc().GetNonThreadedContext(), nRow ); if ( rString.getLength() > 1 ) { eNumFormatType = aParam.mpNumFormatter->GetType(nIndex); @@ -1985,7 +1985,7 @@ bool ScColumn::ParseString( cFirstChar = rString[0]; } - svl::SharedStringPool& rPool = GetDoc()->GetSharedStringPool(); + svl::SharedStringPool& rPool = GetDoc().GetSharedStringPool(); if ( cFirstChar == '=' ) { @@ -2002,11 +2002,11 @@ bool ScColumn::ParseString( else // = Formula { ScFormulaCell* pFormulaCell = new ScFormulaCell( - GetDoc(), ScAddress(nCol, nRow, nTabP), rString, + &GetDoc(), ScAddress(nCol, nRow, nTabP), rString, formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_DEFAULT, eConv), ScMatrixMode::NONE); if (aParam.mbCheckLinkFormula) - GetDoc()->CheckLinkFormulaNeedingCheck( *pFormulaCell->GetCode()); + GetDoc().CheckLinkFormulaNeedingCheck( *pFormulaCell->GetCode()); rCell.set( pFormulaCell); } } @@ -2191,7 +2191,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv, const ScSetStringParam* pParam ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return false; ScCellValue aNewCell; @@ -2209,7 +2209,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const OUString& rString, void ScColumn::SetEditText( SCROW nRow, std::unique_ptr<EditTextObject> pEditText ) { - pEditText->NormalizeString(GetDoc()->GetSharedStringPool()); + pEditText->NormalizeString(GetDoc().GetSharedStringPool()); std::vector<SCROW> aNewSharedRows; sc::CellStoreType::iterator it = GetPositionToInsert(nRow, aNewSharedRows, false); maCells.set(it, nRow, pEditText.release()); @@ -2223,7 +2223,7 @@ void ScColumn::SetEditText( SCROW nRow, std::unique_ptr<EditTextObject> pEditTex void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, std::unique_ptr<EditTextObject> pEditText ) { - pEditText->NormalizeString(GetDoc()->GetSharedStringPool()); + pEditText->NormalizeString(GetDoc().GetSharedStringPool()); std::vector<SCROW> aNewSharedRows; rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow, aNewSharedRows, false); rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pEditText.release()); @@ -2239,7 +2239,7 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, std: void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText ) { - if (GetDoc()->GetEditPool() == rEditText.GetPool()) + if (GetDoc().GetEditPool() == rEditText.GetPool()) { SetEditText(rBlockPos, nRow, rEditText.Clone()); return; @@ -2248,14 +2248,14 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, cons // rats, yet another "spool" // Sadly there is no other way to change the Pool than to // "spool" the Object through a corresponding Engine - EditEngine& rEngine = GetDoc()->GetEditEngine(); + EditEngine& rEngine = GetDoc().GetEditEngine(); rEngine.SetText(rEditText); SetEditText(rBlockPos, nRow, rEngine.CreateTextObject()); } void ScColumn::SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool ) { - if (pEditPool && GetDoc()->GetEditPool() == pEditPool) + if (pEditPool && GetDoc().GetEditPool() == pEditPool) { SetEditText(nRow, rEditText.Clone()); return; @@ -2264,7 +2264,7 @@ void ScColumn::SetEditText( SCROW nRow, const EditTextObject& rEditText, const S // rats, yet another "spool" // Sadly there is no other way to change the Pool than to // "spool" the Object through a corresponding Engine - EditEngine& rEngine = GetDoc()->GetEditEngine(); + EditEngine& rEngine = GetDoc().GetEditEngine(); rEngine.SetText(rEditText); SetEditText(nRow, rEngine.CreateTextObject()); } @@ -2275,8 +2275,8 @@ void ScColumn::SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::Form std::vector<SCROW> aNewSharedRows; sc::CellStoreType::iterator it = GetPositionToInsert(nRow, aNewSharedRows, true); - ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), aPos, rArray, eGram); - sal_uInt32 nCellFormat = GetNumberFormat(GetDoc()->GetNonThreadedContext(), nRow); + ScFormulaCell* pCell = new ScFormulaCell(&GetDoc(), aPos, rArray, eGram); + sal_uInt32 nCellFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow); if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) pCell->SetNeedNumberFormat(true); it = maCells.set(it, nRow, pCell); @@ -2293,8 +2293,8 @@ void ScColumn::SetFormula( SCROW nRow, const OUString& rFormula, formula::Formul std::vector<SCROW> aNewSharedRows; sc::CellStoreType::iterator it = GetPositionToInsert(nRow, aNewSharedRows, true); - ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), aPos, rFormula, eGram); - sal_uInt32 nCellFormat = GetNumberFormat(GetDoc()->GetNonThreadedContext(), nRow); + ScFormulaCell* pCell = new ScFormulaCell(&GetDoc(), aPos, rFormula, eGram); + sal_uInt32 nCellFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow); if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) pCell->SetNeedNumberFormat(true); it = maCells.set(it, nRow, pCell); @@ -2311,7 +2311,7 @@ ScFormulaCell* ScColumn::SetFormulaCell( { std::vector<SCROW> aNewSharedRows; sc::CellStoreType::iterator it = GetPositionToInsert(nRow, aNewSharedRows, true); - sal_uInt32 nCellFormat = GetNumberFormat(GetDoc()->GetNonThreadedContext(), nRow); + sal_uInt32 nCellFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow); if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && bInheritNumFormatIfNeeded ) pCell->SetNeedNumberFormat(true); it = maCells.set(it, nRow, pCell); @@ -2331,7 +2331,7 @@ void ScColumn::SetFormulaCell( { std::vector<SCROW> aNewSharedRows; rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow, aNewSharedRows, true); - sal_uInt32 nCellFormat = GetNumberFormat(GetDoc()->GetNonThreadedContext(), nRow); + sal_uInt32 nCellFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow); if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && bInheritNumFormatIfNeeded ) pCell->SetNeedNumberFormat(true); rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pCell); @@ -2345,11 +2345,11 @@ void ScColumn::SetFormulaCell( bool ScColumn::SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return false; SCROW nEndRow = nRow + rCells.size() - 1; - if (!GetDoc()->ValidRow(nEndRow)) + if (!GetDoc().ValidRow(nEndRow)) return false; sc::CellStoreType::position_type aPos = maCells.position(nRow); @@ -2358,12 +2358,12 @@ bool ScColumn::SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells std::vector<SCROW> aNewSharedRows; DetachFormulaCells(aPos, rCells.size(), &aNewSharedRows); - if (!GetDoc()->IsClipOrUndo()) + if (!GetDoc().IsClipOrUndo()) { for (size_t i = 0, n = rCells.size(); i < n; ++i) { SCROW nThisRow = nRow + i; - sal_uInt32 nFmt = GetNumberFormat(GetDoc()->GetNonThreadedContext(), nThisRow); + sal_uInt32 nFmt = GetNumberFormat(GetDoc().GetNonThreadedContext(), nThisRow); if ((nFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0) rCells[i]->SetNeedNumberFormat(true); } @@ -2417,10 +2417,10 @@ class FilterEntriesHandler void processCell(SCROW nRow, ScRefCellValue& rCell) { - SvNumberFormatter* pFormatter = mrColumn.GetDoc()->GetFormatTable(); + SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable(); OUString aStr; - sal_uLong nFormat = mrColumn.GetNumberFormat(mrColumn.GetDoc()->GetNonThreadedContext(), nRow); - ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter, mrColumn.GetDoc()); + sal_uLong nFormat = mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow); + ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter, &mrColumn.GetDoc()); if (rCell.hasString()) { @@ -2670,8 +2670,8 @@ bool ScColumn::GetDataEntries( // going upward and downward directions in parallel. The start position // cell must be skipped. - StrCellIterator aItrUp(maCells, nStartRow, GetDoc()); - StrCellIterator aItrDown(maCells, nStartRow+1, GetDoc()); + StrCellIterator aItrUp(maCells, nStartRow, &GetDoc()); + StrCellIterator aItrDown(maCells, nStartRow+1, &GetDoc()); bool bMoveUp = aItrUp.valid(); if (!bMoveUp) @@ -2785,7 +2785,7 @@ void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow ) FormulaToValueHandler aFunc; sc::CellStoreType::const_iterator itPos = maCells.begin(); - ScAttrIterator aAttrIter( pAttrArray.get(), nStartRow, nEndRow, GetDoc()->GetDefPattern() ); + ScAttrIterator aAttrIter( pAttrArray.get(), nStartRow, nEndRow, GetDoc().GetDefPattern() ); SCROW nTop = -1; SCROW nBottom = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nTop, nBottom ); @@ -2808,10 +2808,10 @@ void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow ) void ScColumn::SetError( SCROW nRow, const FormulaError nError) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; - ScFormulaCell* pCell = new ScFormulaCell(*GetDoc(), ScAddress(nCol, nRow, nTab)); + ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), ScAddress(nCol, nRow, nTab)); pCell->SetErrCode(nError); std::vector<SCROW> aNewSharedRows; @@ -2826,10 +2826,10 @@ void ScColumn::SetError( SCROW nRow, const FormulaError nError) void ScColumn::SetRawString( SCROW nRow, const OUString& rStr ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; - svl::SharedString aSS = GetDoc()->GetSharedStringPool().intern(rStr); + svl::SharedString aSS = GetDoc().GetSharedStringPool().intern(rStr); if (!aSS.getData()) return; @@ -2838,7 +2838,7 @@ void ScColumn::SetRawString( SCROW nRow, const OUString& rStr ) void ScColumn::SetRawString( SCROW nRow, const svl::SharedString& rStr ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; std::vector<SCROW> aNewSharedRows; @@ -2856,7 +2856,7 @@ void ScColumn::SetRawString( SCROW nRow, const svl::SharedString& rStr ) void ScColumn::SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; std::vector<SCROW> aNewSharedRows; @@ -2875,7 +2875,7 @@ void ScColumn::SetRawString( void ScColumn::SetValue( SCROW nRow, double fVal ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; std::vector<SCROW> aNewSharedRows; @@ -2893,7 +2893,7 @@ void ScColumn::SetValue( SCROW nRow, double fVal ) void ScColumn::SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; std::vector<SCROW> aNewSharedRows; @@ -2916,10 +2916,10 @@ void ScColumn::GetString( const ScRefCellValue& aCell, SCROW nRow, OUString& rSt if (aCell.meType == CELLTYPE_FORMULA) aCell.mpFormula->MaybeInterpret(); - sal_uInt32 nFormat = GetNumberFormat( pContext ? *pContext : GetDoc()->GetNonThreadedContext(), nRow); + sal_uInt32 nFormat = GetNumberFormat( pContext ? *pContext : GetDoc().GetNonThreadedContext(), nRow); const Color* pColor = nullptr; ScCellFormat::GetString(aCell, nFormat, rString, &pColor, - pContext ? *(pContext->GetFormatTable()) : *(GetDoc()->GetFormatTable()), GetDoc()); + pContext ? *(pContext->GetFormatTable()) : *(GetDoc().GetFormatTable()), &GetDoc()); } double* ScColumn::GetValueCell( SCROW nRow ) @@ -2937,8 +2937,8 @@ double* ScColumn::GetValueCell( SCROW nRow ) void ScColumn::GetInputString( const ScRefCellValue& aCell, SCROW nRow, OUString& rString ) const { - sal_uLong nFormat = GetNumberFormat(GetDoc()->GetNonThreadedContext(), nRow); - ScCellFormat::GetInputString(aCell, nFormat, rString, *(GetDoc()->GetFormatTable()), GetDoc()); + sal_uLong nFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow); + ScCellFormat::GetInputString(aCell, nFormat, rString, *(GetDoc().GetFormatTable()), &GetDoc()); } double ScColumn::GetValue( SCROW nRow ) const @@ -3146,7 +3146,7 @@ class MaxStringLenHandler const Color* pColor; OUString aString; sal_uInt32 nFormat = mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue(); - ScCellFormat::GetString(rCell, nFormat, aString, &pColor, *mpFormatter, mrColumn.GetDoc()); + ScCellFormat::GetString(rCell, nFormat, aString, &pColor, *mpFormatter, &mrColumn.GetDoc()); sal_Int32 nLen = 0; if (mbOctetEncoding) { @@ -3173,7 +3173,7 @@ public: MaxStringLenHandler(const ScColumn& rColumn, rtl_TextEncoding eCharSet) : mnMaxLen(0), mrColumn(rColumn), - mpFormatter(rColumn.GetDoc()->GetFormatTable()), + mpFormatter(rColumn.GetDoc().GetFormatTable()), meCharSet(eCharSet), mbOctetEncoding(rtl_isOctetTextEncoding(eCharSet)) { @@ -3256,7 +3256,7 @@ class MaxNumStringLenHandler if (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) { aSep = mpFormatter->GetFormatDecimalSep(nFormat); - ScCellFormat::GetInputString(rCell, nFormat, aString, *mpFormatter, mrColumn.GetDoc()); + ScCellFormat::GetInputString(rCell, nFormat, aString, *mpFormatter, &mrColumn.GetDoc()); const SvNumberformat* pEntry = mpFormatter->GetEntry(nFormat); if (pEntry) { @@ -3340,7 +3340,7 @@ class MaxNumStringLenHandler public: MaxNumStringLenHandler(const ScColumn& rColumn, sal_uInt16 nMaxGeneralPrecision) : - mrColumn(rColumn), mpFormatter(rColumn.GetDoc()->GetFormatTable()), + mrColumn(rColumn), mpFormatter(rColumn.GetDoc().GetFormatTable()), mnMaxLen(0), mnPrecision(0), mnMaxGeneralPrecision(nMaxGeneralPrecision), mbHaveSigned(false) { @@ -3372,7 +3372,7 @@ public: sal_Int32 ScColumn::GetMaxNumberStringLen( sal_uInt16& nPrecision, SCROW nRowStart, SCROW nRowEnd ) const { - sal_uInt16 nMaxGeneralPrecision = GetDoc()->GetDocOptions().GetStdPrecision(); + sal_uInt16 nMaxGeneralPrecision = GetDoc().GetDocOptions().GetStdPrecision(); MaxNumStringLenHandler aFunc(*this, nMaxGeneralPrecision); sc::ParseFormulaNumeric(maCells.begin(), maCells, nRowStart, nRowEnd, aFunc); nPrecision = aFunc.getPrecision(); diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index e7f408175592..7d8ab951eb9e 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -95,9 +95,9 @@ sc::MultiDataCellState::StateType ScColumn::HasDataCellsInRange( void ScColumn::DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScColumn& rClipCol, sc::ColumnSpanSet& rBroadcastSpans ) { - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); sc::CopyFromClipContext::Range aRange = rCxt.getDestRange(); - if (!pDocument->ValidRow(aRange.mnRow1) || !pDocument->ValidRow(aRange.mnRow2)) + if (!rDocument.ValidRow(aRange.mnRow1) || !rDocument.ValidRow(aRange.mnRow2)) return; ScRange aClipRange = rCxt.getClipDoc()->GetClipParam().getWholeRange(); @@ -106,7 +106,7 @@ void ScColumn::DeleteBeforeCopyFromClip( SCROW nClipRowLen = nClipRow2 - nClipRow1 + 1; // Check for non-empty cell ranges in the clip column. - sc::SingleColumnSpanSet aSpanSet(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aSpanSet(GetDoc().GetSheetLimits()); aSpanSet.scan(rClipCol, nClipRow1, nClipRow2); sc::SingleColumnSpanSet::SpansType aSpans; aSpanSet.getSpans(aSpans); @@ -160,9 +160,9 @@ void ScColumn::DeleteBeforeCopyFromClip( if (nDelFlag & InsertDeleteFlags::CONTENTS) { - sc::SingleColumnSpanSet aDeletedRows(GetDoc()->GetSheetLimits()); + sc::SingleColumnSpanSet aDeletedRows(GetDoc().GetSheetLimits()); DeleteCells(aBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows); - rBroadcastSpans.set(*GetDoc(), nTab, nCol, aDeletedRows, true); + rBroadcastSpans.set(GetDoc(), nTab, nCol, aDeletedRows, true); } if (nDelFlag & InsertDeleteFlags::NOTE) @@ -178,7 +178,7 @@ void ScColumn::DeleteBeforeCopyFromClip( if (rCxt.isTableProtected()) { - ScPatternAttr aPattern(pDocument->GetPool()); + ScPatternAttr aPattern(rDocument.GetPool()); aPattern.GetItemSet().Put(ScProtectionAttr(false)); ApplyPatternArea(nRow1, nRow2, aPattern); } @@ -201,8 +201,8 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, if (!pBlockPos) return; - ScDocument* pDocument = GetDoc(); - bool bSameDocPool = (rCxt.getClipDoc()->GetPool() == pDocument->GetPool()); + ScDocument& rDocument = GetDoc(); + bool bSameDocPool = (rCxt.getClipDoc()->GetPool() == rDocument.GetPool()); ScCellValue& rSrcCell = rCxt.getSingleCell(nColOffset); sc::CellTextAttr& rSrcAttr = rCxt.getSingleCellAttr(nColOffset); @@ -214,7 +214,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, if (!rCxt.isSkipAttrForEmptyCells() || rSrcCell.meType != CELLTYPE_NONE) { const ScPatternAttr* pAttr = (bSameDocPool ? rCxt.getSingleCellPattern(nColOffset) : - rCxt.getSingleCellPattern(nColOffset)->PutInPool( pDocument, rCxt.getClipDoc())); + rCxt.getSingleCellPattern(nColOffset)->PutInPool( &rDocument, rCxt.getClipDoc())); auto pNewPattern = std::make_unique<ScPatternAttr>(*pAttr); sal_uInt16 pItems[2]; @@ -245,7 +245,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, { // Compare the ScDocumentPool* to determine if we are copying within the // same document. If not, re-intern shared strings. - svl::SharedStringPool* pSharedStringPool = (bSameDocPool ? nullptr : &pDocument->GetSharedStringPool()); + svl::SharedStringPool* pSharedStringPool = (bSameDocPool ? nullptr : &rDocument.GetSharedStringPool()); svl::SharedString aStr = (pSharedStringPool ? pSharedStringPool->intern( rSrcCell.mpString->getString()) : *rSrcCell.mpString); @@ -299,7 +299,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, for (size_t i = 0; i < nDestSize; ++i) { bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE; - aNotes.push_back(pNote->Clone(aSrcPos, *pDocument, aDestPos, bCloneCaption).release()); + aNotes.push_back(pNote->Clone(aSrcPos, rDocument, aDestPos, bCloneCaption).release()); aDestPos.IncRow(); } @@ -310,11 +310,11 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, void ScColumn::SetValues( const SCROW nRow, const std::vector<double>& rVals ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; SCROW nLastRow = nRow + rVals.size() - 1; - if (nLastRow > GetDoc()->MaxRow()) + if (nLastRow > GetDoc().MaxRow()) // Out of bound. Do nothing. return; @@ -340,11 +340,11 @@ void ScColumn::SetValues( const SCROW nRow, const std::vector<double>& rVals ) void ScColumn::TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; SCROW nLastRow = nRow + nLen - 1; - if (nLastRow > GetDoc()->MaxRow()) + if (nLastRow > GetDoc().MaxRow()) // Out of bound. Do nothing. return; @@ -365,11 +365,11 @@ void ScColumn::TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rD void ScColumn::CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; SCROW nLastRow = nRow + rSrc.size() - 1; - if (nLastRow > GetDoc()->MaxRow()) + if (nLastRow > GetDoc().MaxRow()) // Out of bound. Do nothing return; @@ -432,19 +432,19 @@ public: void ScColumn::ConvertFormulaToValue( sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo ) { - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2) || nRow1 > nRow2) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return; std::vector<SCROW> aBounds; aBounds.push_back(nRow1); - if (nRow2 < GetDoc()->MaxRow()-1) + if (nRow2 < GetDoc().MaxRow()-1) aBounds.push_back(nRow2+1); // Split formula cell groups at top and bottom boundaries (if applicable). - sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds); + sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds); // Parse all formulas within the range and store their results into temporary storage. - ConvertFormulaToValueHandler aFunc(GetDoc()->GetSheetLimits()); + ConvertFormulaToValueHandler aFunc(GetDoc().GetSheetLimits()); sc::ParseFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc); if (!aFunc.isModified()) // No formula cells encountered. @@ -498,11 +498,11 @@ void ScColumn::SwapNonEmpty( const ScRange& rRange = rValues.getRange(); std::vector<SCROW> aBounds; aBounds.push_back(rRange.aStart.Row()); - if (rRange.aEnd.Row() < GetDoc()->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). - sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds); + sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds); std::vector<sc::CellValueSpan> aSpans = rValues.getNonEmptySpans(nTab, nCol); // Detach formula cells within the spans (if any). @@ -554,7 +554,7 @@ void ScColumn::CloneFormulaCell( "ScColumn::CloneFormulaCell - cloning array/matrix with not exactly one column or row as single cell"); } - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); std::vector<ScFormulaCell*> aFormulas; for (const auto& rSpan : rRanges) { @@ -569,7 +569,7 @@ void ScColumn::CloneFormulaCell( if (nLen == 1) { // Single, ungrouped formula cell. - ScFormulaCell* pCell = new ScFormulaCell(rSrc, *pDocument, aPos); + ScFormulaCell* pCell = new ScFormulaCell(rSrc, rDocument, aPos); aFormulas.push_back(pCell); } else @@ -577,10 +577,10 @@ void ScColumn::CloneFormulaCell( // Create a group of formula cells. ScFormulaCellGroupRef xGroup(new ScFormulaCellGroup); xGroup->setCode(*rSrc.GetCode()); - xGroup->compileCode(*pDocument, aPos, pDocument->GetGrammar()); + xGroup->compileCode(rDocument, aPos, rDocument.GetGrammar()); for (size_t i = 0; i < nLen; ++i, aPos.IncRow()) { - ScFormulaCell* pCell = new ScFormulaCell(*pDocument, aPos, xGroup, pDocument->GetGrammar(), nMatrixFlag); + ScFormulaCell* pCell = new ScFormulaCell(rDocument, aPos, xGroup, rDocument.GetGrammar(), nMatrixFlag); if (nMatrixFlag == ScMatrixMode::Formula) pCell->SetMatColsRows( nMatrixCols, nMatrixRows); if (i == 0) @@ -615,7 +615,7 @@ void ScColumn::CloneFormulaCell( std::unique_ptr<ScPostIt> ScColumn::ReleaseNote( SCROW nRow ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return nullptr; ScPostIt* p = nullptr; @@ -673,7 +673,7 @@ void ScColumn::ForgetNoteCaptions( SCROW nRow1, SCROW nRow2, bool bPreserveData if (maCellNotes.empty()) return; - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2)) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2)) return; NoteCaptionCleaner aFunc(bPreserveData); @@ -748,7 +748,7 @@ public: void ScColumn::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const { - std::for_each(maCellNotes.begin(), maCellNotes.end(), NoteEntryCollector(rNotes, nTab, nCol, 0, GetDoc()->MaxRow())); + std::for_each(maCellNotes.begin(), maCellNotes.end(), NoteEntryCollector(rNotes, nTab, nCol, 0, GetDoc().MaxRow())); } void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow, @@ -946,7 +946,7 @@ void ScColumn::PreprocessRangeNameUpdate( aOps.insert(ocBad); aOps.insert(ocColRowName); aOps.insert(ocName); - RecompileByOpcodeHandler aFunc(GetDoc(), aOps, rEndListenCxt, rCompileCxt); + RecompileByOpcodeHandler aFunc(&GetDoc(), aOps, rEndListenCxt, rCompileCxt); std::for_each(aGroups.begin(), aGroups.end(), aFunc); } @@ -961,7 +961,7 @@ void ScColumn::PreprocessDBDataUpdate( aOps.insert(ocColRowName); aOps.insert(ocDBArea); aOps.insert(ocTableRef); - RecompileByOpcodeHandler aFunc(GetDoc(), aOps, rEndListenCxt, rCompileCxt); + RecompileByOpcodeHandler aFunc(&GetDoc(), aOps, rEndListenCxt, rCompileCxt); std::for_each(aGroups.begin(), aGroups.end(), aFunc); } @@ -971,7 +971,7 @@ void ScColumn::CompileHybridFormula( // Collect all formula groups. std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries(); - CompileHybridFormulaHandler aFunc(GetDoc(), rStartListenCxt, rCompileCxt); + CompileHybridFormulaHandler aFunc(&GetDoc(), rStartListenCxt, rCompileCxt); std::for_each(aGroups.begin(), aGroups.end(), aFunc); } @@ -1012,15 +1012,15 @@ private: maPos.SetRow(nRow); const ScCondFormatItem& rItem = pPat->GetItem(ATTR_CONDITIONAL); const ScCondFormatIndexes& rData = rItem.GetCondFormatData(); - pCondSet = mrCol.GetDoc()->GetCondResult(rCell, maPos, *mpCFList, rData); + pCondSet = mrCol.GetDoc().GetCondResult(rCell, maPos, *mpCFList, rData); } OUString aStr; const Color* pColor; sal_uInt32 nFormat = pPat->GetNumberFormat(mpFormatter, pCondSet); - ScCellFormat::GetString(rCell, nFormat, aStr, &pColor, *mpFormatter, mrCol.GetDoc()); + ScCellFormat::GetString(rCell, nFormat, aStr, &pColor, *mpFormatter, &mrCol.GetDoc()); - rAttr.mnScriptType = mrCol.GetDoc()->GetStringScriptType(aStr); + rAttr.mnScriptType = mrCol.GetDoc().GetStringScriptType(aStr); mbUpdated = true; } @@ -1029,8 +1029,8 @@ public: mrCol(rCol), mrTextAttrs(rCol.GetCellAttrStore()), miPosAttr(mrTextAttrs.begin()), - mpCFList(rCol.GetDoc()->GetCondFormList(rCol.GetTab())), - mpFormatter(rCol.GetDoc()->GetFormatTable()), + mpCFList(rCol.GetDoc().GetCondFormList(rCol.GetTab())), + mpFormatter(rCol.GetDoc().GetFormatTable()), maPos(rCol.GetCol(), 0, rCol.GetTab()), mbUpdated(false) {} @@ -1066,7 +1066,7 @@ public: void ScColumn::UpdateScriptTypes( SCROW nRow1, SCROW nRow2 ) { - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2) || nRow1 > nRow2) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return; ScriptTypeUpdater aFunc(*this); @@ -1083,7 +1083,7 @@ void ScColumn::Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern ) maBroadcasters.swap(nRow1, nRow2, rOther.maBroadcasters, nRow1); // Update draw object anchors - ScDrawLayer* pDrawLayer = GetDoc()->GetDrawLayer(); + ScDrawLayer* pDrawLayer = GetDoc().GetDrawLayer(); if (pDrawLayer) { std::map<SCROW, std::vector<SdrObject*>> aThisColRowDrawObjects @@ -1110,7 +1110,7 @@ void ScColumn::Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern ) if (pPat1 != pPat2) { if (pPat1->GetRefCount() == 1) - pPat1 = &rOther.GetDoc()->GetPool()->Put(*pPat1); + pPat1 = &rOther.GetDoc().GetPool()->Put(*pPat1); SetPattern(nRow, *pPat2); rOther.SetPattern(nRow, *pPat1); } @@ -1190,7 +1190,7 @@ public: void ScColumn::SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange ) { - if (rBoundRange.aStart.Row() >= GetDoc()->MaxRow()) + if (rBoundRange.aStart.Row() >= GetDoc().MaxRow()) // Nothing to split. return; @@ -1198,15 +1198,15 @@ void ScColumn::SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange ) // Cut at row boundaries first. aBounds.push_back(rBoundRange.aStart.Row()); - if (rBoundRange.aEnd.Row() < GetDoc()->MaxRow()) + if (rBoundRange.aEnd.Row() < GetDoc().MaxRow()) aBounds.push_back(rBoundRange.aEnd.Row()+1); - sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds); + sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds); RelativeRefBoundChecker aFunc(rBoundRange); sc::ProcessFormula( maCells.begin(), maCells, rBoundRange.aStart.Row(), rBoundRange.aEnd.Row(), aFunc); aFunc.swapBounds(aBounds); - sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds); + sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds); } namespace { @@ -1241,7 +1241,7 @@ public: void ScColumn::CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nRow1, SCROW nRow2 ) { - if (nRow2 < nRow1 || !GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2)) + if (nRow2 < nRow1 || !GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2)) return; ListenerCollector aFunc(rListeners); @@ -1250,7 +1250,7 @@ void ScColumn::CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nR void ScColumn::CollectFormulaCells( std::vector<ScFormulaCell*>& rCells, SCROW nRow1, SCROW nRow2 ) { - if (nRow2 < nRow1 || !GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2)) + if (nRow2 < nRow1 || !GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2)) return; FormulaCellCollector aFunc(rCells); @@ -1279,10 +1279,10 @@ bool ScColumn::HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const if (!mnBlkCountFormula) return false; - if (nRow2 < nRow1 || !GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2)) + if (nRow2 < nRow1 || !GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2)) return false; - if (nRow1 == 0 && nRow2 == GetDoc()->MaxRow()) + if (nRow1 == 0 && nRow2 == GetDoc().MaxRow()) return HasFormulaCell(); FindAnyFormula aFunc; @@ -1495,7 +1495,7 @@ void ScColumn::EndListeningFormulaCells( void ScColumn::EndListeningIntersectedGroup( sc::EndListeningContext& rCxt, SCROW nRow, std::vector<ScAddress>* pGroupPos ) { - if (!GetDoc()->ValidRow(nRow)) + if (!GetDoc().ValidRow(nRow)) return; sc::CellStoreType::position_type aPos = maCells.position(nRow); @@ -1633,7 +1633,7 @@ void ScColumn::SetNeedsListeningGroup( SCROW nRow ) std::unique_ptr<sc::ColumnIterator> ScColumn::GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const { - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2) || nRow1 > nRow2) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return std::unique_ptr<sc::ColumnIterator>(); return std::make_unique<sc::ColumnIterator>(maCells, nRow1, nRow2); @@ -1853,14 +1853,14 @@ static void lcl_EvalDirty(sc::CellStoreType& rCells, SCROW nRow1, SCROW nRow2, S // Returns true if at least one FC is dirty. bool ScColumn::EnsureFormulaCellResults( SCROW nRow1, SCROW nRow2, bool bSkipRunning ) { - if (!GetDoc()->ValidRow(nRow1) || !GetDoc()->ValidRow(nRow2) || nRow1 > nRow2) + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return false; if (!HasFormulaCell(nRow1, nRow2)) return false; bool bAnyDirty = false, bTmp = false; - lcl_EvalDirty(maCells, nRow1, nRow2, *GetDoc(), nullptr, false, bSkipRunning, bAnyDirty, bTmp); + lcl_EvalDirty(maCells, nRow1, nRow2, GetDoc(), nullptr, false, bSkipRunning, bAnyDirty, bTmp); return bAnyDirty; } @@ -1870,7 +1870,7 @@ bool ScColumn::HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2, const ScF return false; bool bAllowThreading = true, bTmp = false; - lcl_EvalDirty(maCells, nRow1, nRow2, *GetDoc(), mxGroup, true, false, bTmp, bAllowThreading); + lcl_EvalDirty(maCells, nRow1, nRow2, GetDoc(), mxGroup, true, false, bTmp, bAllowThreading); return bAllowThreading; } @@ -1988,7 +1988,7 @@ void ScColumn::RestoreFromCache(SvStream& rStrm) sal_uInt64 nLastRow = 0; rStrm.ReadUInt64(nLastRow); sal_uInt64 nReadRow = 0; - ScDocument* pDocument = GetDoc(); + ScDocument& rDocument = GetDoc(); while (nReadRow < nLastRow) { sal_uInt64 nStartRow = 0; @@ -2017,7 +2017,7 @@ void ScColumn::RestoreFromCache(SvStream& rStrm) case 2: { std::vector<svl::SharedString> aStrings(nDataSize); - svl::SharedStringPool& rPool = pDocument->GetSharedStringPool(); + svl::SharedStringPool& rPool = rDocument.GetSharedStringPool(); for (auto& rString : aStrings) { sal_Int32 nStrLength = 0; @@ -2050,7 +2050,7 @@ void ScColumn::RestoreFromCache(SvStream& rStrm) OUString aStr = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8); for (sal_uInt64 i = 0; i < nFormulaGroupSize; ++i) { - aFormulaCells[nRow + i] = new ScFormulaCell(pDocument, aAddr, aStr, eGrammar); + aFormulaCells[nRow + i] = new ScFormulaCell(&rDocument, aAddr, aStr, eGrammar); aAddr.IncRow(); } diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 368ddedc79b4..d7ff6613eecc 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -951,9 +951,9 @@ bool ScCellIterator::getCurrent() SCROW nLastRow; // Skip all filtered or hidden rows, depending on mSubTotalFlags if ( ( ( mnSubTotalFlags & SubtotalFlags::IgnoreFiltered ) && - pCol->GetDoc()->RowFiltered(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) || + pCol->GetDoc().RowFiltered(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) || ( ( mnSubTotalFlags & SubtotalFlags::IgnoreHidden ) && - pCol->GetDoc()->RowHidden(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) ) + pCol->GetDoc().RowHidden(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) ) { setPos(nLastRow+1); continue; diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index af5f34f5d3b0..c0c07ef172d0 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -271,7 +271,7 @@ ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName, bActiveScenario(false), mbPageBreaksValid(false), mbForceBreaks(false), - aDefaultColAttrArray(static_cast<SCCOL>(-1), nNewTab, &rDoc, nullptr) + aDefaultColAttrArray(static_cast<SCCOL>(-1), nNewTab, rDoc, nullptr) { if (bColInfo) { diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 29d771eb8e75..9403d1b913a7 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -137,7 +137,7 @@ void setSuffixCell( ScColumn& rColumn, SCROW nRow, sal_Int32 nValue, sal_uInt16 nDigits, const OUString& rSuffix, CellType eCellType, bool bIsOrdinalSuffix ) { - ScDocument& rDoc = *rColumn.GetDoc(); + ScDocument& rDoc = rColumn.GetDoc(); OUString aValue = lcl_ValueString(nValue, nDigits); if (!bIsOrdinalSuffix) { diff --git a/sc/source/core/tool/scopetools.cxx b/sc/source/core/tool/scopetools.cxx index cbe0486ad0c8..0da9d1061ce8 100644 --- a/sc/source/core/tool/scopetools.cxx +++ b/sc/source/core/tool/scopetools.cxx @@ -75,13 +75,13 @@ void DelayFormulaGroupingSwitch::reset() } DelayStartListeningFormulaCells::DelayStartListeningFormulaCells(ScColumn& column, bool delay) - : mColumn(column), mbOldValue(column.GetDoc()->IsEnabledDelayStartListeningFormulaCells(&column)) + : mColumn(column), mbOldValue(column.GetDoc().IsEnabledDelayStartListeningFormulaCells(&column)) { - column.GetDoc()->EnableDelayStartListeningFormulaCells(&column, delay); + column.GetDoc().EnableDelayStartListeningFormulaCells(&column, delay); } DelayStartListeningFormulaCells::DelayStartListeningFormulaCells(ScColumn& column) - : mColumn(column), mbOldValue(column.GetDoc()->IsEnabledDelayStartListeningFormulaCells(&column)) + : mColumn(column), mbOldValue(column.GetDoc().IsEnabledDelayStartListeningFormulaCells(&column)) { } @@ -90,20 +90,20 @@ DelayStartListeningFormulaCells::~DelayStartListeningFormulaCells() #if defined(__COVERITY__) try { - mColumn.GetDoc()->EnableDelayStartListeningFormulaCells(&mColumn, mbOldValue); + mColumn.GetDoc().EnableDelayStartListeningFormulaCells(&mColumn, mbOldValue); } catch (...) { std::abort(); } #else - mColumn.GetDoc()->EnableDelayStartListeningFormulaCells(&mColumn, mbOldValue); + mColumn.GetDoc().EnableDelayStartListeningFormulaCells(&mColumn, mbOldValue); #endif } void DelayStartListeningFormulaCells::set() { - mColumn.GetDoc()->EnableDelayStartListeningFormulaCells(&mColumn, true); + mColumn.GetDoc().EnableDelayStartListeningFormulaCells(&mColumn, true); } } diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 6ff7da739871..3537b141a3d7 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -2840,7 +2840,7 @@ public: case CELLTYPE_STRING: case CELLTYPE_EDIT: { - OUString aStr = aCell.getString(mpCurCol->GetDoc()); + OUString aStr = aCell.getString(&mpCurCol->GetDoc()); svl::SharedString aSS = mrStrPool.intern(aStr); pTok.reset(new formula::FormulaStringToken(aSS)); } @@ -2877,7 +2877,7 @@ public: if (pTok) { // Cache this cell. - mpRefTab->setCell(mpCurCol->GetCol(), nRow, pTok, mpCurCol->GetNumberFormat(mpCurCol->GetDoc()->GetNonThreadedContext(), nRow)); + mpRefTab->setCell(mpCurCol->GetCol(), nRow, pTok, mpCurCol->GetNumberFormat(mpCurCol->GetDoc().GetNonThreadedContext(), nRow)); mpRefTab->setCachedCell(mpCurCol->GetCol(), nRow); } } |