xref: /aoo41x/main/sc/inc/dptabres.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SC_DPTABRES_HXX
29*cdf0e10cSrcweir #define SC_DPTABRES_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <svl/svarray.hxx>
32*cdf0e10cSrcweir #include <tools/string.hxx>
33*cdf0e10cSrcweir #include <com/sun/star/sheet/MemberResult.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/sheet/DataResult.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
36*cdf0e10cSrcweir #include "global.hxx"		// enum ScSubTotalFunc
37*cdf0e10cSrcweir #include "dpcachetable.hxx"
38*cdf0e10cSrcweir #include <hash_map>
39*cdf0e10cSrcweir #include <hash_set>
40*cdf0e10cSrcweir #include <vector>
41*cdf0e10cSrcweir #include <memory>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace sheet {
44*cdf0e10cSrcweir     struct DataPilotFieldReference;
45*cdf0e10cSrcweir } } } }
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir class ScAddress;
49*cdf0e10cSrcweir class ScDocument;
50*cdf0e10cSrcweir class ScDPSource;
51*cdf0e10cSrcweir class ScDPDimension;
52*cdf0e10cSrcweir class ScDPDimensions;
53*cdf0e10cSrcweir class ScDPLevel;
54*cdf0e10cSrcweir class ScDPMember;
55*cdf0e10cSrcweir class ScDPAggData;
56*cdf0e10cSrcweir class ScDPResultMember;
57*cdf0e10cSrcweir class ScDPResultVisibilityData;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir struct ScDPValueData;
60*cdf0e10cSrcweir // Wang Xu Ming -- 2009-8-17
61*cdf0e10cSrcweir // DataPilot Migration - Cache&&Performance
62*cdf0e10cSrcweir class ScDPItemData;
63*cdf0e10cSrcweir // End Comments
64*cdf0e10cSrcweir //
65*cdf0e10cSrcweir //  Member names that are being processed for InitFrom/LateInitFrom
66*cdf0e10cSrcweir //  (needed for initialization of grouped items)
67*cdf0e10cSrcweir //
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir class ScDPInitState
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir     long*           pIndex;     // array
72*cdf0e10cSrcweir // Wang Xu Ming -- 2009-8-17
73*cdf0e10cSrcweir // DataPilot Migration - Cache&&Performance
74*cdf0e10cSrcweir     SCROW*     pData; // array
75*cdf0e10cSrcweir  // End Comments
76*cdf0e10cSrcweir     long            nCount;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir public:
79*cdf0e10cSrcweir             ScDPInitState();
80*cdf0e10cSrcweir             ~ScDPInitState();
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     void    AddMember( long nSourceIndex,SCROW nMember);
83*cdf0e10cSrcweir     void    RemoveMember();
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     long                GetCount() const    { return nCount; }
86*cdf0e10cSrcweir     const long*         GetSource() const   { return pIndex; }
87*cdf0e10cSrcweir // Wang Xu Ming -- 2009-8-17
88*cdf0e10cSrcweir // DataPilot Migration - Cache&&Performance
89*cdf0e10cSrcweir     const SCROW* GetNameIds() const    { return pData; }
90*cdf0e10cSrcweir     SCROW   GetNameIdForIndex( long nIndexValue ) const;
91*cdf0e10cSrcweir // End Comments
92*cdf0e10cSrcweir };
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir typedef ::std::vector<sal_Int32> ScMemberSortOrder;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir //
97*cdf0e10cSrcweir //	selected subtotal information, passed down the dimensions
98*cdf0e10cSrcweir //
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir struct ScDPSubTotalState
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	ScSubTotalFunc eColForce;
103*cdf0e10cSrcweir 	ScSubTotalFunc eRowForce;
104*cdf0e10cSrcweir 	long nColSubTotalFunc;
105*cdf0e10cSrcweir 	long nRowSubTotalFunc;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	ScDPSubTotalState() :
108*cdf0e10cSrcweir 		eColForce( SUBTOTAL_FUNC_NONE ),
109*cdf0e10cSrcweir 		eRowForce( SUBTOTAL_FUNC_NONE ),
110*cdf0e10cSrcweir 		nColSubTotalFunc( -1 ),
111*cdf0e10cSrcweir 		nRowSubTotalFunc( -1 )
112*cdf0e10cSrcweir 	{}
113*cdf0e10cSrcweir };
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir //
116*cdf0e10cSrcweir //  indexes when calculating running totals
117*cdf0e10cSrcweir //  Col/RowVisible: simple counts from 0 - without sort order applied - visible index
118*cdf0e10cSrcweir //                  (only used for running total / relative index)
119*cdf0e10cSrcweir //  Col/RowIndexes: with sort order applied - member index
120*cdf0e10cSrcweir //                  (used otherwise - so other members' children can be accessed)
121*cdf0e10cSrcweir //
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir class ScDPRunningTotalState
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir     ScDPResultMember*   pColResRoot;
126*cdf0e10cSrcweir     ScDPResultMember*   pRowResRoot;
127*cdf0e10cSrcweir     long*               pColVisible;
128*cdf0e10cSrcweir     long*               pColIndexes;
129*cdf0e10cSrcweir     long*               pRowVisible;
130*cdf0e10cSrcweir     long*               pRowIndexes;
131*cdf0e10cSrcweir     long                nColIndexPos;
132*cdf0e10cSrcweir     long                nRowIndexPos;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir public:
135*cdf0e10cSrcweir             ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* pRowRoot );
136*cdf0e10cSrcweir             ~ScDPRunningTotalState();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     ScDPResultMember*   GetColResRoot() const   { return pColResRoot; }
139*cdf0e10cSrcweir     ScDPResultMember*   GetRowResRoot() const   { return pRowResRoot; }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     const long*         GetColVisible() const   { return pColVisible; }
142*cdf0e10cSrcweir     const long*         GetColIndexes() const   { return pColIndexes; }
143*cdf0e10cSrcweir     const long*         GetRowVisible() const   { return pRowVisible; }
144*cdf0e10cSrcweir     const long*         GetRowIndexes() const   { return pRowIndexes; }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     void    AddColIndex( long nVisible, long nSorted );
147*cdf0e10cSrcweir     void    AddRowIndex( long nVisible, long nSorted );
148*cdf0e10cSrcweir     void    RemoveColIndex();
149*cdf0e10cSrcweir     void    RemoveRowIndex();
150*cdf0e10cSrcweir };
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir struct ScDPRelativePos
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir     long    nBasePos;       // simple count, without sort order applied
155*cdf0e10cSrcweir     long    nDirection;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     ScDPRelativePos( long nBase, long nDir );
158*cdf0e10cSrcweir };
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir //
161*cdf0e10cSrcweir //	aggregated data
162*cdf0e10cSrcweir //!	separate header file?
163*cdf0e10cSrcweir //
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir //  Possible values for the nCount member:
166*cdf0e10cSrcweir //  (greater than 0 counts the collected values)
167*cdf0e10cSrcweir const long SC_DPAGG_EMPTY        =  0;  // empty during data collection
168*cdf0e10cSrcweir const long SC_DPAGG_DATA_ERROR   = -1;  // error during data collection
169*cdf0e10cSrcweir const long SC_DPAGG_RESULT_EMPTY = -2;  // empty result calculated
170*cdf0e10cSrcweir const long SC_DPAGG_RESULT_VALID = -3;  // valid result calculated
171*cdf0e10cSrcweir const long SC_DPAGG_RESULT_ERROR = -4;  // error in calculated result
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir class ScDPAggData
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir private:
176*cdf0e10cSrcweir 	double			fVal;
177*cdf0e10cSrcweir 	double			fAux;
178*cdf0e10cSrcweir 	long			nCount;
179*cdf0e10cSrcweir 	ScDPAggData*	pChild;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir public:
182*cdf0e10cSrcweir 			ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY), pChild(NULL) {}
183*cdf0e10cSrcweir 			~ScDPAggData() { delete pChild; }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	void	Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
186*cdf0e10cSrcweir 	void	Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
187*cdf0e10cSrcweir 	sal_Bool	IsCalculated() const;
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	double	GetResult() const;
190*cdf0e10cSrcweir 	sal_Bool	HasError() const;
191*cdf0e10cSrcweir 	sal_Bool	HasData() const;
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	void	SetResult( double fNew );
194*cdf0e10cSrcweir 	void	SetEmpty( sal_Bool bSet );
195*cdf0e10cSrcweir 	void	SetError();
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 	double	GetAuxiliary() const;
198*cdf0e10cSrcweir 	void	SetAuxiliary( double fNew );
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 	void    Reset();        // also deletes children
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	const ScDPAggData*	GetExistingChild() const	{ return pChild; }
203*cdf0e10cSrcweir 	ScDPAggData*		GetChild();
204*cdf0e10cSrcweir };
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir //
207*cdf0e10cSrcweir //  Row and grand total state, passed down (column total is at result member)
208*cdf0e10cSrcweir //
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir class ScDPRowTotals
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     ScDPAggData aRowTotal;
213*cdf0e10cSrcweir     ScDPAggData aGrandTotal;
214*cdf0e10cSrcweir     sal_Bool        bIsInColRoot;
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir public:
217*cdf0e10cSrcweir             ScDPRowTotals();
218*cdf0e10cSrcweir             ~ScDPRowTotals();
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir     ScDPAggData*    GetRowTotal( long nMeasure );
221*cdf0e10cSrcweir     ScDPAggData*    GetGrandTotal( long nMeasure );
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     sal_Bool            IsInColRoot() const     { return bIsInColRoot; }
224*cdf0e10cSrcweir     void            SetInColRoot(sal_Bool bSet) { bIsInColRoot = bSet; }
225*cdf0e10cSrcweir };
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir // --------------------------------------------------------------------
228*cdf0e10cSrcweir //
229*cdf0e10cSrcweir //	results for a hierarchy dimension
230*cdf0e10cSrcweir //
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir #define SC_DP_RES_GROW	16
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir class ScDPResultDimension;
235*cdf0e10cSrcweir class ScDPDataDimension;
236*cdf0e10cSrcweir class ScDPDataMember;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir #define SC_DPMEASURE_ALL	-1
239*cdf0e10cSrcweir #define SC_DPMEASURE_ANY	-2
240*cdf0e10cSrcweir // Wang Xu Ming -- 2009-8-17
241*cdf0e10cSrcweir // DataPilot Migration - Cache&&Performance
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir struct MemberHashIndexFunc : public std::unary_function< const SCROW &, size_t >
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	size_t operator() (const SCROW &rDataIndex) const { return rDataIndex; }
246*cdf0e10cSrcweir };
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir class ScDPParentDimData
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir public:
251*cdf0e10cSrcweir 	const SCROW						mnOrder;						//! Ref
252*cdf0e10cSrcweir 	const ScDPDimension*			mpParentDim;			//! Ref
253*cdf0e10cSrcweir 	const ScDPLevel*				mpParentLevel;			//! Ref
254*cdf0e10cSrcweir 	const ScDPMember*				mpMemberDesc;			//! Ref
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	ScDPParentDimData():mnOrder(-1), mpParentDim( NULL), mpParentLevel( NULL ), mpMemberDesc( NULL ){}
257*cdf0e10cSrcweir 	ScDPParentDimData( const SCROW nIndex, ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember ): mnOrder( nIndex ), mpParentDim( pDim), mpParentLevel( pLev ), mpMemberDesc( pMember ){}
258*cdf0e10cSrcweir };
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir typedef std::vector <ScDPParentDimData *>                 DimMemberArray;
261*cdf0e10cSrcweir typedef std::hash_map < SCROW, ScDPParentDimData *, MemberHashIndexFunc>  DimMemberHash;
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir class ResultMembers
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     DimMemberHash      maMemberHash;
266*cdf0e10cSrcweir     sal_Bool 				mbHasHideDetailsMember;
267*cdf0e10cSrcweir public:
268*cdf0e10cSrcweir     ScDPParentDimData* FindMember( const SCROW& nIndex ) const;
269*cdf0e10cSrcweir     void                             InsertMember(  ScDPParentDimData* pNew );
270*cdf0e10cSrcweir     sal_Bool			IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
271*cdf0e10cSrcweir     void			SetHasHideDetailsMembers( sal_Bool b ) { mbHasHideDetailsMember=b; }
272*cdf0e10cSrcweir     ResultMembers();
273*cdf0e10cSrcweir     virtual ~ResultMembers();
274*cdf0e10cSrcweir };
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir class LateInitParams
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir private:
279*cdf0e10cSrcweir     const ::std::vector<ScDPDimension*>& mppDim;
280*cdf0e10cSrcweir     const ::std::vector<ScDPLevel*>& mppLev;
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir     sal_Bool      mbRow;
283*cdf0e10cSrcweir     sal_Bool      mbInitChild;
284*cdf0e10cSrcweir     sal_Bool      mbAllChildren;
285*cdf0e10cSrcweir public:
286*cdf0e10cSrcweir     LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
287*cdf0e10cSrcweir         sal_Bool bRow, sal_Bool bInitChild = sal_True , sal_Bool bAllChildren = sal_False);
288*cdf0e10cSrcweir     ~LateInitParams();
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir     void  SetInitChild( sal_Bool b ) { mbInitChild = b; }
291*cdf0e10cSrcweir     void  SetInitAllChildren( sal_Bool b ) { mbAllChildren = b; }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     inline ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
294*cdf0e10cSrcweir     inline ScDPLevel*         GetLevel( size_t nPos ) const { return mppLev[nPos];}
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir     inline sal_Bool  GetInitChild() const {return mbInitChild; }
297*cdf0e10cSrcweir     inline sal_Bool  GetInitAllChild() const { return mbAllChildren; }
298*cdf0e10cSrcweir     inline sal_Bool  IsRow() const { return mbRow; }
299*cdf0e10cSrcweir     sal_Bool  IsEnd( size_t nPos ) const ;
300*cdf0e10cSrcweir };
301*cdf0e10cSrcweir // End Comments
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir class ScDPResultData
304*cdf0e10cSrcweir {
305*cdf0e10cSrcweir private:
306*cdf0e10cSrcweir 	ScDPSource*				pSource;				//! Ref
307*cdf0e10cSrcweir 	//!	keep things like measure lists here
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 	long					nMeasCount;
310*cdf0e10cSrcweir 	ScSubTotalFunc*			pMeasFuncs;
311*cdf0e10cSrcweir 	::com::sun::star::sheet::DataPilotFieldReference* pMeasRefs;
312*cdf0e10cSrcweir 	sal_uInt16*					pMeasRefOrient;
313*cdf0e10cSrcweir 	String*					pMeasNames;
314*cdf0e10cSrcweir 	sal_Bool					bLateInit;
315*cdf0e10cSrcweir 	sal_Bool					bDataAtCol;
316*cdf0e10cSrcweir 	sal_Bool					bDataAtRow;
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	//! add "displayed values" settings
319*cdf0e10cSrcweir     	mutable std::vector< ResultMembers* > mpDimMembers;
320*cdf0e10cSrcweir public:
321*cdf0e10cSrcweir 						ScDPResultData( ScDPSource* pSrc );		//! Ref
322*cdf0e10cSrcweir 						~ScDPResultData();
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	void				SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
325*cdf0e10cSrcweir 										const ::com::sun::star::sheet::DataPilotFieldReference* pRefs,
326*cdf0e10cSrcweir 										const sal_uInt16* pRefOrient, const String* pNames );
327*cdf0e10cSrcweir 	void				SetDataLayoutOrientation( sal_uInt16 nOrient );
328*cdf0e10cSrcweir 	void				SetLateInit( sal_Bool bSet );
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 	long				GetMeasureCount() const		{ return nMeasCount; }
331*cdf0e10cSrcweir 	ScSubTotalFunc		GetMeasureFunction(long nMeasure) const;
332*cdf0e10cSrcweir     String              GetMeasureString(long nMeasure, sal_Bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
333*cdf0e10cSrcweir 	String				GetMeasureDimensionName(long nMeasure) const;
334*cdf0e10cSrcweir 	const ::com::sun::star::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
335*cdf0e10cSrcweir 	sal_uInt16				GetMeasureRefOrient(long nMeasure) const;
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	sal_Bool				IsDataAtCol() const				{ return bDataAtCol; }
338*cdf0e10cSrcweir 	sal_Bool				IsDataAtRow() const				{ return bDataAtRow; }
339*cdf0e10cSrcweir 	sal_Bool				IsLateInit() const				{ return bLateInit; }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	long				GetColStartMeasure() const;
342*cdf0e10cSrcweir 	long				GetRowStartMeasure() const;
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	long				GetCountForMeasure( long nMeas ) const
345*cdf0e10cSrcweir 								{ return ( nMeas == SC_DPMEASURE_ALL ) ? nMeasCount : 1; }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir     sal_Bool                IsBaseForGroup( long nDim ) const;              // any group
348*cdf0e10cSrcweir     long                GetGroupBase( long nGroupDim ) const;
349*cdf0e10cSrcweir     sal_Bool                IsNumOrDateGroup( long nDim ) const;
350*cdf0e10cSrcweir  // Wang Xu Ming -- 2009-8-17
351*cdf0e10cSrcweir // DataPilot Migration - Cache&&Performance
352*cdf0e10cSrcweir     sal_Bool                IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
353*cdf0e10cSrcweir                                                long nBaseDataId, long nBaseIndex ) const;
354*cdf0e10cSrcweir     sal_Bool                IsInGroup( SCROW nGroupDataId, long nGroupIndex,
355*cdf0e10cSrcweir                                               const ScDPItemData& rBaseData, long nBaseIndex ) const;
356*cdf0e10cSrcweir     sal_Bool                HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
357*cdf0e10cSrcweir                                           const ScDPItemData& rSecondData, long nSecondIndex ) const;
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir     ResultMembers* GetDimResultMembers( long nDim , ScDPDimension* pDim , ScDPLevel*   pLevel) const ;
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir // End Comments
362*cdf0e10cSrcweir     const ScDPSource*   GetSource() const;
363*cdf0e10cSrcweir };
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir class ScDPResultMember
367*cdf0e10cSrcweir {
368*cdf0e10cSrcweir private:
369*cdf0e10cSrcweir     const ScDPResultData*   pResultData;
370*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
371*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
372*cdf0e10cSrcweir     ScDPParentDimData        aParentDimData;
373*cdf0e10cSrcweir     // End Comments
374*cdf0e10cSrcweir 	ScDPResultDimension*	pChildDimension;
375*cdf0e10cSrcweir 	ScDPDataMember*			pDataRoot;
376*cdf0e10cSrcweir 	sal_Bool					bHasElements;
377*cdf0e10cSrcweir 	sal_Bool					bForceSubTotal;
378*cdf0e10cSrcweir 	sal_Bool					bHasHiddenDetails;
379*cdf0e10cSrcweir 	sal_Bool					bInitialized;
380*cdf0e10cSrcweir 	sal_Bool                    bAutoHidden;
381*cdf0e10cSrcweir 	ScDPAggData				aColTotal;				// to store column totals
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 	sal_uInt16					nMemberStep;			// step to show details
384*cdf0e10cSrcweir public:
385*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
386*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
387*cdf0e10cSrcweir     ScDPResultMember(  const ScDPResultData* pData,  const ScDPParentDimData& rParentDimData,
388*cdf0e10cSrcweir         sal_Bool bForceSub );  //! Ref
389*cdf0e10cSrcweir     ScDPResultMember(  const ScDPResultData* pData, sal_Bool bForceSub );
390*cdf0e10cSrcweir     // End Comments
391*cdf0e10cSrcweir     ~ScDPResultMember();
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
394*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
395*cdf0e10cSrcweir     void                InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
396*cdf0e10cSrcweir                                         const ::std::vector<ScDPLevel*>& ppLev,
397*cdf0e10cSrcweir                                         size_t nPos,
398*cdf0e10cSrcweir                                         ScDPInitState& rInitState,
399*cdf0e10cSrcweir                                         sal_Bool bInitChild = sal_True );
400*cdf0e10cSrcweir     void               LateInitFrom(
401*cdf0e10cSrcweir                                         LateInitParams& rParams,
402*cdf0e10cSrcweir                                         const ::std::vector< SCROW >& pItemData,
403*cdf0e10cSrcweir                                         size_t nPos,
404*cdf0e10cSrcweir                                         ScDPInitState& rInitState);
405*cdf0e10cSrcweir     void              CheckShowEmpty( sal_Bool bShow = sal_False );
406*cdf0e10cSrcweir     // End Comments
407*cdf0e10cSrcweir 	String				GetName() const;
408*cdf0e10cSrcweir     void                FillItemData( ScDPItemData& rData ) const;
409*cdf0e10cSrcweir 	sal_Bool				IsValid() const;
410*cdf0e10cSrcweir 	sal_Bool				IsVisible() const;
411*cdf0e10cSrcweir 	long				GetSize(long nMeasure) const;
412*cdf0e10cSrcweir 	sal_Bool				HasHiddenDetails() const;
413*cdf0e10cSrcweir 	sal_Bool                IsSubTotalInTitle(long nMeasure) const;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir //	sal_Bool				SubTotalEnabled() const;
416*cdf0e10cSrcweir 	long				GetSubTotalCount( long* pUserSubStart = NULL ) const;
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
419*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
420*cdf0e10cSrcweir     sal_Bool              IsNamedItem( SCROW nIndex ) const;
421*cdf0e10cSrcweir     bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
422*cdf0e10cSrcweir     // End Comments
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 	void				SetHasElements()	{ bHasElements = sal_True; }
425*cdf0e10cSrcweir 	void                SetAutoHidden()     { bAutoHidden = sal_True; }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
428*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
429*cdf0e10cSrcweir     void                ProcessData( const ::std::vector<SCROW>& aChildMembers,
430*cdf0e10cSrcweir                                         const ScDPResultDimension* pDataDim,
431*cdf0e10cSrcweir                                         const ::std::vector<SCROW>& aDataMembers,
432*cdf0e10cSrcweir                                         const ::std::vector<ScDPValueData>& aValues );
433*cdf0e10cSrcweir     // End Comments
434*cdf0e10cSrcweir 	void				FillMemberResults( com::sun::star::uno::Sequence<
435*cdf0e10cSrcweir 												com::sun::star::sheet::MemberResult>* pSequences,
436*cdf0e10cSrcweir 											long& rPos, long nMeasure, sal_Bool bRoot,
437*cdf0e10cSrcweir 											const String* pMemberName,
438*cdf0e10cSrcweir 											const String* pMemberCaption );
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 	void				FillDataResults( const ScDPResultMember* pRefMember,
441*cdf0e10cSrcweir 									com::sun::star::uno::Sequence<
442*cdf0e10cSrcweir 										com::sun::star::uno::Sequence<
443*cdf0e10cSrcweir 											com::sun::star::sheet::DataResult> >& rSequence,
444*cdf0e10cSrcweir 									long& rRow, long nMeasure ) const;
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir 	void				UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
447*cdf0e10cSrcweir 	void				UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
448*cdf0e10cSrcweir 												ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir     void                SortMembers( ScDPResultMember* pRefMember );
451*cdf0e10cSrcweir     void                DoAutoShow( ScDPResultMember* pRefMember );
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir     void                ResetResults( sal_Bool bRoot );
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir 	void				DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 						//!	this will be removed!
458*cdf0e10cSrcweir 	const ScDPResultDimension*	GetChildDimension() const	{ return pChildDimension; }
459*cdf0e10cSrcweir 	ScDPResultDimension*		GetChildDimension()			{ return pChildDimension; }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir 	ScDPDataMember*			GetDataRoot() const				{ return pDataRoot; }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
464*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
465*cdf0e10cSrcweir     const ScDPDimension*  GetParentDim() const               { return aParentDimData.mpParentDim; }     //! Ref
466*cdf0e10cSrcweir     const ScDPLevel*         GetParentLevel() const         { return aParentDimData.mpParentLevel; }   //! Ref
467*cdf0e10cSrcweir     const ScDPMember*     GetDPMember()const              { return aParentDimData.mpMemberDesc; }    //! Ref
468*cdf0e10cSrcweir     inline SCROW               GetOrder() const                           { return aParentDimData.mnOrder; }         //! Ref
469*cdf0e10cSrcweir     inline sal_Bool                  IsRoot() const                       { return GetParentLevel() == NULL; }
470*cdf0e10cSrcweir     SCROW                       GetDataId( ) const ;
471*cdf0e10cSrcweir     // End Comments
472*cdf0e10cSrcweir 	ScDPAggData*		GetColTotal( long nMeasure ) const;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir     void                FillVisibilityData(ScDPResultVisibilityData& rData) const;
475*cdf0e10cSrcweir };
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir class ScDPDataMember
478*cdf0e10cSrcweir {
479*cdf0e10cSrcweir private:
480*cdf0e10cSrcweir     const ScDPResultData*       pResultData;
481*cdf0e10cSrcweir 	const ScDPResultMember*		pResultMember;			//! Ref?
482*cdf0e10cSrcweir 	ScDPDataDimension*		pChildDimension;
483*cdf0e10cSrcweir 	ScDPAggData				aAggregate;
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir     void                UpdateValues( const ::std::vector<ScDPValueData>& aValues, const ScDPSubTotalState& rSubState );
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir public:
488*cdf0e10cSrcweir                         ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes );
489*cdf0e10cSrcweir 						~ScDPDataMember();
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir 	void				InitFrom( const ScDPResultDimension* pDim );
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 	String				GetName() const;
494*cdf0e10cSrcweir 	sal_Bool				IsVisible() const;
495*cdf0e10cSrcweir 	sal_Bool				HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
498*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
499*cdf0e10cSrcweir     sal_Bool              IsNamedItem(   SCROW r ) const;
500*cdf0e10cSrcweir     // End Comments
501*cdf0e10cSrcweir 	sal_Bool				HasHiddenDetails() const;
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
504*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
505*cdf0e10cSrcweir     void                ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValueData>& aValues,
506*cdf0e10cSrcweir                                        const ScDPSubTotalState& rSubState );
507*cdf0e10cSrcweir     // End Comments
508*cdf0e10cSrcweir 	sal_Bool				HasError( long nMeasure, const ScDPSubTotalState& rSubState ) const;
509*cdf0e10cSrcweir 	double				GetAggregate( long nMeasure, const ScDPSubTotalState& rSubState ) const;
510*cdf0e10cSrcweir 	const ScDPAggData*	GetConstAggData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
511*cdf0e10cSrcweir 	ScDPAggData*		GetAggData( long nMeasure, const ScDPSubTotalState& rSubState );
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 	void				FillDataRow( const ScDPResultMember* pRefMember,
514*cdf0e10cSrcweir 									com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
515*cdf0e10cSrcweir 									long& rCol, long nMeasure, sal_Bool bIsSubTotalRow,
516*cdf0e10cSrcweir 									const ScDPSubTotalState& rSubState ) const;
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 	void				UpdateDataRow( const ScDPResultMember* pRefMember, long nMeasure, sal_Bool bIsSubTotalRow,
519*cdf0e10cSrcweir 									const ScDPSubTotalState& rSubState );
520*cdf0e10cSrcweir 	void				UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, sal_Bool bIsSubTotalRow,
521*cdf0e10cSrcweir 									const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
522*cdf0e10cSrcweir 									ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent );
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir     void                SortMembers( ScDPResultMember* pRefMember );
525*cdf0e10cSrcweir     void                DoAutoShow( ScDPResultMember* pRefMember );
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     void                ResetResults();
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir 	void				DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 						//!	this will be removed!
532*cdf0e10cSrcweir 	const ScDPDataDimension*	GetChildDimension() const	{ return pChildDimension; }
533*cdf0e10cSrcweir 	ScDPDataDimension*			GetChildDimension()			{ return pChildDimension; }
534*cdf0e10cSrcweir };
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir //!	replace PtrArr with 32-bit array ????
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir typedef ScDPDataMember* ScDPDataMemberPtr;
539*cdf0e10cSrcweir SV_DECL_PTRARR_DEL(ScDPDataMembers, ScDPDataMemberPtr, SC_DP_RES_GROW, SC_DP_RES_GROW)
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir //	result dimension contains only members
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir class ScDPResultDimension
545*cdf0e10cSrcweir {
546*cdf0e10cSrcweir public :
547*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
548*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
549*cdf0e10cSrcweir     typedef std::vector <ScDPResultMember *>                           MemberArray;
550*cdf0e10cSrcweir     typedef std::map < SCROW , ScDPResultMember *> MemberHash;
551*cdf0e10cSrcweir     // End Comments
552*cdf0e10cSrcweir private:
553*cdf0e10cSrcweir     	const ScDPResultData*   pResultData;
554*cdf0e10cSrcweir 	MemberArray				maMemberArray;
555*cdf0e10cSrcweir 	MemberHash				maMemberHash;
556*cdf0e10cSrcweir 	sal_Bool                    bInitialized;
557*cdf0e10cSrcweir 	String					aDimensionName;		//! or ptr to IntDimension?
558*cdf0e10cSrcweir 	sal_Bool					bIsDataLayout;		//! or ptr to IntDimension?
559*cdf0e10cSrcweir 	sal_Bool                    bSortByData;
560*cdf0e10cSrcweir 	sal_Bool                    bSortAscending;
561*cdf0e10cSrcweir 	long                    nSortMeasure;
562*cdf0e10cSrcweir 	ScMemberSortOrder       aMemberOrder;       // used when sorted by measure
563*cdf0e10cSrcweir 	sal_Bool                    bAutoShow;
564*cdf0e10cSrcweir 	sal_Bool                    bAutoTopItems;
565*cdf0e10cSrcweir 	long                    nAutoMeasure;
566*cdf0e10cSrcweir 	long                    nAutoCount;
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
569*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
570*cdf0e10cSrcweir     ScDPResultMember*        FindMember(   SCROW  iData ) const;
571*cdf0e10cSrcweir     ScDPResultMember*        AddMember( const ScDPParentDimData& aData );
572*cdf0e10cSrcweir     ScDPResultMember*        InsertMember( ScDPParentDimData* pMemberData );
573*cdf0e10cSrcweir     ResultMembers*               GetResultMember( ScDPDimension* pDim, ScDPLevel* pLevel );
574*cdf0e10cSrcweir     void                                  InitWithMembers( LateInitParams& rParams,
575*cdf0e10cSrcweir                                                             const ::std::vector< SCROW >& pItemData,
576*cdf0e10cSrcweir                                                             size_t  nPos,
577*cdf0e10cSrcweir                                                             ScDPInitState& rInitState  );
578*cdf0e10cSrcweir     // End Comments
579*cdf0e10cSrcweir public:
580*cdf0e10cSrcweir        ScDPResultDimension( const ScDPResultData* pData );
581*cdf0e10cSrcweir 	~ScDPResultDimension();
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir                         //	allocates new members
584*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
585*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
586*cdf0e10cSrcweir     void                InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
587*cdf0e10cSrcweir                                         const ::std::vector<ScDPLevel*>& ppLev,
588*cdf0e10cSrcweir                                         size_t nPos,
589*cdf0e10cSrcweir                                         ScDPInitState& rInitState ,  sal_Bool bInitChild = sal_True );
590*cdf0e10cSrcweir     void                LateInitFrom(  LateInitParams& rParams,
591*cdf0e10cSrcweir                                         const ::std::vector< SCROW >& pItemData,
592*cdf0e10cSrcweir                                         size_t nPos,
593*cdf0e10cSrcweir                                         ScDPInitState& rInitState );
594*cdf0e10cSrcweir     void               CheckShowEmpty( sal_Bool bShow = sal_False );
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir     // End Comments
597*cdf0e10cSrcweir     long				GetSize(long nMeasure) const;
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
600*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
601*cdf0e10cSrcweir     bool                IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir     //	modifies existing members, allocates data dimensions
604*cdf0e10cSrcweir 	void				ProcessData( const ::std::vector<SCROW>& aMembers,
605*cdf0e10cSrcweir                                      const ScDPResultDimension* pDataDim,
606*cdf0e10cSrcweir                                      const ::std::vector<SCROW>& aDataMembers,
607*cdf0e10cSrcweir                                      const ::std::vector<ScDPValueData>& aValues ) const;	//! Test
608*cdf0e10cSrcweir  // End Comments
609*cdf0e10cSrcweir 	void				FillMemberResults( com::sun::star::uno::Sequence<
610*cdf0e10cSrcweir 												com::sun::star::sheet::MemberResult>* pSequences,
611*cdf0e10cSrcweir 											long nStart, long nMeasure );
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 	void				FillDataResults( const ScDPResultMember* pRefMember,
614*cdf0e10cSrcweir 									com::sun::star::uno::Sequence<
615*cdf0e10cSrcweir 										com::sun::star::uno::Sequence<
616*cdf0e10cSrcweir 											com::sun::star::sheet::DataResult> >& rSequence,
617*cdf0e10cSrcweir 									long nRow, long nMeasure ) const;
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 	void				UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
620*cdf0e10cSrcweir 	void				UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
621*cdf0e10cSrcweir 											ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir     void                SortMembers( ScDPResultMember* pRefMember );
624*cdf0e10cSrcweir     long                GetSortedIndex( long nUnsorted ) const;
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir     void                DoAutoShow( ScDPResultMember* pRefMember );
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir     void                ResetResults();
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir 						//	called for the reference dimension
631*cdf0e10cSrcweir 	ScDPDataMember*		GetRowReferenceMember( const ScDPRelativePos* pMemberPos, const String* pName,
632*cdf0e10cSrcweir 									const long* pRowIndexes, const long* pColIndexes ) const;
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir 						//	uses row root member from ScDPRunningTotalState
635*cdf0e10cSrcweir 	static ScDPDataMember* GetColReferenceMember( const ScDPRelativePos* pMemberPos, const String* pName,
636*cdf0e10cSrcweir 									long nRefDimPos, const ScDPRunningTotalState& rRunning );
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 	void				DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir 						//	for ScDPDataDimension::InitFrom
641*cdf0e10cSrcweir 	long				GetMemberCount() const;
642*cdf0e10cSrcweir 	const ScDPResultMember*	GetMember(long n) const;
643*cdf0e10cSrcweir 	ScDPResultMember*		GetMember(long n);
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 	const ScMemberSortOrder& GetMemberOrder() const     { return aMemberOrder; }
646*cdf0e10cSrcweir 	ScMemberSortOrder&  GetMemberOrder()                { return aMemberOrder; }
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 	sal_Bool				IsDataLayout() const	{ return bIsDataLayout; }
649*cdf0e10cSrcweir 	String				GetName() const			{ return aDimensionName; }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 	sal_Bool                IsSortByData() const    { return bSortByData; }
652*cdf0e10cSrcweir 	sal_Bool                IsSortAscending() const { return bSortAscending; }
653*cdf0e10cSrcweir 	long                GetSortMeasure() const  { return nSortMeasure; }
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	sal_Bool                IsAutoShow() const      { return bAutoShow; }
656*cdf0e10cSrcweir 	sal_Bool                IsAutoTopItems() const  { return bAutoTopItems; }
657*cdf0e10cSrcweir 	long                GetAutoMeasure() const  { return nAutoMeasure; }
658*cdf0e10cSrcweir 	long                GetAutoCount() const    { return nAutoCount; }
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir 	ScDPResultDimension* GetFirstChildDimension() const;
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir     void                FillVisibilityData(ScDPResultVisibilityData& rData) const;
663*cdf0e10cSrcweir };
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir class ScDPDataDimension
666*cdf0e10cSrcweir {
667*cdf0e10cSrcweir private:
668*cdf0e10cSrcweir     const ScDPResultData*		pResultData;
669*cdf0e10cSrcweir 	const ScDPResultDimension* pResultDimension;  // column
670*cdf0e10cSrcweir 	ScDPDataMembers		aMembers;
671*cdf0e10cSrcweir 	sal_Bool				bIsDataLayout;		//! or ptr to IntDimension?
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir public:
674*cdf0e10cSrcweir                         ScDPDataDimension( const ScDPResultData* pData );
675*cdf0e10cSrcweir 						~ScDPDataDimension();
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 	void				InitFrom( const ScDPResultDimension* pDim );		// recursive
678*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
679*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
680*cdf0e10cSrcweir     void                ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValueData>& aValues,
681*cdf0e10cSrcweir                                        const ScDPSubTotalState& rSubState );
682*cdf0e10cSrcweir     // End Comments
683*cdf0e10cSrcweir 	void				FillDataRow( const ScDPResultDimension* pRefDim,
684*cdf0e10cSrcweir 									com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
685*cdf0e10cSrcweir 									long nCol, long nMeasure, sal_Bool bIsSubTotalRow,
686*cdf0e10cSrcweir 									const ScDPSubTotalState& rSubState ) const;
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 	void				UpdateDataRow( const ScDPResultDimension* pRefDim, long nMeasure, sal_Bool bIsSubTotalRow,
689*cdf0e10cSrcweir 									const ScDPSubTotalState& rSubState ) const;
690*cdf0e10cSrcweir 	void				UpdateRunningTotals( const ScDPResultDimension* pRefDim, long nMeasure, sal_Bool bIsSubTotalRow,
691*cdf0e10cSrcweir 									const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
692*cdf0e10cSrcweir 									ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const;
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir     void                SortMembers( ScDPResultDimension* pRefDim );
695*cdf0e10cSrcweir     long                GetSortedIndex( long nUnsorted ) const;
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir     void                DoAutoShow( ScDPResultDimension* pRefDim );
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir     void                ResetResults();
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 	void				DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const;
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 	long				GetMemberCount() const;
704*cdf0e10cSrcweir 	ScDPDataMember*		GetMember(long n) const;
705*cdf0e10cSrcweir };
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir // ----------------------------------------------------------------------------
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir /**
710*cdf0e10cSrcweir  * This class collects visible members of each dimension and uses that
711*cdf0e10cSrcweir  * information to create filtering criteria (e.g. for drill-down data).
712*cdf0e10cSrcweir  */
713*cdf0e10cSrcweir class ScDPResultVisibilityData
714*cdf0e10cSrcweir {
715*cdf0e10cSrcweir public:
716*cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
717*cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
718*cdf0e10cSrcweir     ScDPResultVisibilityData( ScDPSource* pSource);
719*cdf0e10cSrcweir     // End Comments
720*cdf0e10cSrcweir     ~ScDPResultVisibilityData();
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir     void addVisibleMember(const String& rDimName, const ScDPItemData& rMemberItem);
723*cdf0e10cSrcweir     void fillFieldFilters(::std::vector<ScDPCacheTable::Criterion>& rFilters) const;
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir private:
726*cdf0e10cSrcweir     struct MemberHash
727*cdf0e10cSrcweir     {
728*cdf0e10cSrcweir         size_t operator()(const ScDPItemData& r) const;
729*cdf0e10cSrcweir     };
730*cdf0e10cSrcweir     typedef ::std::hash_set<ScDPItemData, MemberHash> VisibleMemberType;
731*cdf0e10cSrcweir     typedef ::std::hash_map<String, VisibleMemberType, ScStringHashCode> DimMemberType;
732*cdf0e10cSrcweir     DimMemberType maDimensions;
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir     ScDPSource* mpSource;
735*cdf0e10cSrcweir };
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir #endif
738*cdf0e10cSrcweir 
739