summaryrefslogtreecommitdiff
path: root/sc/source/core/data/documen3.cxx
diff options
context:
space:
mode:
authorDennis Francis <dennisfrancis.in@gmail.com>2015-11-24 01:34:47 +0530
committerEike Rathke <erack@redhat.com>2016-01-21 20:48:07 +0000
commit3536fe8f4cdbacf5702e743407f34d918b6f4d38 (patch)
tree24ae7b9048003baadd5408db08662cbcd8782895 /sc/source/core/data/documen3.cxx
parenteb3ee586e420ee4e38f9ef8c579e1a37d2dc0c10 (diff)
tdf#34873 : Show autofilter row count in status bar
Change-Id: I91aa637d654c1f4d828832f2e43ad21f03036ad0 Reviewed-on: https://gerrit.libreoffice.org/20134 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/core/data/documen3.cxx')
-rw-r--r--sc/source/core/data/documen3.cxx40
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
*/