Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / sc / inc / dptabres.hxx
blob4610f20348d030788965e2dfd9a2c01b32451d8a
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"
25 #include "calcmacros.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 } } } }
41 class ScAddress;
42 class ScDocument;
43 class ScDPSource;
44 class ScDPDimension;
45 class ScDPLevel;
46 class ScDPMember;
47 class ScDPAggData;
48 class ScDPResultMember;
49 class ScDPResultVisibilityData;
51 struct ScDPValue;
52 class ScDPItemData;
53 struct ScDPResultFilterContext;
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 ScDPValue& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
172 void Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
173 bool IsCalculated() const;
175 double GetResult() const;
176 bool HasError() const;
177 bool HasData() const;
179 void SetResult( double fNew );
180 void SetEmpty( 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();
191 #if DEBUG_PIVOT_TABLE
192 void Dump(int nIndent) const;
193 #endif
197 // Row and grand total state, passed down (column total is at result member)
200 class ScDPRowTotals
202 ScDPAggData aRowTotal;
203 ScDPAggData aGrandTotal;
204 bool bIsInColRoot;
206 public:
207 ScDPRowTotals();
208 ~ScDPRowTotals();
210 ScDPAggData* GetRowTotal( long nMeasure );
211 ScDPAggData* GetGrandTotal( long nMeasure );
213 bool IsInColRoot() const { return bIsInColRoot; }
214 void SetInColRoot(bool bSet) { bIsInColRoot = bSet; }
218 // results for a hierarchy dimension
221 class ScDPResultDimension;
222 class ScDPDataDimension;
223 class ScDPDataMember;
225 #define SC_DPMEASURE_ALL -1
226 #define SC_DPMEASURE_ANY -2
228 struct MemberHashIndexFunc : public std::unary_function< const SCROW &, size_t >
230 size_t operator() (const SCROW &rDataIndex) const { return rDataIndex; }
233 struct ScDPParentDimData
235 const SCROW mnOrder; //! Ref
236 const ScDPDimension* mpParentDim; //! Ref
237 const ScDPLevel* mpParentLevel; //! Ref
238 const ScDPMember* mpMemberDesc; //! Ref
240 ScDPParentDimData();
241 ScDPParentDimData(SCROW nIndex, const ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember);
244 typedef std::vector <ScDPParentDimData *> DimMemberArray;
245 typedef boost::unordered_map < SCROW, ScDPParentDimData *, MemberHashIndexFunc> DimMemberHash;
247 class ResultMembers
249 DimMemberHash maMemberHash;
250 bool mbHasHideDetailsMember;
251 public:
252 ScDPParentDimData* FindMember( SCROW nIndex ) const;
253 void InsertMember( ScDPParentDimData* pNew );
254 bool IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
255 void SetHasHideDetailsMembers( bool b ) { mbHasHideDetailsMember = b; }
256 ResultMembers();
257 virtual ~ResultMembers();
260 class LateInitParams
262 private:
263 const ::std::vector<ScDPDimension*>& mppDim;
264 const ::std::vector<ScDPLevel*>& mppLev;
266 bool mbRow:1;
267 bool mbInitChild:1;
268 bool mbAllChildren:1;
269 public:
270 LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
271 bool bRow, bool bInitChild = true, bool bAllChildren = false);
272 ~LateInitParams();
274 void SetInitChild( bool b ) { mbInitChild = b; }
275 void SetInitAllChildren( bool b ) { mbAllChildren = b; }
277 inline ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
278 inline ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];}
280 bool GetInitChild() const {return mbInitChild; }
281 bool GetInitAllChild() const { return mbAllChildren; }
282 bool IsRow() const { return mbRow; }
283 bool IsEnd( size_t nPos ) const ;
287 * The term 'measure' here roughly equals "data dimension" ?
289 class ScDPResultData
291 ScDPSource& mrSource;
292 //! keep things like measure lists here
294 std::vector<ScSubTotalFunc> maMeasureFuncs;
295 std::vector<com::sun::star::sheet::DataPilotFieldReference> maMeasureRefs;
296 std::vector<sal_uInt16> maMeasureRefOrients;
297 std::vector<OUString> maMeasureNames;
299 bool bLateInit:1;
300 bool bDataAtCol:1;
301 bool bDataAtRow:1;
303 //! add "displayed values" settings
304 mutable std::vector<ResultMembers*> maDimMembers;
305 public:
306 ScDPResultData( ScDPSource& rSrc );
307 ~ScDPResultData();
309 void SetMeasureData(
310 std::vector<ScSubTotalFunc>& rFunctions,
311 std::vector<com::sun::star::sheet::DataPilotFieldReference>& rRefs,
312 std::vector<sal_uInt16>& rRefOrient, std::vector<OUString>& rNames );
314 void SetDataLayoutOrientation( sal_uInt16 nOrient );
315 void SetLateInit( bool bSet );
317 long GetMeasureCount() const { return maMeasureFuncs.size(); }
318 ScSubTotalFunc GetMeasureFunction(long nMeasure) const;
319 OUString GetMeasureString(long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
320 OUString GetMeasureDimensionName(long nMeasure) const;
321 const ::com::sun::star::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
322 sal_uInt16 GetMeasureRefOrient(long nMeasure) const;
324 bool IsDataAtCol() const { return bDataAtCol; }
325 bool IsDataAtRow() const { return bDataAtRow; }
326 bool IsLateInit() const { return bLateInit; }
328 long GetColStartMeasure() const;
329 long GetRowStartMeasure() const;
331 long GetCountForMeasure( long nMeas ) const { return (nMeas == SC_DPMEASURE_ALL) ? maMeasureFuncs.size() : 1; }
333 bool IsBaseForGroup( long nDim ) const; // any group
334 long GetGroupBase( long nGroupDim ) const;
335 bool IsNumOrDateGroup( long nDim ) const;
336 bool IsInGroup( SCROW nGroupDataId, long nGroupIndex,
337 const ScDPItemData& rBaseData, long nBaseIndex ) const;
338 bool HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
339 const ScDPItemData& rSecondData, long nSecondIndex ) const;
341 ResultMembers* GetDimResultMembers(long nDim, ScDPDimension* pDim, ScDPLevel* pLevel) const;
343 const ScDPSource& GetSource() const;
346 class ScDPResultMember
348 private:
349 const ScDPResultData* pResultData;
350 ScDPParentDimData aParentDimData;
351 ScDPResultDimension* pChildDimension;
352 ScDPDataMember* pDataRoot;
353 bool bHasElements:1;
354 bool bForceSubTotal:1;
355 bool bHasHiddenDetails:1;
356 bool bInitialized:1;
357 bool bAutoHidden:1;
358 ScDPAggData aColTotal; // to store column totals
360 sal_uInt16 nMemberStep; // step to show details
361 public:
362 ScDPResultMember(
363 const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, bool bForceSub ); //! Ref
364 ScDPResultMember( const ScDPResultData* pData, bool bForceSub );
365 ~ScDPResultMember();
367 void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
368 const ::std::vector<ScDPLevel*>& ppLev,
369 size_t nPos,
370 ScDPInitState& rInitState,
371 bool bInitChild = true );
372 void LateInitFrom(
373 LateInitParams& rParams,
374 const ::std::vector< SCROW >& pItemData,
375 size_t nPos,
376 ScDPInitState& rInitState);
377 void CheckShowEmpty( bool bShow = false );
378 OUString GetName() const;
379 OUString GetDisplayName() const;
381 void FillItemData( ScDPItemData& rData ) const;
382 bool IsValid() const;
383 bool IsVisible() const;
384 long GetSize(long nMeasure) const;
385 bool HasHiddenDetails() const;
386 bool IsSubTotalInTitle(long nMeasure) const;
388 long GetSubTotalCount( long* pUserSubStart = NULL ) const;
390 bool IsNamedItem( SCROW nIndex ) const;
391 bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
393 void SetHasElements() { bHasElements = true; }
394 void SetAutoHidden() { bAutoHidden = true; }
396 void ProcessData( const ::std::vector<SCROW>& aChildMembers,
397 const ScDPResultDimension* pDataDim,
398 const ::std::vector<SCROW>& aDataMembers,
399 const ::std::vector<ScDPValue>& aValues );
400 void FillMemberResults(
401 com::sun::star::uno::Sequence<
402 com::sun::star::sheet::MemberResult>* pSequences,
403 long& rPos, long nMeasure, bool bRoot, const OUString* pMemberName, const OUString* pMemberCaption );
405 void FillDataResults(
406 const ScDPResultMember* pRefMember, ScDPResultFilterContext& rFilterCxt,
407 com::sun::star::uno::Sequence<
408 com::sun::star::uno::Sequence<
409 com::sun::star::sheet::DataResult> >& rSequence,
410 long nMeasure) const;
412 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
413 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
414 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
416 void SortMembers( ScDPResultMember* pRefMember );
417 void DoAutoShow( ScDPResultMember* pRefMember );
419 void ResetResults();
421 #if DEBUG_PIVOT_TABLE
422 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
424 void Dump(int nIndent) const;
425 #endif
427 //! this will be removed!
428 const ScDPResultDimension* GetChildDimension() const { return pChildDimension; }
429 ScDPResultDimension* GetChildDimension() { return pChildDimension; }
431 ScDPDataMember* GetDataRoot() const { return pDataRoot; }
433 const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref
434 const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref
435 const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref
436 SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
437 bool IsRoot() const { return GetParentLevel() == NULL; }
438 SCROW GetDataId( ) const ;
439 ScDPAggData* GetColTotal( long nMeasure ) const;
441 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
444 class ScDPDataMember
446 private:
447 const ScDPResultData* pResultData;
448 const ScDPResultMember* pResultMember; //! Ref?
449 ScDPDataDimension* pChildDimension;
450 ScDPAggData aAggregate;
452 void UpdateValues( const ::std::vector<ScDPValue>& aValues, const ScDPSubTotalState& rSubState );
454 public:
455 ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes );
456 ~ScDPDataMember();
458 void InitFrom( const ScDPResultDimension* pDim );
460 OUString GetName() const;
461 bool IsVisible() const;
462 bool HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
464 bool IsNamedItem( SCROW nRow ) const;
465 bool HasHiddenDetails() const;
467 void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValue>& aValues,
468 const ScDPSubTotalState& rSubState );
469 bool HasError( long nMeasure, const ScDPSubTotalState& rSubState ) const;
470 double GetAggregate( long nMeasure, const ScDPSubTotalState& rSubState ) const;
471 const ScDPAggData* GetConstAggData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
472 ScDPAggData* GetAggData( long nMeasure, const ScDPSubTotalState& rSubState );
474 void FillDataRow(
475 const ScDPResultMember* pRefMember,
476 ScDPResultFilterContext& rFilterCxt,
477 com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
478 long nMeasure, bool bIsSubTotalRow,
479 const ScDPSubTotalState& rSubState) const;
481 void UpdateDataRow( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
482 const ScDPSubTotalState& rSubState );
483 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
484 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
485 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent );
487 void SortMembers( ScDPResultMember* pRefMember );
488 void DoAutoShow( ScDPResultMember* pRefMember );
490 void ResetResults();
492 #if DEBUG_PIVOT_TABLE
493 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
494 void Dump(int nIndent) const;
495 #endif
497 //! this will be removed!
498 const ScDPDataDimension* GetChildDimension() const { return pChildDimension; }
499 ScDPDataDimension* GetChildDimension() { return pChildDimension; }
502 typedef std::vector<ScDPDataMember*> ScDPDataMembers;
504 // result dimension contains only members
506 class ScDPResultDimension
508 public:
509 typedef std::vector<ScDPResultMember*> MemberArray;
510 typedef std::map<SCROW, ScDPResultMember*> MemberHash;
511 private:
512 const ScDPResultData* pResultData;
513 MemberArray maMemberArray;
514 MemberHash maMemberHash;
515 OUString aDimensionName; //! or ptr to IntDimension?
516 long nSortMeasure;
517 ScMemberSortOrder aMemberOrder; // used when sorted by measure
518 bool bIsDataLayout:1; //! or ptr to IntDimension?
519 bool bSortByData:1;
520 bool bSortAscending:1;
521 bool bAutoShow:1;
522 bool bAutoTopItems:1;
523 bool bInitialized:1;
524 long nAutoMeasure;
525 long nAutoCount;
527 ScDPResultMember* FindMember( SCROW iData ) const;
528 ScDPResultMember* AddMember( const ScDPParentDimData& aData );
529 ScDPResultMember* InsertMember( ScDPParentDimData* pMemberData );
530 void InitWithMembers( LateInitParams& rParams,
531 const ::std::vector< SCROW >& pItemData,
532 size_t nPos,
533 ScDPInitState& rInitState );
534 public:
535 ScDPResultDimension( const ScDPResultData* pData );
536 ~ScDPResultDimension();
538 // allocates new members
539 void InitFrom(
540 const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
541 size_t nPos, ScDPInitState& rInitState, bool bInitChild = true );
542 void LateInitFrom( LateInitParams& rParams,
543 const ::std::vector< SCROW >& pItemData,
544 size_t nPos,
545 ScDPInitState& rInitState );
546 void CheckShowEmpty( bool bShow = false );
548 long GetSize(long nMeasure) const;
550 bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
552 // modifies existing members, allocates data dimensions
553 void ProcessData( const ::std::vector<SCROW>& aMembers,
554 const ScDPResultDimension* pDataDim,
555 const ::std::vector<SCROW>& aDataMembers,
556 const ::std::vector<ScDPValue>& aValues ) const; //! Test
557 void FillMemberResults( com::sun::star::uno::Sequence<
558 com::sun::star::sheet::MemberResult>* pSequences,
559 long nStart, long nMeasure );
561 void FillDataResults(
562 const ScDPResultMember* pRefMember,
563 ScDPResultFilterContext& rFilterCxt,
564 com::sun::star::uno::Sequence<
565 com::sun::star::uno::Sequence<
566 com::sun::star::sheet::DataResult> >& rSequence,
567 long nMeasure) const;
569 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
570 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
571 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
573 void SortMembers( ScDPResultMember* pRefMember );
574 long GetSortedIndex( long nUnsorted ) const;
576 void DoAutoShow( ScDPResultMember* pRefMember );
578 void ResetResults();
580 // called for the reference dimension
581 ScDPDataMember* GetRowReferenceMember(
582 const ScDPRelativePos* pMemberPos, const OUString* pName,
583 const long* pRowIndexes, const long* pColIndexes ) const;
585 // uses row root member from ScDPRunningTotalState
586 static ScDPDataMember* GetColReferenceMember(
587 const ScDPRelativePos* pMemberPos, const OUString* pName,
588 long nRefDimPos, const ScDPRunningTotalState& rRunning );
590 #if DEBUG_PIVOT_TABLE
591 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
592 void Dump(int nIndent) const;
593 #endif
595 // for ScDPDataDimension::InitFrom
596 long GetMemberCount() const;
597 const ScDPResultMember* GetMember(long n) const;
598 ScDPResultMember* GetMember(long n);
600 const ScMemberSortOrder& GetMemberOrder() const { return aMemberOrder; }
601 ScMemberSortOrder& GetMemberOrder() { return aMemberOrder; }
603 bool IsDataLayout() const { return bIsDataLayout; }
604 const OUString& GetName() const { return aDimensionName; }
606 bool IsSortByData() const { return bSortByData; }
607 bool IsSortAscending() const { return bSortAscending; }
608 long GetSortMeasure() const { return nSortMeasure; }
610 bool IsAutoShow() const { return bAutoShow; }
611 bool IsAutoTopItems() const { return bAutoTopItems; }
612 long GetAutoMeasure() const { return nAutoMeasure; }
613 long GetAutoCount() const { return nAutoCount; }
615 ScDPResultDimension* GetFirstChildDimension() const;
617 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
620 class ScDPDataDimension
622 private:
623 const ScDPResultData* pResultData;
624 const ScDPResultDimension* pResultDimension; // column
625 ScDPDataMembers maMembers;
626 bool bIsDataLayout; //! or ptr to IntDimension?
628 public:
629 ScDPDataDimension( const ScDPResultData* pData );
630 ~ScDPDataDimension();
632 void InitFrom( const ScDPResultDimension* pDim ); // recursive
633 void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValue>& aValues,
634 const ScDPSubTotalState& rSubState );
635 void FillDataRow(
636 const ScDPResultDimension* pRefDim,
637 ScDPResultFilterContext& rFilterCxt,
638 com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
639 long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState& rSubState) const;
641 void UpdateDataRow( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
642 const ScDPSubTotalState& rSubState ) const;
643 void UpdateRunningTotals( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
644 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
645 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const;
647 void SortMembers( ScDPResultDimension* pRefDim );
648 long GetSortedIndex( long nUnsorted ) const;
650 void DoAutoShow( ScDPResultDimension* pRefDim );
652 void ResetResults();
654 #if DEBUG_PIVOT_TABLE
655 void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const;
656 void Dump(int nIndent) const;
657 #endif
659 long GetMemberCount() const;
660 const ScDPDataMember* GetMember(long n) const;
661 ScDPDataMember* GetMember(long n);
665 * This class collects visible members of each dimension and uses that
666 * information to create filtering criteria (e.g. for drill-down data).
668 class ScDPResultVisibilityData
670 public:
671 ScDPResultVisibilityData( ScDPSource* pSource);
672 ~ScDPResultVisibilityData();
674 void addVisibleMember(const OUString& rDimName, const ScDPItemData& rMemberItem);
675 void fillFieldFilters(::std::vector<ScDPFilteredCache::Criterion>& rFilters) const;
677 private:
678 struct MemberHash
680 size_t operator()(const ScDPItemData& r) const;
682 typedef ::boost::unordered_set<ScDPItemData, MemberHash> VisibleMemberType;
683 typedef ::boost::unordered_map<OUString, VisibleMemberType, OUStringHash> DimMemberType;
684 DimMemberType maDimensions;
686 ScDPSource* mpSource;
689 #endif
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */