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