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 #pragma once
11 
12 #include <rtl/ustring.hxx>
13 #include "calcmacros.hxx"
14 
15 #include <memory>
16 #include <map>
17 #include <vector>
18 #include <unordered_map>
19 
20 namespace com::sun::star::uno
21 {
22 template <typename> class Sequence;
23 }
24 namespace com::sun::star::sheet
25 {
26 struct DataPilotFieldFilter;
27 }
28 
30 {
31  OUString maDimName;
32  OUString maValueName;
33  OUString maValue;
34 
35  bool mbHasValue : 1;
36  bool mbDataLayout : 1;
37 
38  ScDPResultFilter(const OUString& rDimName, bool bDataLayout);
39 };
40 
56 {
57 public:
58  typedef std::vector<double> ValuesType;
59 
60 private:
61  struct MemberNode;
62  typedef std::map<OUString, std::shared_ptr<MemberNode>> MembersType;
63 
65  {
67  MembersType maChildMembersValues;
68 
69 #if DEBUG_PIVOT_TABLE
70  void dump(int nLevel) const;
71 #endif
72  };
73 
74  struct MemberNode
75  {
76  ValuesType maValues;
77  std::map<OUString, DimensionNode> maChildDimensions;
78 
79  MemberNode();
80  MemberNode(const MemberNode&) = delete;
81  const MemberNode& operator=(const MemberNode&) = delete;
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 std::unordered_map<NamePairType, double, NamePairHash> LeafValuesType;
96  LeafValuesType maLeafValues;
97 
98  OUString maPrimaryDimName;
99  std::unique_ptr<MemberNode> mpRoot;
100 
101 public:
102  ScDPResultTree();
103  ScDPResultTree(const ScDPResultTree&) = delete;
104  const ScDPResultTree& operator=(const ScDPResultTree&) = delete;
105  ~ScDPResultTree();
113  void add(const std::vector<ScDPResultFilter>& rFilter, double fVal);
114 
115  void swap(ScDPResultTree& rOther);
116 
117  bool empty() const;
118  void clear();
119 
120  const ValuesType*
121  getResults(const css::uno::Sequence<css::sheet::DataPilotFieldFilter>& rFilters) const;
122 
123  double getLeafResult(const css::sheet::DataPilotFieldFilter& rFilter) const;
124 
125 #if DEBUG_PIVOT_TABLE
126  void dump() const;
127 #endif
128 };
129 
131 {
133  std::vector<ScDPResultFilter> maFilters;
134  sal_Int32 mnCol;
135  sal_Int32 mnRow;
136 
138 };
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maValueName
Definition: dpresfilter.hxx:32
double getLeafResult(const css::sheet::DataPilotFieldFilter &rFilter) const
LeafValuesType maLeafValues
Definition: dpresfilter.hxx:96
std::map< OUString, DimensionNode > maChildDimensions
Definition: dpresfilter.hxx:77
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:61
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:82
size_t operator()(const NamePairType &rPair) const
Definition: dpresfilter.cxx:30
OUString maDimName
Definition: dpresfilter.hxx:31
This class maintains pivot table calculation result in a tree structure which represents the logical ...
Definition: dpresfilter.hxx:55
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:58
bool empty() const
std::unordered_map< NamePairType, double, NamePairHash > LeafValuesType
Definition: dpresfilter.hxx:95
std::unique_ptr< MemberNode > mpRoot
Definition: dpresfilter.hxx:99
std::pair< OUString, OUString > NamePairType
Definition: dpresfilter.hxx:89
OUString maPrimaryDimName
Definition: dpresfilter.hxx:98