LibreOffice Module sc (master)  1
dpresfilter.hxx
Go to the documentation of this file.
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 <rtl/ustring.hxx>
14 #include "calcmacros.hxx"
15 
16 #include <memory>
17 #include <map>
18 #include <vector>
19 #include <unordered_map>
20 
21 namespace com::sun::star::uno { template <typename > class Sequence; }
22 namespace com::sun::star::sheet { struct DataPilotFieldFilter; }
23 
25 {
26  OUString maDimName;
27  OUString maValueName;
28  OUString maValue;
29 
30  bool mbHasValue:1;
31  bool mbDataLayout:1;
32 
33  ScDPResultFilter(const OUString& rDimName, bool bDataLayout);
34 };
35 
51 {
52 public:
53  typedef std::vector<double> ValuesType;
54 
55 private:
56 
57  struct MemberNode;
58  typedef std::map<OUString, std::shared_ptr<MemberNode> > MembersType;
59 
61  {
63  MembersType maChildMembersValues;
64 
65  DimensionNode();
66  DimensionNode(const DimensionNode&) = delete;
67  const DimensionNode& operator=(const DimensionNode&) = delete;
69 
70 #if DEBUG_PIVOT_TABLE
71  void dump(int nLevel) const;
72 #endif
73  };
74 
75  struct MemberNode
76  {
77  ValuesType maValues;
78  std::map<OUString, std::unique_ptr<DimensionNode>> maChildDimensions;
79 
80  MemberNode();
81  MemberNode(const MemberNode&) = delete;
82  const MemberNode& operator=(const MemberNode&) = delete;
83  ~MemberNode();
84 
85 #if DEBUG_PIVOT_TABLE
86  void dump(int nLevel) const;
87 #endif
88  };
89 
90  typedef std::pair<OUString, OUString> NamePairType;
91 
92  struct NamePairHash
93  {
94  size_t operator() (const NamePairType& rPair) const;
95  };
96  typedef std::unordered_map<NamePairType, double, NamePairHash> LeafValuesType;
97  LeafValuesType maLeafValues;
98 
99  OUString maPrimaryDimName;
100  std::unique_ptr<MemberNode> mpRoot;
101 
102 public:
103 
104  ScDPResultTree();
105  ScDPResultTree(const ScDPResultTree&) = delete;
106  const ScDPResultTree& operator=(const ScDPResultTree&) = delete;
107  ~ScDPResultTree();
115  void add(const std::vector<ScDPResultFilter>& rFilter, double fVal);
116 
117  void swap(ScDPResultTree& rOther);
118 
119  bool empty() const;
120  void clear();
121 
122  const ValuesType* getResults(
123  const css::uno::Sequence< css::sheet::DataPilotFieldFilter>& rFilters) const;
124 
125  double getLeafResult(const css::sheet::DataPilotFieldFilter& rFilter) const;
126 
127 #if DEBUG_PIVOT_TABLE
128  void dump() const;
129 #endif
130 };
131 
133 {
135  std::vector<ScDPResultFilter> maFilters;
136  long mnCol;
137  long mnRow;
138 
140 };
141 
142 #endif
143 
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maValueName
Definition: dpresfilter.hxx:27
double getLeafResult(const css::sheet::DataPilotFieldFilter &rFilter) const
LeafValuesType maLeafValues
Definition: dpresfilter.hxx:97
void swap(ScDPResultTree &rOther)
ScDPResultTree maFilterSet
std::vector< ScDPResultFilter > maFilters
const ScDPResultTree & operator=(const ScDPResultTree &)=delete
std::map< OUString, std::shared_ptr< MemberNode > > MembersType
Definition: dpresfilter.hxx:57
const ValuesType * getResults(const css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters) const
void add(const std::vector< ScDPResultFilter > &rFilter, double fVal)
Add a single value filter path.
Definition: dpresfilter.cxx:88
size_t operator()(const NamePairType &rPair) const
Definition: dpresfilter.cxx:30
OUString maDimName
Definition: dpresfilter.hxx:26
This class maintains pivot table calculation result in a tree structure which represents the logical ...
Definition: dpresfilter.hxx:50
ScDPResultFilter(const OUString &rDimName, bool bDataLayout)
Definition: dpresfilter.cxx:24
const MemberNode & operator=(const MemberNode &)=delete
VCL_DLLPUBLIC void dump(const SkBitmap &bitmap, const char *file)
std::vector< double > ValuesType
Definition: dpresfilter.hxx:53
bool empty() const
std::unordered_map< NamePairType, double, NamePairHash > LeafValuesType
Definition: dpresfilter.hxx:96
std::unique_ptr< MemberNode > mpRoot
std::pair< OUString, OUString > NamePairType
Definition: dpresfilter.hxx:90
const DimensionNode & operator=(const DimensionNode &)=delete
std::map< OUString, std::unique_ptr< DimensionNode > > maChildDimensions
Definition: dpresfilter.hxx:78
OUString maPrimaryDimName
Definition: dpresfilter.hxx:99