diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-11 17:16:54 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-04-19 00:30:10 -0400 |
commit | ac569ed4cf5064248b9952f182f6572f20dc9bcb (patch) | |
tree | 44789fb45958b6cc8ce21f1742a04a407d5f6c75 /sc/inc/dpresfilter.hxx | |
parent | 687a821e3b4ac872fd7eb1010ea87c3d81e71991 (diff) |
fdo#60300: Work-in-progress change to rework pivot table core.
The idea is to avoid parsing the pivot table sheet output in order
to calculate GETPIVOTDATA. The table outout is configurable, and it
will only be more configurable in the future. The gist of my rework
is to calcualte the result of GETPIVOTDATA with the internl result
tree alone.
Also, the same result tree can be used for drill down too, which also
currently parses the table output, therefore subject to the same
limitation & fragility.
Change-Id: Ib0147e2aa2b710dfd627df7f535a685301214a52
Diffstat (limited to 'sc/inc/dpresfilter.hxx')
-rw-r--r-- | sc/inc/dpresfilter.hxx | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/sc/inc/dpresfilter.hxx b/sc/inc/dpresfilter.hxx new file mode 100644 index 000000000000..db32f6e16d90 --- /dev/null +++ b/sc/inc/dpresfilter.hxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef __SC_DPRESFILTER_HXX__ +#define __SC_DPRESFILTER_HXX__ + +#include "dpitemdata.hxx" + +#include <vector> +#include <boost/noncopyable.hpp> + +#if DEBUG_PIVOT_TABLE +#include <map> +#else +#include <boost/unordered_map.hpp> +#endif + +struct ScDPResultFilter +{ + OUString maDimName; + ScDPItemData maValue; + + bool mbHasValue:1; + bool mbDataLayout:1; + + ScDPResultFilter(const OUString& rDimName, bool bDataLayout); +}; + +class ScDPResultFilterSet : boost::noncopyable +{ + struct MemberNode; + struct DimensionNode; +#if DEBUG_PIVOT_TABLE + // To keep the entries sorted in the tree dump. + typedef std::map<ScDPItemData, MemberNode*> MembersType; + typedef std::map<OUString, DimensionNode*> DimensionsType; +#else + typedef boost::unordered_map<ScDPItemData, MemberNode*, ScDPItemData::Hash> MembersType; + typedef boost::unordered_map<OUString, DimensionNode*, OUStringHash> DimensionsType; +#endif + typedef std::vector<double> ValuesType; + + struct DimensionNode : boost::noncopyable + { + const MemberNode* mpParent; + MembersType maChildMembers; + + DimensionNode(const MemberNode* pParent); + ~DimensionNode(); + +#if DEBUG_PIVOT_TABLE + void dump(int nLevel) const; +#endif + }; + + struct MemberNode : boost::noncopyable + { + const DimensionNode* mpParent; + double mfValue; + ValuesType maValues; + DimensionsType maChildDimensions; + + MemberNode(const DimensionNode* pParent); + ~MemberNode(); + +#if DEBUG_PIVOT_TABLE + void dump(int nLevel) const; +#endif + }; + + MemberNode* mpRoot; + +public: + ScDPResultFilterSet(); + ~ScDPResultFilterSet(); + + /** + * Add a single value filter path. The filters are expected to be sorted + * by row dimension order then by column dimension order. + * + * @param rFilter set of filters. + * @param nCol column position relative to the top-left cell within the + * data field range. + * @param nRow row position relative to the top-left cell within the data + * field range. + * @param fVal result value, as displayed in the table output. + */ + void add(const std::vector<ScDPResultFilter>& rFilter, long nCol, long nRow, double fVal); + + void swap(ScDPResultFilterSet& rOther); + +#if DEBUG_PIVOT_TABLE + void dump() const; +#endif +}; + +struct ScDPResultFilterContext +{ + ScDPResultFilterSet maFilterSet; + std::vector<ScDPResultFilter> maFilters; + long mnCol; + long mnRow; + + ScDPResultFilterContext(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |