diff options
Diffstat (limited to 'sc/source/core/data/documen3.cxx')
-rw-r--r-- | sc/source/core/data/documen3.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 48f01cf2c401..5f632d922049 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1464,6 +1464,46 @@ bool ScDocument::HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, return ValidTab(nTab) && maTabs[nTab] && maTabs[nTab]->HasRowHeader( nStartCol, nStartRow, nEndCol, nEndRow ); } +void ScDocument::GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal ) +{ + nSelected = 0; + nTotal = 0; + if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] ) + { + const ScDBData* pDBData = GetDBAtCursor( nCol, nRow, nTab, ScDBDataPortion::AREA ); + if( pDBData && pDBData->HasAutoFilter() ) + { + SCTAB nAreaTab; + SCCOL nStartCol; + SCROW nStartRow; + SCCOL nEndCol; + SCROW nEndRow; + pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow ); + + if( pDBData->HasHeader() ) + ++nStartRow; + + nTotal = nEndRow - nStartRow + 1; + + ScTable::FilteredRowCountData* pFilteredRowCount = &(maTabs[nTab]->maFilteredRowCount); + // Exact range match, cache hit, early exit + if( ( pFilteredRowCount->nStartRow == nStartRow ) && ( pFilteredRowCount->nEndRow == nEndRow ) && + ( pFilteredRowCount->nCount != SCSIZE_MAX ) ) + { + nSelected = nTotal - pFilteredRowCount->nCount; + return; + } + + // Compute the count + nSelected = CountNonFilteredRows( nStartRow, nEndRow, nTab ); + // and store it in the cache + pFilteredRowCount->nStartRow = nStartRow; + pFilteredRowCount->nEndRow = nEndRow; + pFilteredRowCount->nCount = nTotal - nSelected; + } + } +} + /** * Entries for AutoFilter listbox */ |