Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / sc / inc / dptabres.hxx
blobedef1b342aa6bc328ae4db6b1005861d04a2d163
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SC_DPTABRES_HXX
21 #define SC_DPTABRES_HXX
23 #include "global.hxx"
24 #include "dpfilteredcache.hxx"
26 #include <tools/string.hxx>
27 #include <com/sun/star/sheet/MemberResult.hpp>
28 #include <com/sun/star/sheet/DataResult.hpp>
29 #include <com/sun/star/uno/Sequence.hxx>
31 #include <boost/unordered_map.hpp>
32 #include <boost/unordered_set.hpp>
33 #include <vector>
34 #include <memory>
35 #include <map>
37 namespace com { namespace sun { namespace star { namespace sheet {
38 struct DataPilotFieldReference;
39 } } } }
42 class ScAddress;
43 class ScDocument;
44 class ScDPSource;
45 class ScDPDimension;
46 class ScDPLevel;
47 class ScDPMember;
48 class ScDPAggData;
49 class ScDPResultMember;
50 class ScDPResultVisibilityData;
52 struct ScDPValueData;
53 class ScDPItemData;
55 /**
56 * Member names that are being processed for InitFrom/LateInitFrom (needed
57 * for initialization of grouped items).
59 class ScDPInitState
61 public:
62 struct Member
64 long mnSrcIndex;
65 SCROW mnNameIndex;
67 Member(long nSrcIndex, SCROW nNameIndex);
70 void AddMember(long nSourceIndex, SCROW nMember);
71 void RemoveMember();
73 const std::vector<Member>& GetMembers() const { return maMembers; }
75 private:
76 std::vector<Member> maMembers;
79 typedef ::std::vector<sal_Int32> ScMemberSortOrder;
81 /**
82 * Select subtotal information, passed down the dimensions.
84 struct ScDPSubTotalState
86 ScSubTotalFunc eColForce;
87 ScSubTotalFunc eRowForce;
88 long nColSubTotalFunc;
89 long nRowSubTotalFunc;
91 ScDPSubTotalState() :
92 eColForce( SUBTOTAL_FUNC_NONE ),
93 eRowForce( SUBTOTAL_FUNC_NONE ),
94 nColSubTotalFunc( -1 ),
95 nRowSubTotalFunc( -1 )
99 /**
100 * indexes when calculating running totals
102 * Col/RowVisible: simple counts from 0 - without sort order applied
103 * - visible index (only used for running total / relative index)
105 * Col/RowSorted: with sort order applied - member index (used otherwise -
106 * so other members' children can be accessed).
108 class ScDPRunningTotalState
110 public:
111 typedef std::vector<long> IndexArray; /// array of long integers terminated by -1.
113 ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* pRowRoot );
115 ScDPResultMember* GetColResRoot() const { return pColResRoot; }
116 ScDPResultMember* GetRowResRoot() const { return pRowResRoot; }
118 const IndexArray& GetColVisible() const;
119 const IndexArray& GetColSorted() const;
120 const IndexArray& GetRowVisible() const;
121 const IndexArray& GetRowSorted() const;
123 void AddColIndex( long nVisible, long nSorted );
124 void AddRowIndex( long nVisible, long nSorted );
125 void RemoveColIndex();
126 void RemoveRowIndex();
128 private:
129 ScDPResultMember* pColResRoot;
130 ScDPResultMember* pRowResRoot;
132 mutable IndexArray maColVisible;
133 mutable IndexArray maColSorted;
134 mutable IndexArray maRowVisible;
135 mutable IndexArray maRowSorted;
138 struct ScDPRelativePos
140 long nBasePos; // simple count, without sort order applied
141 long nDirection;
143 ScDPRelativePos( long nBase, long nDir );
147 // aggregated data
148 //! separate header file?
151 // Possible values for the nCount member:
152 // (greater than 0 counts the collected values)
153 const long SC_DPAGG_EMPTY = 0; // empty during data collection
154 const long SC_DPAGG_DATA_ERROR = -1; // error during data collection
155 const long SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated
156 const long SC_DPAGG_RESULT_VALID = -3; // valid result calculated
157 const long SC_DPAGG_RESULT_ERROR = -4; // error in calculated result
159 class ScDPAggData
161 private:
162 double fVal;
163 double fAux;
164 long nCount;
165 ScDPAggData* pChild;
167 public:
168 ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY), pChild(NULL) {}
169 ~ScDPAggData() { delete pChild; }
171 void Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
172 void Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
173 sal_Bool IsCalculated() const;
175 double GetResult() const;
176 sal_Bool HasError() const;
177 sal_Bool HasData() const;
179 void SetResult( double fNew );
180 void SetEmpty( sal_Bool bSet );
181 void SetError();
183 double GetAuxiliary() const;
184 void SetAuxiliary( double fNew );
186 void Reset(); // also deletes children
188 const ScDPAggData* GetExistingChild() const { return pChild; }
189 ScDPAggData* GetChild();
193 // Row and grand total state, passed down (column total is at result member)
196 class ScDPRowTotals
198 ScDPAggData aRowTotal;
199 ScDPAggData aGrandTotal;
200 sal_Bool bIsInColRoot;
202 public:
203 ScDPRowTotals();
204 ~ScDPRowTotals();
206 ScDPAggData* GetRowTotal( long nMeasure );
207 ScDPAggData* GetGrandTotal( long nMeasure );
209 sal_Bool IsInColRoot() const { return bIsInColRoot; }
210 void SetInColRoot(sal_Bool bSet) { bIsInColRoot = bSet; }
213 // --------------------------------------------------------------------
215 // results for a hierarchy dimension
218 class ScDPResultDimension;
219 class ScDPDataDimension;
220 class ScDPDataMember;
222 #define SC_DPMEASURE_ALL -1
223 #define SC_DPMEASURE_ANY -2
225 struct MemberHashIndexFunc : public std::unary_function< const SCROW &, size_t >
227 size_t operator() (const SCROW &rDataIndex) const { return rDataIndex; }
230 class ScDPParentDimData
232 public:
233 const SCROW mnOrder; //! Ref
234 const ScDPDimension* mpParentDim; //! Ref
235 const ScDPLevel* mpParentLevel; //! Ref
236 const ScDPMember* mpMemberDesc; //! Ref
238 ScDPParentDimData():mnOrder(-1), mpParentDim( NULL), mpParentLevel( NULL ), mpMemberDesc( NULL ){}
239 ScDPParentDimData( const SCROW nIndex, ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember ): mnOrder( nIndex ), mpParentDim( pDim), mpParentLevel( pLev ), mpMemberDesc( pMember ){}
242 typedef std::vector <ScDPParentDimData *> DimMemberArray;
243 typedef boost::unordered_map < SCROW, ScDPParentDimData *, MemberHashIndexFunc> DimMemberHash;
245 class ResultMembers
247 DimMemberHash maMemberHash;
248 sal_Bool mbHasHideDetailsMember;
249 public:
250 ScDPParentDimData* FindMember( const SCROW& nIndex ) const;
251 void InsertMember( ScDPParentDimData* pNew );
252 sal_Bool IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
253 void SetHasHideDetailsMembers( sal_Bool b ) { mbHasHideDetailsMember=b; }
254 ResultMembers();
255 virtual ~ResultMembers();
258 class LateInitParams
260 private:
261 const ::std::vector<ScDPDimension*>& mppDim;
262 const ::std::vector<ScDPLevel*>& mppLev;
264 sal_Bool mbRow;
265 sal_Bool mbInitChild;
266 sal_Bool mbAllChildren;
267 public:
268 LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
269 sal_Bool bRow, sal_Bool bInitChild = sal_True , sal_Bool bAllChildren = false);
270 ~LateInitParams();
272 void SetInitChild( sal_Bool b ) { mbInitChild = b; }
273 void SetInitAllChildren( sal_Bool b ) { mbAllChildren = b; }
275 inline ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
276 inline ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];}
278 inline sal_Bool GetInitChild() const {return mbInitChild; }
279 inline sal_Bool GetInitAllChild() const { return mbAllChildren; }
280 inline sal_Bool IsRow() const { return mbRow; }
281 sal_Bool IsEnd( size_t nPos ) const ;
284 class ScDPResultData
286 private:
287 ScDPSource* pSource; //! Ref
288 //! keep things like measure lists here
290 long nMeasCount;
291 ScSubTotalFunc* pMeasFuncs;
292 ::com::sun::star::sheet::DataPilotFieldReference* pMeasRefs;
293 sal_uInt16* pMeasRefOrient;
294 std::vector<rtl::OUString> maMeasureNames;
295 bool bLateInit:1;
296 bool bDataAtCol:1;
297 bool bDataAtRow:1;
299 //! add "displayed values" settings
300 mutable std::vector<ResultMembers*> maDimMembers;
301 public:
302 ScDPResultData( ScDPSource* pSrc ); //! Ref
303 ~ScDPResultData();
305 void SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
306 const ::com::sun::star::sheet::DataPilotFieldReference* pRefs,
307 const sal_uInt16* pRefOrient, std::vector<rtl::OUString>& rNames );
308 void SetDataLayoutOrientation( sal_uInt16 nOrient );
309 void SetLateInit( bool bSet );
311 long GetMeasureCount() const { return nMeasCount; }
312 ScSubTotalFunc GetMeasureFunction(long nMeasure) const;
313 rtl::OUString GetMeasureString(long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
314 rtl::OUString GetMeasureDimensionName(long nMeasure) const;
315 const ::com::sun::star::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
316 sal_uInt16 GetMeasureRefOrient(long nMeasure) const;
318 bool IsDataAtCol() const { return bDataAtCol; }
319 bool IsDataAtRow() const { return bDataAtRow; }
320 bool IsLateInit() const { return bLateInit; }
322 long GetColStartMeasure() const;
323 long GetRowStartMeasure() const;
325 long GetCountForMeasure( long nMeas ) const
326 { return ( nMeas == SC_DPMEASURE_ALL ) ? nMeasCount : 1; }
328 bool IsBaseForGroup( long nDim ) const; // any group
329 long GetGroupBase( long nGroupDim ) const;
330 bool IsNumOrDateGroup( long nDim ) const;
331 bool IsInGroup( SCROW nGroupDataId, long nGroupIndex,
332 const ScDPItemData& rBaseData, long nBaseIndex ) const;
333 bool HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
334 const ScDPItemData& rSecondData, long nSecondIndex ) const;
336 ResultMembers* GetDimResultMembers(long nDim, ScDPDimension* pDim, ScDPLevel* pLevel) const;
338 const ScDPSource* GetSource() const;
342 class ScDPResultMember
344 private:
345 const ScDPResultData* pResultData;
346 ScDPParentDimData aParentDimData;
347 ScDPResultDimension* pChildDimension;
348 ScDPDataMember* pDataRoot;
349 sal_Bool bHasElements;
350 sal_Bool bForceSubTotal;
351 sal_Bool bHasHiddenDetails;
352 sal_Bool bInitialized;
353 sal_Bool bAutoHidden;
354 ScDPAggData aColTotal; // to store column totals
356 sal_uInt16 nMemberStep; // step to show details
357 public:
358 ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData,
359 sal_Bool bForceSub ); //! Ref
360 ScDPResultMember( const ScDPResultData* pData, sal_Bool bForceSub );
361 ~ScDPResultMember();
363 void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
364 const ::std::vector<ScDPLevel*>& ppLev,
365 size_t nPos,
366 ScDPInitState& rInitState,
367 sal_Bool bInitChild = sal_True );
368 void LateInitFrom(
369 LateInitParams& rParams,
370 const ::std::vector< SCROW >& pItemData,
371 size_t nPos,
372 ScDPInitState& rInitState);
373 void CheckShowEmpty( sal_Bool bShow = false );
374 String GetName() const;
375 void FillItemData( ScDPItemData& rData ) const;
376 sal_Bool IsValid() const;
377 sal_Bool IsVisible() const;
378 long GetSize(long nMeasure) const;
379 sal_Bool HasHiddenDetails() const;
380 sal_Bool IsSubTotalInTitle(long nMeasure) const;
382 long GetSubTotalCount( long* pUserSubStart = NULL ) const;
384 sal_Bool IsNamedItem( SCROW nIndex ) const;
385 bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
387 void SetHasElements() { bHasElements = sal_True; }
388 void SetAutoHidden() { bAutoHidden = sal_True; }
390 void ProcessData( const ::std::vector<SCROW>& aChildMembers,
391 const ScDPResultDimension* pDataDim,
392 const ::std::vector<SCROW>& aDataMembers,
393 const ::std::vector<ScDPValueData>& aValues );
394 void FillMemberResults( com::sun::star::uno::Sequence<
395 com::sun::star::sheet::MemberResult>* pSequences,
396 long& rPos, long nMeasure, sal_Bool bRoot,
397 const String* pMemberName,
398 const String* pMemberCaption );
400 void FillDataResults( const ScDPResultMember* pRefMember,
401 com::sun::star::uno::Sequence<
402 com::sun::star::uno::Sequence<
403 com::sun::star::sheet::DataResult> >& rSequence,
404 long& rRow, long nMeasure ) const;
406 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
407 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
408 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
410 void SortMembers( ScDPResultMember* pRefMember );
411 void DoAutoShow( ScDPResultMember* pRefMember );
413 void ResetResults( sal_Bool bRoot );
415 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
417 //! this will be removed!
418 const ScDPResultDimension* GetChildDimension() const { return pChildDimension; }
419 ScDPResultDimension* GetChildDimension() { return pChildDimension; }
421 ScDPDataMember* GetDataRoot() const { return pDataRoot; }
423 const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref
424 const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref
425 const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref
426 inline SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
427 inline sal_Bool IsRoot() const { return GetParentLevel() == NULL; }
428 SCROW GetDataId( ) const ;
429 ScDPAggData* GetColTotal( long nMeasure ) const;
431 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
434 class ScDPDataMember
436 private:
437 const ScDPResultData* pResultData;
438 const ScDPResultMember* pResultMember; //! Ref?
439 ScDPDataDimension* pChildDimension;
440 ScDPAggData aAggregate;
442 void UpdateValues( const ::std::vector<ScDPValueData>& aValues, const ScDPSubTotalState& rSubState );
444 public:
445 ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes );
446 ~ScDPDataMember();
448 void InitFrom( const ScDPResultDimension* pDim );
450 String GetName() const;
451 sal_Bool IsVisible() const;
452 sal_Bool HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
454 sal_Bool IsNamedItem( SCROW r ) const;
455 sal_Bool HasHiddenDetails() const;
457 void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValueData>& aValues,
458 const ScDPSubTotalState& rSubState );
459 sal_Bool HasError( long nMeasure, const ScDPSubTotalState& rSubState ) const;
460 double GetAggregate( long nMeasure, const ScDPSubTotalState& rSubState ) const;
461 const ScDPAggData* GetConstAggData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
462 ScDPAggData* GetAggData( long nMeasure, const ScDPSubTotalState& rSubState );
464 void FillDataRow( const ScDPResultMember* pRefMember,
465 com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
466 long& rCol, long nMeasure, sal_Bool bIsSubTotalRow,
467 const ScDPSubTotalState& rSubState ) const;
469 void UpdateDataRow( const ScDPResultMember* pRefMember, long nMeasure, sal_Bool bIsSubTotalRow,
470 const ScDPSubTotalState& rSubState );
471 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, sal_Bool bIsSubTotalRow,
472 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
473 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent );
475 void SortMembers( ScDPResultMember* pRefMember );
476 void DoAutoShow( ScDPResultMember* pRefMember );
478 void ResetResults();
480 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
482 //! this will be removed!
483 const ScDPDataDimension* GetChildDimension() const { return pChildDimension; }
484 ScDPDataDimension* GetChildDimension() { return pChildDimension; }
487 typedef std::vector<ScDPDataMember*> ScDPDataMembers;
490 // result dimension contains only members
492 class ScDPResultDimension
494 public:
495 typedef std::vector<ScDPResultMember*> MemberArray;
496 typedef std::map<SCROW, ScDPResultMember*> MemberHash;
497 private:
498 const ScDPResultData* pResultData;
499 MemberArray maMemberArray;
500 MemberHash maMemberHash;
501 rtl::OUString aDimensionName; //! or ptr to IntDimension?
502 long nSortMeasure;
503 ScMemberSortOrder aMemberOrder; // used when sorted by measure
504 bool bIsDataLayout:1; //! or ptr to IntDimension?
505 bool bSortByData:1;
506 bool bSortAscending:1;
507 bool bAutoShow:1;
508 bool bAutoTopItems:1;
509 bool bInitialized:1;
510 long nAutoMeasure;
511 long nAutoCount;
513 ScDPResultMember* FindMember( SCROW iData ) const;
514 ScDPResultMember* AddMember( const ScDPParentDimData& aData );
515 ScDPResultMember* InsertMember( ScDPParentDimData* pMemberData );
516 void InitWithMembers( LateInitParams& rParams,
517 const ::std::vector< SCROW >& pItemData,
518 size_t nPos,
519 ScDPInitState& rInitState );
520 public:
521 ScDPResultDimension( const ScDPResultData* pData );
522 ~ScDPResultDimension();
524 // allocates new members
525 void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
526 const ::std::vector<ScDPLevel*>& ppLev,
527 size_t nPos,
528 ScDPInitState& rInitState , sal_Bool bInitChild = sal_True );
529 void LateInitFrom( LateInitParams& rParams,
530 const ::std::vector< SCROW >& pItemData,
531 size_t nPos,
532 ScDPInitState& rInitState );
533 void CheckShowEmpty( sal_Bool bShow = false );
535 long GetSize(long nMeasure) const;
537 bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
539 // modifies existing members, allocates data dimensions
540 void ProcessData( const ::std::vector<SCROW>& aMembers,
541 const ScDPResultDimension* pDataDim,
542 const ::std::vector<SCROW>& aDataMembers,
543 const ::std::vector<ScDPValueData>& aValues ) const; //! Test
544 void FillMemberResults( com::sun::star::uno::Sequence<
545 com::sun::star::sheet::MemberResult>* pSequences,
546 long nStart, long nMeasure );
548 void FillDataResults( const ScDPResultMember* pRefMember,
549 com::sun::star::uno::Sequence<
550 com::sun::star::uno::Sequence<
551 com::sun::star::sheet::DataResult> >& rSequence,
552 long nRow, long nMeasure ) const;
554 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
555 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
556 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
558 void SortMembers( ScDPResultMember* pRefMember );
559 long GetSortedIndex( long nUnsorted ) const;
561 void DoAutoShow( ScDPResultMember* pRefMember );
563 void ResetResults();
565 // called for the reference dimension
566 ScDPDataMember* GetRowReferenceMember( const ScDPRelativePos* pMemberPos, const String* pName,
567 const long* pRowIndexes, const long* pColIndexes ) const;
569 // uses row root member from ScDPRunningTotalState
570 static ScDPDataMember* GetColReferenceMember( const ScDPRelativePos* pMemberPos, const String* pName,
571 long nRefDimPos, const ScDPRunningTotalState& rRunning );
573 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
575 // for ScDPDataDimension::InitFrom
576 long GetMemberCount() const;
577 const ScDPResultMember* GetMember(long n) const;
578 ScDPResultMember* GetMember(long n);
580 const ScMemberSortOrder& GetMemberOrder() const { return aMemberOrder; }
581 ScMemberSortOrder& GetMemberOrder() { return aMemberOrder; }
583 sal_Bool IsDataLayout() const { return bIsDataLayout; }
584 String GetName() const { return aDimensionName; }
586 sal_Bool IsSortByData() const { return bSortByData; }
587 sal_Bool IsSortAscending() const { return bSortAscending; }
588 long GetSortMeasure() const { return nSortMeasure; }
590 sal_Bool IsAutoShow() const { return bAutoShow; }
591 sal_Bool IsAutoTopItems() const { return bAutoTopItems; }
592 long GetAutoMeasure() const { return nAutoMeasure; }
593 long GetAutoCount() const { return nAutoCount; }
595 ScDPResultDimension* GetFirstChildDimension() const;
597 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
600 class ScDPDataDimension
602 private:
603 const ScDPResultData* pResultData;
604 const ScDPResultDimension* pResultDimension; // column
605 ScDPDataMembers maMembers;
606 sal_Bool bIsDataLayout; //! or ptr to IntDimension?
608 public:
609 ScDPDataDimension( const ScDPResultData* pData );
610 ~ScDPDataDimension();
612 void InitFrom( const ScDPResultDimension* pDim ); // recursive
613 void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValueData>& aValues,
614 const ScDPSubTotalState& rSubState );
615 void FillDataRow( const ScDPResultDimension* pRefDim,
616 com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
617 long nCol, long nMeasure, sal_Bool bIsSubTotalRow,
618 const ScDPSubTotalState& rSubState ) const;
620 void UpdateDataRow( const ScDPResultDimension* pRefDim, long nMeasure, sal_Bool bIsSubTotalRow,
621 const ScDPSubTotalState& rSubState ) const;
622 void UpdateRunningTotals( const ScDPResultDimension* pRefDim, long nMeasure, sal_Bool bIsSubTotalRow,
623 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
624 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const;
626 void SortMembers( ScDPResultDimension* pRefDim );
627 long GetSortedIndex( long nUnsorted ) const;
629 void DoAutoShow( ScDPResultDimension* pRefDim );
631 void ResetResults();
633 void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const;
635 long GetMemberCount() const;
636 const ScDPDataMember* GetMember(long n) const;
637 ScDPDataMember* GetMember(long n);
640 // ----------------------------------------------------------------------------
643 * This class collects visible members of each dimension and uses that
644 * information to create filtering criteria (e.g. for drill-down data).
646 class ScDPResultVisibilityData
648 public:
649 ScDPResultVisibilityData( ScDPSource* pSource);
650 ~ScDPResultVisibilityData();
652 void addVisibleMember(const String& rDimName, const ScDPItemData& rMemberItem);
653 void fillFieldFilters(::std::vector<ScDPFilteredCache::Criterion>& rFilters) const;
655 private:
656 struct MemberHash
658 size_t operator()(const ScDPItemData& r) const;
660 typedef ::boost::unordered_set<ScDPItemData, MemberHash> VisibleMemberType;
661 typedef ::boost::unordered_map<String, VisibleMemberType, ScStringHashCode> DimMemberType;
662 DimMemberType maDimensions;
664 ScDPSource* mpSource;
667 #endif
669 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */