1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef __SC_DPRESFILTER_HXX__
11 #define __SC_DPRESFILTER_HXX__
13 #include "dpitemdata.hxx"
17 #include <boost/noncopyable.hpp>
20 namespace com
{ namespace sun
{ namespace star
{ namespace sheet
{
21 struct DataPilotFieldFilter
;
24 struct ScDPResultFilter
32 ScDPResultFilter(const OUString
& rDimName
, bool bDataLayout
);
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.
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>
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>
49 class ScDPResultTree
: boost::noncopyable
52 typedef std::vector
<double> ValuesType
;
58 typedef std::map
<OUString
, MemberNode
*> MembersType
;
59 typedef std::map
<OUString
, DimensionNode
*> DimensionsType
;
61 struct DimensionNode
: boost::noncopyable
63 const MemberNode
* mpParent
;
64 MembersType maChildMembers
;
66 DimensionNode(const MemberNode
* pParent
);
70 void dump(int nLevel
) const;
74 struct MemberNode
: boost::noncopyable
76 const DimensionNode
* mpParent
;
78 DimensionsType maChildDimensions
;
80 MemberNode(const DimensionNode
* pParent
);
84 void dump(int nLevel
) const;
88 OUString maPrimaryDimName
;
97 * Add a single value filter path. The filters are expected to be sorted
98 * by row dimension order then by column dimension order.
100 * @param rFilter set of filters.
101 * @param nCol column position relative to the top-left cell within the
103 * @param nRow row position relative to the top-left cell within the data
105 * @param fVal result value, as displayed in the table output.
107 void add(const std::vector
<ScDPResultFilter
>& rFilter
, long nCol
, long nRow
, double fVal
);
109 void swap(ScDPResultTree
& rOther
);
114 const ValuesType
* getResults(
115 const com::sun::star::uno::Sequence
<
116 com::sun::star::sheet::DataPilotFieldFilter
>& rFilters
) const;
118 #if DEBUG_PIVOT_TABLE
123 struct ScDPResultFilterContext
125 ScDPResultTree maFilterSet
;
126 std::vector
<ScDPResultFilter
> maFilters
;
130 ScDPResultFilterContext();
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */