summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-04-12 14:58:33 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-04-12 23:10:16 +0200
commit4d45d9886fa5830f4c8c92268ffca4297650ed70 (patch)
treea16950f628972a6d4d2e1b328b046bcdb7deddc6 /sc
parente3830b06a9886620ed432a011d2de2abbb7a3a12 (diff)
don't artificially clamp attribute iterators range
Even ScDocument::GetDefPattern() can be modified by the user (it's the default style that can be edited), so it's conceptually incorrect to ignore it while iterating, and clamping to allocated columns is also no longer needed. If this makes some code slow, then that needs explicit handling in that code or some other way of speeding things up. Change-Id: I4a7c7fef0a8625b559bbce4580df19a5e9ed92a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132911 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/attarray.hxx1
-rw-r--r--sc/inc/column.hxx6
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/inc/table.hxx4
-rw-r--r--sc/source/core/data/attarray.cxx20
-rw-r--r--sc/source/core/data/dociter.cxx26
-rw-r--r--sc/source/core/data/table1.cxx15
7 files changed, 6 insertions, 71 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 8153b441ffe6..f4028b844c62 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -225,7 +225,6 @@ public:
bool Reserve( SCSIZE nReserve );
SCSIZE Count() const { return mvData.size(); }
SCSIZE Count( SCROW nRow1, SCROW nRow2 ) const;
- bool HasNonDefPattern( SCROW nStartRow, SCROW nEndRow ) const;
private:
const ScPatternAttr* SetPatternAreaImpl( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 0a2b16c809d9..676e3fc0e634 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -166,7 +166,6 @@ public:
std::unique_ptr<ScAttrIterator> CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
bool IsAllAttrEqual( const ScColumnData& rCol, SCROW nStartRow, SCROW nEndRow ) const;
- bool HasNonDefPattern( SCROW nStartRow, SCROW nEndRow ) const;
void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark, SCCOL nCol );
void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark, SCCOL nCol );
@@ -864,11 +863,6 @@ inline bool ScColumnData::IsAllAttrEqual( const ScColumnData& rCol, SCROW nStart
return pAttrArray->IsAllEqual( *rCol.pAttrArray, nStartRow, nEndRow );
}
-inline bool ScColumnData::HasNonDefPattern( SCROW nStartRow, SCROW nEndRow ) const
-{
- return pAttrArray->HasNonDefPattern( nStartRow, nEndRow );
-}
-
inline bool ScColumn::IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const
{
return pAttrArray->IsVisibleEqual( *rCol.pAttrArray, nStartRow, nEndRow );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 2093847f26eb..dff68fc6e344 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -823,11 +823,6 @@ public:
SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const;
SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const;
- // Limits nCol to the last column that can possibly have a non-default pattern. The purpose
- // is to avoid checking unallocated columns if they don't have attributes set, so this is
- // never less than ClampToAllocatedColumns().
- SCCOL ClampToMaxNonDefPatternColumn(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2) const;
- SCCOL GetMaxNonDefPatternColumnsCount(SCTAB nTab, SCROW nRow1, SCROW nRow2) const;
SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index de8f9c231077..36ff984ed8fa 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -1117,10 +1117,6 @@ public:
ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const;
SCCOL ClampToAllocatedColumns(SCCOL nCol) const { return std::min(nCol, static_cast<SCCOL>(aCol.size() - 1)); }
SCCOL GetAllocatedColumnsCount() const { return aCol.size(); }
- SCCOL ClampToMaxNonDefPatternColumn(SCCOL nCol, SCROW nRow1, SCROW nRow2) const;
- SCCOL ClampToMaxNonDefPatternColumn(SCCOL nCol) const
- { return ClampToMaxNonDefPatternColumn(nCol, 0, rDocument.MaxRow()); }
- SCCOL GetMaxNonDefPatternColumnsCount(SCROW nRow1, SCROW nRow2) const;
/**
* Serializes the sheet's geometry data.
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 042213bda05c..2f7e686ac383 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -2690,24 +2690,4 @@ SCSIZE ScAttrArray::Count( SCROW nStartRow, SCROW nEndRow ) const
return nIndex2 - nIndex1 + 1;
}
-bool ScAttrArray::HasNonDefPattern( SCROW nStartRow, SCROW nEndRow ) const
-{
- if ( mvData.empty() )
- return false;
-
- SCSIZE nIndex1, nIndex2;
-
- if( !Search( nStartRow, nIndex1 ) )
- return false;
-
- if( !Search( nEndRow, nIndex2 ) )
- nIndex2 = mvData.size() - 1;
-
- const ScPatternAttr* defPattern = rDocument.GetDefPattern();
- for( SCSIZE index = nIndex1; index <= nIndex2; ++index )
- if( mvData[index].pPattern != defPattern )
- return true;
- return false;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 35148072f387..6bb47df2a9d8 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -2394,8 +2394,6 @@ ScHorizontalAttrIterator::ScHorizontalAttrIterator( ScDocument& rDocument, SCTAB
assert(nTab < rDoc.GetTableCount() && "index out of bounds, FIX IT");
assert(rDoc.maTabs[nTab]);
- nEndCol = rDoc.maTabs[nTab]->ClampToMaxNonDefPatternColumn(nEndCol);
-
nRow = nStartRow;
nCol = nStartCol;
bRowEmpty = false;
@@ -2644,14 +2642,7 @@ ScDocAttrIterator::ScDocAttrIterator(ScDocument& rDocument, SCTAB nTable,
nCol( nCol1 )
{
if ( ValidTab(nTab) && nTab < rDoc.GetTableCount() && rDoc.maTabs[nTab] )
- {
- SCCOL attrColCount = rDoc.maTabs[nTab]->GetMaxNonDefPatternColumnsCount(nStartRow, nEndRow);
- if( nCol < attrColCount )
- {
- nEndCol = std::min<SCCOL>(nEndCol,attrColCount - 1);
- pColIter = rDoc.maTabs[nTab]->ColumnData(nCol).CreateAttrIterator( nStartRow, nEndRow );
- }
- }
+ pColIter = rDoc.maTabs[nTab]->ColumnData(nCol).CreateAttrIterator( nStartRow, nEndRow );
}
ScDocAttrIterator::~ScDocAttrIterator()
@@ -2780,16 +2771,11 @@ ScAttrRectIterator::ScAttrRectIterator(ScDocument& rDocument, SCTAB nTable,
{
if ( ValidTab(nTab) && nTab < rDoc.GetTableCount() && rDoc.maTabs[nTab] )
{
- SCCOL attrColCount = rDoc.maTabs[nTab]->GetMaxNonDefPatternColumnsCount(nStartRow, nEndRow);
- if( nCol1 < attrColCount )
- {
- nEndCol = std::min<SCCOL>(nEndCol,attrColCount - 1);
- pColIter = rDoc.maTabs[nTab]->ColumnData(nIterStartCol).CreateAttrIterator( nStartRow, nEndRow );
- while ( nIterEndCol < nEndCol &&
- rDoc.maTabs[nTab]->ColumnData(nIterEndCol).IsAllAttrEqual(
- rDoc.maTabs[nTab]->ColumnData(nIterEndCol+1), nStartRow, nEndRow ) )
- ++nIterEndCol;
- }
+ pColIter = rDoc.maTabs[nTab]->ColumnData(nIterStartCol).CreateAttrIterator( nStartRow, nEndRow );
+ while ( nIterEndCol < nEndCol &&
+ rDoc.maTabs[nTab]->ColumnData(nIterEndCol).IsAllAttrEqual(
+ rDoc.maTabs[nTab]->ColumnData(nIterEndCol+1), nStartRow, nEndRow ) )
+ ++nIterEndCol;
}
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 5c35eba2fb9c..45bd5c777cc0 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2699,21 +2699,6 @@ ScColumnsRange ScTable::GetColumnsRange(SCCOL nColBegin, SCCOL nColEnd) const
return ScColumnsRange(ScColumnsRange::Iterator(beginIter), ScColumnsRange::Iterator(endIter));
}
-SCCOL ScTable::ClampToMaxNonDefPatternColumn(SCCOL nCol, SCROW nRow1, SCROW nRow2) const
-{
- // The purpose so to avoid unallocated columns if possible, so don't check allocated ones.
- if( nCol < GetAllocatedColumnsCount())
- return nCol;
- return std::min<SCCOL>(nCol, GetMaxNonDefPatternColumnsCount( nRow1, nRow2 ) - 1 );
-}
-
-SCCOL ScTable::GetMaxNonDefPatternColumnsCount(SCROW nRow1, SCROW nRow2) const
-{
- if( aDefaultColData.HasNonDefPattern(nRow1, nRow2))
- return GetDoc().GetMaxColCount();
- return GetAllocatedColumnsCount();
-}
-
// out-of-line the cold part of the CreateColumnIfNotExists function
void ScTable::CreateColumnIfNotExistsImpl( const SCCOL nScCol ) const
{