LCOV - code coverage report
Current view: top level - sc/inc - dpresfilter.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef __SC_DPRESFILTER_HXX__
      11             : #define __SC_DPRESFILTER_HXX__
      12             : 
      13             : #include "dpitemdata.hxx"
      14             : 
      15             : #include <map>
      16             : #include <vector>
      17             : #include <boost/noncopyable.hpp>
      18             : #include <boost/unordered_map.hpp>
      19             : 
      20             : 
      21             : namespace com { namespace sun { namespace star { namespace sheet {
      22             :     struct DataPilotFieldFilter;
      23             : }}}}
      24             : 
      25           0 : struct ScDPResultFilter
      26             : {
      27             :     OUString maDimName;
      28             :     OUString maValue;
      29             : 
      30             :     bool mbHasValue:1;
      31             :     bool mbDataLayout:1;
      32             : 
      33             :     ScDPResultFilter(const OUString& rDimName, bool bDataLayout);
      34             : };
      35             : 
      36             : /**
      37             :  * This class maintains pivot table calculation result in a tree structure
      38             :  * which represents the logical structure of pivot table result layout as
      39             :  * presented in the sheet.
      40             :  *
      41             :  * <p>The root node has two child nodes if the pivot table consists of both
      42             :  * column and row dimensions. The first child stores the result tree that is
      43             :  * first filtered by row dimensions then by column dimensions. The second
      44             :  * child stores the result tree that is filtered by column dimensions only
      45             :  * (for column grand totals).</p>
      46             :  *
      47             :  * <p>If the pivot table layout only consists of either column or row
      48             :  * dimensions, the root node only has one child node.</p>
      49             :  */
      50             : class ScDPResultTree : boost::noncopyable
      51             : {
      52             : public:
      53             :     typedef std::vector<double> ValuesType;
      54             : 
      55             : private:
      56             : 
      57             :     struct MemberNode;
      58             :     struct DimensionNode;
      59             :     typedef std::map<OUString, MemberNode*> MembersType;
      60             :     typedef std::map<OUString, DimensionNode*> DimensionsType;
      61             : 
      62             :     struct DimensionNode : boost::noncopyable
      63             :     {
      64             :         const MemberNode* mpParent;
      65             :         MembersType maChildMembers;
      66             : 
      67             :         DimensionNode(const MemberNode* pParent);
      68             :         ~DimensionNode();
      69             : 
      70             : #if DEBUG_PIVOT_TABLE
      71             :         void dump(int nLevel) const;
      72             : #endif
      73             :     };
      74             : 
      75             :     struct MemberNode : boost::noncopyable
      76             :     {
      77             :         const DimensionNode* mpParent;
      78             :         ValuesType maValues;
      79             :         DimensionsType maChildDimensions;
      80             : 
      81             :         MemberNode(const DimensionNode* pParent);
      82             :         ~MemberNode();
      83             : 
      84             : #if DEBUG_PIVOT_TABLE
      85             :         void dump(int nLevel) const;
      86             : #endif
      87             :     };
      88             : 
      89             :     typedef std::pair<OUString, OUString> NamePairType;
      90             : 
      91             :     struct NamePairHash
      92             :     {
      93             :         size_t operator() (const NamePairType& rPair) const;
      94             :     };
      95             :     typedef boost::unordered_map<NamePairType, double, NamePairHash> LeafValuesType;
      96             :     LeafValuesType maLeafValues;
      97             : 
      98             :     OUString maPrimaryDimName;
      99             :     MemberNode* mpRoot;
     100             : 
     101             : public:
     102             : 
     103             :     ScDPResultTree();
     104             :     ~ScDPResultTree();
     105             : 
     106             :     /**
     107             :      * Add a single value filter path.  The filters are expected to be sorted
     108             :      * by row dimension order then by column dimension order.
     109             :      *
     110             :      * @param rFilter set of filters.
     111             :      * @param nCol column position relative to the top-left cell within the
     112             :      *             data field range.
     113             :      * @param nRow row position relative to the top-left cell within the data
     114             :      *             field range.
     115             :      * @param fVal result value, as displayed in the table output.
     116             :      */
     117             :     void add(const std::vector<ScDPResultFilter>& rFilter, long nCol, long nRow, double fVal);
     118             : 
     119             :     void swap(ScDPResultTree& rOther);
     120             : 
     121             :     bool empty() const;
     122             :     void clear();
     123             : 
     124             :     const ValuesType* getResults(
     125             :         const com::sun::star::uno::Sequence<
     126             :             com::sun::star::sheet::DataPilotFieldFilter>& rFilters) const;
     127             : 
     128             :     double getLeafResult(const com::sun::star::sheet::DataPilotFieldFilter& rFilter) const;
     129             : 
     130             : #if DEBUG_PIVOT_TABLE
     131             :     void dump() const;
     132             : #endif
     133             : };
     134             : 
     135           0 : struct ScDPResultFilterContext
     136             : {
     137             :     ScDPResultTree maFilterSet;
     138             :     std::vector<ScDPResultFilter> maFilters;
     139             :     long mnCol;
     140             :     long mnRow;
     141             : 
     142             :     ScDPResultFilterContext();
     143             : };
     144             : 
     145             : #endif
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10