diff options
author | Aron Budea <aron.budea@collabora.com> | 2023-12-12 02:15:43 +1030 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-12 05:40:12 +0100 |
commit | 93801094fa7a3d276dc56138fafbf21029aae4d5 (patch) | |
tree | 64f87e5f5f57ecb8238e787e5c5f2efae3351bd6 /sc | |
parent | 76400f66096a5cdc64cbd72ed9a94961b3200216 (diff) |
sc: Unify GetColumnData
This added ColumnData:
a15c02effa654da06e9695b5e4c0c595f851a878
This added GetColumnData:
1c53f5b6647dcffa57012990d342b21eaff19888
Both functions are the same, one is const, other is non-const.
Change-Id: I8ed214290c7ee8d9e22bd466f9ada95b40300e34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160601
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/table.hxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/dociter.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 16 | ||||
-rw-r--r-- | sc/source/core/data/table4.cxx | 2 |
5 files changed, 22 insertions, 28 deletions
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 3bf61e701c16..dbfffacc67bf 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -309,12 +309,8 @@ public: // out-of-line the cold part of the function void CreateColumnIfNotExistsImpl( const SCCOL nScCol ); - ScColumnData& GetColumnData( SCCOL nCol ) - { - if( nCol >= aCol.size()) - return aDefaultColData; - return aCol[nCol]; - } + const ScColumnData& GetColumnData( SCCOL nCol ) const { return nCol < aCol.size() ? aCol[ nCol ] : aDefaultColData; } + ScColumnData& GetColumnData( SCCOL nCol ) { return nCol < aCol.size() ? aCol[ nCol ] : aDefaultColData; } sal_uInt64 GetCellCount() const; sal_uInt64 GetWeightedCount() const; @@ -1187,8 +1183,6 @@ public: std::set<SCCOL> QueryColumnsWithFormulaCells() const; - const ScColumnData& ColumnData( SCCOL nCol ) const { return nCol < aCol.size() ? aCol[ nCol ] : aDefaultColData; } - void CheckIntegrity() const; void CollectBroadcasterState(sc::BroadcasterState& rState) const; diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 35c0d2caa8fd..6fd13c2e3885 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1383,7 +1383,7 @@ void ScHorizontalAttrIterator::InitForNextRow(bool bInitialization) SCCOL nPos = i - nStartCol; if ( bInitialization || pNextEnd[nPos] < nRow ) { - const ScAttrArray& pArray = rDoc.maTabs[nTab]->ColumnData(i).AttrArray(); + const ScAttrArray& pArray = rDoc.maTabs[nTab]->GetColumnData(i).AttrArray(); SCSIZE nIndex; if (bInitialization) @@ -1579,7 +1579,7 @@ ScDocAttrIterator::ScDocAttrIterator(ScDocument& rDocument, SCTAB nTable, nCol( nCol1 ) { if ( ValidTab(nTab) && nTab < rDoc.GetTableCount() && rDoc.maTabs[nTab] ) - pColIter = rDoc.maTabs[nTab]->ColumnData(nCol).CreateAttrIterator( nStartRow, nEndRow ); + pColIter = rDoc.maTabs[nTab]->GetColumnData(nCol).CreateAttrIterator( nStartRow, nEndRow ); } ScDocAttrIterator::~ScDocAttrIterator() @@ -1599,7 +1599,7 @@ const ScPatternAttr* ScDocAttrIterator::GetNext( SCCOL& rCol, SCROW& rRow1, SCRO ++nCol; if ( nCol <= nEndCol ) - pColIter = rDoc.maTabs[nTab]->ColumnData(nCol).CreateAttrIterator( nStartRow, nEndRow ); + pColIter = rDoc.maTabs[nTab]->GetColumnData(nCol).CreateAttrIterator( nStartRow, nEndRow ); else pColIter.reset(); } @@ -1711,10 +1711,10 @@ ScAttrRectIterator::ScAttrRectIterator(ScDocument& rDocument, SCTAB nTable, { if ( ValidTab(nTab) && nTab < rDoc.GetTableCount() && rDoc.maTabs[nTab] ) { - pColIter = rDoc.maTabs[nTab]->ColumnData(nIterStartCol).CreateAttrIterator( nStartRow, nEndRow ); + pColIter = rDoc.maTabs[nTab]->GetColumnData(nIterStartCol).CreateAttrIterator( nStartRow, nEndRow ); while ( nIterEndCol < nEndCol && - rDoc.maTabs[nTab]->ColumnData(nIterEndCol).IsAllAttrEqual( - rDoc.maTabs[nTab]->ColumnData(nIterEndCol+1), nStartRow, nEndRow ) ) + rDoc.maTabs[nTab]->GetColumnData(nIterEndCol).IsAllAttrEqual( + rDoc.maTabs[nTab]->GetColumnData(nIterEndCol+1), nStartRow, nEndRow ) ) ++nIterEndCol; } } @@ -1728,7 +1728,7 @@ void ScAttrRectIterator::DataChanged() if (pColIter) { SCROW nNextRow = pColIter->GetNextRow(); - pColIter = rDoc.maTabs[nTab]->ColumnData(nIterStartCol).CreateAttrIterator( nNextRow, nEndRow ); + pColIter = rDoc.maTabs[nTab]->GetColumnData(nIterStartCol).CreateAttrIterator( nNextRow, nEndRow ); } } @@ -1749,10 +1749,10 @@ const ScPatternAttr* ScAttrRectIterator::GetNext( SCCOL& rCol1, SCCOL& rCol2, if ( nIterStartCol <= nEndCol ) { nIterEndCol = nIterStartCol; - pColIter = rDoc.maTabs[nTab]->ColumnData(nIterStartCol).CreateAttrIterator( nStartRow, nEndRow ); + pColIter = rDoc.maTabs[nTab]->GetColumnData(nIterStartCol).CreateAttrIterator( nStartRow, nEndRow ); while ( nIterEndCol < nEndCol && - rDoc.maTabs[nTab]->ColumnData(nIterEndCol).IsAllAttrEqual( - rDoc.maTabs[nTab]->ColumnData(nIterEndCol+1), nStartRow, nEndRow ) ) + rDoc.maTabs[nTab]->GetColumnData(nIterEndCol).IsAllAttrEqual( + rDoc.maTabs[nTab]->GetColumnData(nIterEndCol+1), nStartRow, nEndRow ) ) ++nIterEndCol; } else diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 060bd85eebbc..6a51d364d9ce 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -5509,7 +5509,7 @@ void ScDocument::ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow, //TODO: pass on ? - const ScAttrArray& pAttrArray = pTable->ColumnData(nOldCol).AttrArray(); + const ScAttrArray& pAttrArray = pTable->GetColumnData(nOldCol).AttrArray(); SCSIZE nIndex; if ( pAttrArray.Count() ) pAttrArray.Search( nOldRow, nIndex ); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 89ded6428766..3caad0124f5e 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2256,20 +2256,20 @@ const SfxPoolItem* ScTable::GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) { if (!ValidColRow(nCol, nRow)) return nullptr; - return &ColumnData(nCol).GetAttr( nRow, nWhich ); + return &GetColumnData(nCol).GetAttr( nRow, nWhich ); } const SfxPoolItem* ScTable::GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const { if (!ValidColRow(nCol, nRow)) return nullptr; - return &ColumnData(nCol).GetAttr( nRow, nWhich, nStartRow, nEndRow ); + return &GetColumnData(nCol).GetAttr( nRow, nWhich, nStartRow, nEndRow ); } sal_uInt32 ScTable::GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const { if (ValidColRow(rPos.Col(), rPos.Row())) - return ColumnData(rPos.Col()).GetNumberFormat(rContext, rPos.Row()); + return GetColumnData(rPos.Col()).GetNumberFormat(rContext, rPos.Row()); return 0; } @@ -2283,7 +2283,7 @@ sal_uInt32 ScTable::GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow if (!ValidCol(nCol) || !ValidRow(nStartRow) || !ValidRow(nEndRow)) return 0; - return ColumnData(nCol).GetNumberFormat(nStartRow, nEndRow); + return GetColumnData(nCol).GetNumberFormat(nStartRow, nEndRow); } void ScTable::SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat ) @@ -2298,13 +2298,13 @@ const ScPatternAttr* ScTable::GetPattern( SCCOL nCol, SCROW nRow ) const { if (!ValidColRow(nCol,nRow)) return nullptr; - return ColumnData(nCol).GetPattern( nRow ); + return GetColumnData(nCol).GetPattern( nRow ); } const ScPatternAttr* ScTable::GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const { if ( ValidColRow( nCol, nStartRow ) && ValidRow( nEndRow ) && (nStartRow <= nEndRow)) - return ColumnData(nCol).GetMostUsedPattern( nStartRow, nEndRow ); + return GetColumnData(nCol).GetMostUsedPattern( nStartRow, nEndRow ); return nullptr; } @@ -2320,7 +2320,7 @@ bool ScTable::HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, Has bool ScTable::HasAttrib( SCCOL nCol, SCROW nRow, HasAttrFlags nMask, SCROW* nStartRow, SCROW* nEndRow ) const { - return ColumnData(nCol).HasAttrib( nRow, nMask, nStartRow, nEndRow ); + return GetColumnData(nCol).HasAttrib( nRow, nMask, nStartRow, nEndRow ); } bool ScTable::HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const @@ -3076,7 +3076,7 @@ const ScStyleSheet* ScTable::GetStyle( SCCOL nCol, SCROW nRow ) const { if ( !ValidColRow( nCol, nRow ) ) return nullptr; - return ColumnData(nCol).GetStyle( nRow ); + return GetColumnData(nCol).GetStyle( nRow ); } const ScStyleSheet* ScTable::GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 62b9dbb9e006..2d53f46337ae 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -1311,7 +1311,7 @@ void ScTable::GetBackColorArea(SCCOL& rStartCol, SCROW& /*rStartRow*/, { for (SCCOL nCol = rStartCol; nCol <= rEndCol; ++nCol) { - const ScPatternAttr* pPattern = ColumnData(nCol).GetPattern(rEndRow + 1); + const ScPatternAttr* pPattern = GetColumnData(nCol).GetPattern(rEndRow + 1); const SvxBrushItem* pBackground = &pPattern->GetItem(ATTR_BACKGROUND); if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty() || pBackground != pDefBackground) |