LCOV - code coverage report
Current view: top level - sc/inc - dpresfilter.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 2 100.0 %
Date: 2015-06-13 12:38:46 Functions: 4 4 100.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 INCLUDED_SC_INC_DPRESFILTER_HXX
      11             : #define INCLUDED_SC_INC_DPRESFILTER_HXX
      12             : 
      13             : #include "dpitemdata.hxx"
      14             : 
      15             : #include <map>
      16             : #include <vector>
      17             : #include <boost/noncopyable.hpp>
      18             : #include <unordered_map>
      19             : 
      20             : namespace com { namespace sun { namespace star { namespace sheet {
      21             :     struct DataPilotFieldFilter;
      22             : }}}}
      23             : 
      24        1408 : struct ScDPResultFilter
      25             : {
      26             :     OUString maDimName;
      27             :     OUString maValue;
      28             : 
      29             :     bool mbHasValue:1;
      30             :     bool mbDataLayout:1;
      31             : 
      32             :     ScDPResultFilter(const OUString& rDimName, bool bDataLayout);
      33             : };
      34             : 
      35             : /**
      36             :  * This class maintains pivot table calculation result in a tree structure
      37             :  * which represents the logical structure of pivot table result layout as
      38             :  * presented in the sheet.
      39             :  *
      40             :  * <p>The root node has two child nodes if the pivot table consists of both
      41             :  * column and row dimensions. The first child stores the result tree that is
      42             :  * first filtered by row dimensions then by column dimensions. The second
      43             :  * child stores the result tree that is filtered by column dimensions only
      44             :  * (for column grand totals).</p>
      45             :  *
      46             :  * <p>If the pivot table layout only consists of either column or row
      47             :  * dimensions, the root node only has one child node.</p>
      48             :  */
      49             : class ScDPResultTree : boost::noncopyable
      50             : {
      51             : public:
      52             :     typedef std::vector<double> ValuesType;
      53             : 
      54             : private:
      55             : 
      56             :     struct MemberNode;
      57             :     struct DimensionNode;
      58             :     typedef std::map<OUString, MemberNode*> MembersType;
      59             :     typedef std::map<OUString, DimensionNode*> DimensionsType;
      60             : 
      61             :     struct DimensionNode : boost::noncopyable
      62             :     {
      63             :         const MemberNode* mpParent;
      64             :         MembersType maChildMembers;
      65             : 
      66             :         DimensionNode(const MemberNode* pParent);
      67             :         ~DimensionNode();
      68             : 
      69             : #if DEBUG_PIVOT_TABLE
      70             :         void dump(int nLevel) const;
      71             : #endif
      72             :     };
      73             : 
      74             :     struct MemberNode : boost::noncopyable
      75             :     {
      76             :         const DimensionNode* mpParent;
      77             :         ValuesType maValues;
      78             :         DimensionsType maChildDimensions;
      79             : 
      80             :         MemberNode(const DimensionNode* pParent);
      81             :         ~MemberNode();
      82             : 
      83             : #if DEBUG_PIVOT_TABLE
      84             :         void dump(int nLevel) const;
      85             : #endif
      86             :     };
      87             : 
      88             :     typedef std::pair<OUString, OUString> NamePairType;
      89             : 
      90             :     struct NamePairHash
      91             :     {
      92             :         size_t operator() (const NamePairType& rPair) const;
      93             :     };
      94             :     typedef std::unordered_map<NamePairType, double, NamePairHash> LeafValuesType;
      95             :     LeafValuesType maLeafValues;
      96             : 
      97             :     OUString maPrimaryDimName;
      98             :     MemberNode* mpRoot;
      99             : 
     100             : public:
     101             : 
     102             :     ScDPResultTree();
     103             :     ~ScDPResultTree();
     104             : 
     105             :     /**
     106             :      * Add a single value filter path.  The filters are expected to be sorted
     107             :      * by row dimension order then by column dimension order.
     108             :      *
     109             :      * @param rFilter set of filters.
     110             :      * @param nCol column position relative to the top-left cell within the
     111             :      *             data field range.
     112             :      * @param nRow row position relative to the top-left cell within the data
     113             :      *             field range.
     114             :      * @param fVal result value, as displayed in the table output.
     115             :      */
     116             :     void add(const std::vector<ScDPResultFilter>& rFilter, long nCol, long nRow, double fVal);
     117             : 
     118             :     void swap(ScDPResultTree& rOther);
     119             : 
     120             :     bool empty() const;
     121             :     void clear();
     122             : 
     123             :     const ValuesType* getResults(
     124             :         const com::sun::star::uno::Sequence<
     125             :             com::sun::star::sheet::DataPilotFieldFilter>& rFilters) const;
     126             : 
     127             :     double getLeafResult(const com::sun::star::sheet::DataPilotFieldFilter& rFilter) const;
     128             : 
     129             : #if DEBUG_PIVOT_TABLE
     130             :     void dump() const;
     131             : #endif
     132             : };
     133             : 
     134          91 : struct ScDPResultFilterContext
     135             : {
     136             :     ScDPResultTree maFilterSet;
     137             :     std::vector<ScDPResultFilter> maFilters;
     138             :     long mnCol;
     139             :     long mnRow;
     140             : 
     141             :     ScDPResultFilterContext();
     142             : };
     143             : 
     144             : #endif
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11