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
22 {
23 template <typename> class Sequence;
24 }
25 namespace com::sun::star::sheet
26 {
27 struct DataPilotFieldFilter;
28 }
29 
31 {
32  OUString maDimName;
33  OUString maValueName;
34  OUString maValue;
35 
36  bool mbHasValue : 1;
37  bool mbDataLayout : 1;
38 
39  ScDPResultFilter(const OUString& rDimName, bool bDataLayout);
40 };
41 
57 {
58 public:
59  typedef std::vector<double> ValuesType;
60 
61 private:
62  struct MemberNode;
63  typedef std::map<OUString, std::shared_ptr<MemberNode>> MembersType;
64 
66  {
68  MembersType maChildMembersValues;
69 
70  DimensionNode();
71  DimensionNode(const DimensionNode&) = delete;
72  const DimensionNode& operator=(const DimensionNode&) = delete;
74 
75 #if DEBUG_PIVOT_TABLE
76  void dump(int nLevel) const;
77 #endif
78  };
79 
80  struct MemberNode
81  {
82  ValuesType maValues;
83  std::map<OUString, std::unique_ptr<DimensionNode>> maChildDimensions;
84 
85  MemberNode();
86  MemberNode(const MemberNode&) = delete;
87  const MemberNode& operator=(const MemberNode&) = delete;
88  ~MemberNode();
89 
90 #if DEBUG_PIVOT_TABLE
91  void dump(int nLevel) const;
92 #endif
93  };
94 
95  typedef std::pair<OUString, OUString> NamePairType;
96 
97  struct NamePairHash
98  {
99  size_t operator()(const NamePairType& rPair) const;
100  };
101  typedef std::unordered_map<NamePairType, double, NamePairHash> LeafValuesType;
102  LeafValuesType maLeafValues;
103 
105  std::unique_ptr<MemberNode> mpRoot;
106 
107 public:
108  ScDPResultTree();
109  ScDPResultTree(const ScDPResultTree&) = delete;
110  const ScDPResultTree& operator=(const ScDPResultTree&) = delete;
111  ~ScDPResultTree();
119  void add(const std::vector<ScDPResultFilter>& rFilter, double fVal);
120 
121  void swap(ScDPResultTree& rOther);
122 
123  bool empty() const;
124  void clear();
125 
126  const ValuesType*
127  getResults(const css::uno::Sequence<css::sheet::DataPilotFieldFilter>& rFilters) const;
128 
129  double getLeafResult(const css::sheet::DataPilotFieldFilter& rFilter) const;
130 
131 #if DEBUG_PIVOT_TABLE
132  void dump() const;
133 #endif
134 };
135 
137 {
139  std::vector<ScDPResultFilter> maFilters;
140  sal_Int32 mnCol;
141  sal_Int32 mnRow;
142 
144 };
145 
146 #endif
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maValueName
Definition: dpresfilter.hxx:33
double getLeafResult(const css::sheet::DataPilotFieldFilter &rFilter) const
LeafValuesType maLeafValues
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:62
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:32
This class maintains pivot table calculation result in a tree structure which represents the logical ...
Definition: dpresfilter.hxx:56
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:59
bool empty() const
std::unordered_map< NamePairType, double, NamePairHash > LeafValuesType
std::unique_ptr< MemberNode > mpRoot
std::pair< OUString, OUString > NamePairType
Definition: dpresfilter.hxx:95
const DimensionNode & operator=(const DimensionNode &)=delete
std::map< OUString, std::unique_ptr< DimensionNode > > maChildDimensions
Definition: dpresfilter.hxx:83
OUString maPrimaryDimName