sc/inc/attarray.hxx | 6 sc/inc/column.hxx | 2 sc/source/core/data/attarray.cxx | 250 +++++++++++++++--------------- sc/source/core/data/cellvalue.cxx | 4 sc/source/core/data/column.cxx | 198 +++++++++++------------ sc/source/core/data/column2.cxx | 160 +++++++++---------- sc/source/core/data/column3.cxx | 258 +++++++++++++++---------------- sc/source/core/data/column4.cxx | 114 ++++++------- sc/source/core/data/dociter.cxx | 4 sc/source/core/data/table1.cxx | 2 sc/source/core/data/table4.cxx | 2 sc/source/core/tool/scopetools.cxx | 12 - sc/source/ui/docshell/externalrefmgr.cxx | 4 13 files changed, 508 insertions(+), 508 deletions(-)
New commits: commit 91313ea13f9dc846a141e5106fb9ba2f70a970f5 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Sep 15 12:22:21 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Sep 16 18:04:44 2020 +0200 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 <caol...@redhat.com> 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()); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits