summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-03-13 00:17:21 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-03-13 00:18:35 -0400
commit32b3e93e04df2b09cb3bdeda8bea32a51bbf1b09 (patch)
tree75a0afe123064cf73beab97824f838bd8b439a1d /sc
parent307bfa235b40f013f6c5fda30aced14957b62dd7 (diff)
Get drill-down by double-click to work with number-grouped data.
This never worked before, going back to the OOo days...
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/dpgroup.cxx69
1 files changed, 57 insertions, 12 deletions
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 57403c0be270..9b7720d80c81 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -77,6 +77,46 @@ inline bool IsInteger( double fValue )
}
+class ScDPGroupNumFilter : public ScDPCacheTable::FilterBase
+{
+public:
+ ScDPGroupNumFilter(const ScDPItemData& rValue, const ScDPNumGroupInfo& rInfo);
+ virtual ~ScDPGroupNumFilter() {}
+ virtual bool match(const ScDPItemData &rCellData) const;
+private:
+ ScDPItemData maValue;
+ ScDPNumGroupInfo maNumInfo;
+};
+
+ScDPGroupNumFilter::ScDPGroupNumFilter(const ScDPItemData& rValue, const ScDPNumGroupInfo& rInfo) :
+ maValue(rValue), maNumInfo(rInfo) {}
+
+bool ScDPGroupNumFilter::match(const ScDPItemData& rCellData) const
+{
+ if (rCellData.GetType() != ScDPItemData::Value)
+ return false;
+
+ double fVal = maValue.GetValue();
+ if (rtl::math::isInf(fVal))
+ {
+ if (rtl::math::isSignBitSet(fVal))
+ {
+ // Less than the min value.
+ return rCellData.GetValue() < maNumInfo.mfStart;
+ }
+
+ // Greater than the max value.
+ return maNumInfo.mfEnd < rCellData.GetValue();
+ }
+
+ double low = fVal;
+ double high = low + maNumInfo.mfStep;
+ if (maNumInfo.mbIntegerOnly)
+ high += 1.0;
+
+ return low <= rCellData.GetValue() && rCellData.GetValue() < high;
+}
+
class ScDPGroupDateFilter : public ScDPCacheTable::FilterBase
{
public:
@@ -89,9 +129,9 @@ public:
private:
ScDPGroupDateFilter(); // disabled
- ScDPItemData maValue;
- const Date maNullDate;
- const ScDPNumGroupInfo maNumInfo;
+ ScDPItemData maValue;
+ Date maNullDate;
+ ScDPNumGroupInfo maNumInfo;
};
// ----------------------------------------------------------------------------
@@ -682,19 +722,24 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
if (IsNumGroupDimension(itr->mnFieldIndex))
{
// internal number group field
+ ScDPCacheTable::Criterion aCri;
+ aCri.mnFieldIndex = itr->mnFieldIndex;
const ScDPNumGroupDimension& rNumGrpDim = pNumGroups[itr->mnFieldIndex];
const ScDPDateGroupHelper* pDateHelper = rNumGrpDim.GetDateHelper();
- if (!pDateHelper)
+
+ if (pDateHelper)
{
- // What do we do here !?
- continue;
+ // grouped by dates.
+ aCri.mpFilter.reset(
+ new ScDPGroupDateFilter(
+ pFilter->getMatchValue(), *pDoc->GetFormatTable()->GetNullDate(), pDateHelper->GetNumInfo()));
+ }
+ else
+ {
+ // This dimension is grouped by numeric ranges.
+ aCri.mpFilter.reset(
+ new ScDPGroupNumFilter(pFilter->getMatchValue(), rNumGrpDim.GetInfo()));
}
-
- ScDPCacheTable::Criterion aCri;
- aCri.mnFieldIndex = itr->mnFieldIndex;
- aCri.mpFilter.reset(
- new ScDPGroupDateFilter(
- pFilter->getMatchValue(), *pDoc->GetFormatTable()->GetNullDate(), pDateHelper->GetNumInfo()));
aNewCriteria.push_back(aCri);
}