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