summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-05-02 23:15:51 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-05-03 01:28:30 -0400
commit0060509ae519776c5f112aedf3531505e091ab12 (patch)
tree7621d4ad93f5268c411d8d52001d674403c96ce9
parentaada201fe2d421c567a21b9903254d25c9b1c9be (diff)
fdo#36771: Treat filter by "filter" and filter by "page" separate.
The new datapilot cache implementation mixed these two up. I guess it's best to have two separate flags for these.
-rw-r--r--sc/inc/dpcachetable.hxx12
-rw-r--r--sc/source/core/data/dpcachetable.cxx46
2 files changed, 40 insertions, 18 deletions
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 4c83ec991..dc6742750 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -58,6 +58,13 @@ struct ScQueryParam;
class SC_DLLPUBLIC ScDPCacheTable
{
+ struct RowFlag
+ {
+ bool mbShowByFilter:1;
+ bool mbShowByPage:1;
+ bool isActive() const;
+ RowFlag();
+ };
public:
/** individual filter item used in SingleFilter and GroupFilter. */
struct FilterItem
@@ -188,9 +195,8 @@ private:
/** unique field entires for each field (column). */
::std::vector< ::std::vector<SCROW> > maFieldEntries;
- /** used to track visibility of rows. The first row below the header row
- has the index of 0. */
- ::std::vector<bool> maRowsVisible;
+ /** Row flags. The first row below the header row has the index of 0. */
+ ::std::vector<RowFlag> maRowFlags;
const ScDPCache* mpCache;
};
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index f764272b8..40d34ac7a 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -73,6 +73,17 @@ static sal_Bool lcl_HasQueryEntry( const ScQueryParam& rParam )
// ----------------------------------------------------------------------------
+bool ScDPCacheTable::RowFlag::isActive() const
+{
+ return mbShowByFilter && mbShowByPage;
+}
+
+ScDPCacheTable::RowFlag::RowFlag() :
+ mbShowByFilter(true),
+ mbShowByPage(true)
+{
+}
+
ScDPCacheTable::FilterItem::FilterItem() :
mfValue(0.0),
mbHasValue(false)
@@ -185,8 +196,8 @@ void ScDPCacheTable::fillTable(
if ( nRowCount <= 0 || nColCount <= 0)
return;
- maRowsVisible.clear();
- maRowsVisible.reserve(nRowCount);
+ maRowFlags.clear();
+ maRowFlags.reserve(nRowCount);
// Initialize field entries container.
maFieldEntries.clear();
@@ -206,16 +217,19 @@ void ScDPCacheTable::fillTable(
SCROW nOrder = getOrder( nCol, nIndex );
if ( nCol == 0 )
- maRowsVisible.push_back(false);
+ {
+ maRowFlags.push_back(RowFlag());
+ maRowFlags.back().mbShowByFilter = false;
+ }
if ( lcl_HasQueryEntry(rQuery) &&
!getCache()->ValidQuery( nRow , rQuery, pSpecial ) )
continue;
if ( bIgnoreEmptyRows && getCache()->IsRowEmpty( nRow ) )
continue;
- // Insert a new row into cache table.
+
if ( nCol == 0 )
- maRowsVisible.back() = true;
+ maRowFlags.back().mbShowByFilter = true;
aAdded[nOrder] = nIndex;
}
@@ -236,8 +250,8 @@ void ScDPCacheTable::fillTable()
if ( nRowCount <= 0 || nColCount <= 0)
return;
- maRowsVisible.clear();
- maRowsVisible.reserve(nRowCount);
+ maRowFlags.clear();
+ maRowFlags.reserve(nRowCount);
// Initialize field entries container.
@@ -258,8 +272,10 @@ void ScDPCacheTable::fillTable()
SCROW nOrder = getOrder( nCol, nIndex );
if ( nCol == 0 )
- maRowsVisible.push_back(true);
-
+ {
+ maRowFlags.push_back(RowFlag());
+ maRowFlags.back().mbShowByFilter = true;
+ }
pAdded[nOrder] = nIndex;
}
@@ -275,24 +291,24 @@ void ScDPCacheTable::fillTable()
bool ScDPCacheTable::isRowActive(sal_Int32 nRow) const
{
- if (nRow < 0 || static_cast<size_t>(nRow) >= maRowsVisible.size())
+ if (nRow < 0 || static_cast<size_t>(nRow) >= maRowFlags.size())
// row index out of bound
return false;
- return maRowsVisible[nRow];
+ return maRowFlags[nRow].isActive();
}
void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
{
sal_Int32 nRowSize = getRowSize();
- if (nRowSize != static_cast<sal_Int32>(maRowsVisible.size()))
+ if (nRowSize != static_cast<sal_Int32>(maRowFlags.size()))
{
// sizes of the two tables differ!
return;
}
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
- maRowsVisible[nRow] = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
+ maRowFlags[nRow].mbShowByPage = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
}
const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
@@ -358,7 +374,7 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
{
- if (!maRowsVisible[nRow])
+ if (!maRowFlags[nRow].isActive())
// This row is filtered out.
continue;
@@ -400,7 +416,7 @@ SCROW ScDPCacheTable::getOrder(long nDim, SCROW nIndex) const
void ScDPCacheTable::clear()
{
maFieldEntries.clear();
- maRowsVisible.clear();
+ maRowFlags.clear();
mpCache = NULL;
}