[Libreoffice-commits] .: 2 commits - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Mar 12 21:18:23 PDT 2012


 sc/source/core/data/dpgroup.cxx    |   69 ++++++++++++++++++++++++++++++-------
 sc/source/core/data/dpitemdata.cxx |    1 
 2 files changed, 58 insertions(+), 12 deletions(-)

New commits:
commit 32b3e93e04df2b09cb3bdeda8bea32a51bbf1b09
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 13 00:17:21 2012 -0400

    Get drill-down by double-click to work with number-grouped data.
    
    This never worked before, going back to the OOo days...

diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 57403c0..9b7720d 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);
             }
commit 307bfa235b40f013f6c5fda30aced14957b62dd7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Mar 12 22:09:36 2012 -0400

    Forgot to add break here...

diff --git a/sc/source/core/data/dpitemdata.cxx b/sc/source/core/data/dpitemdata.cxx
index dd370ca..43c01cb 100644
--- a/sc/source/core/data/dpitemdata.cxx
+++ b/sc/source/core/data/dpitemdata.cxx
@@ -278,6 +278,7 @@ void ScDPItemData::Dump(const char* msg) const
         break;
         case RangeStart:
             printf("range start: %g\n", mfValue);
+        break;
         default:
             printf("unknown type\n");
     }


More information about the Libreoffice-commits mailing list