Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / inc / dptabres.hxx
blob900fa3e031211c4369b93479760571aa44e1e167
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 INCLUDED_SC_INC_DPTABRES_HXX
21 #define INCLUDED_SC_INC_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 <map>
32 #include <unordered_map>
33 #include <unordered_set>
34 #include <vector>
36 namespace com { namespace sun { namespace star { namespace sheet {
37 struct DataPilotFieldReference;
38 } } } }
40 class ScAddress;
41 class ScDocument;
42 class ScDPSource;
43 class ScDPDimension;
44 class ScDPLevel;
45 class ScDPMember;
46 class ScDPAggData;
47 class ScDPResultMember;
48 class ScDPResultVisibilityData;
50 struct ScDPValue;
51 class ScDPItemData;
52 struct ScDPResultFilterContext;
54 /**
55 * Member names that are being processed for InitFrom/LateInitFrom (needed
56 * for initialization of grouped items).
58 class ScDPInitState
60 public:
61 struct Member
63 long mnSrcIndex;
64 SCROW mnNameIndex;
66 Member(long nSrcIndex, SCROW nNameIndex);
69 void AddMember(long nSourceIndex, SCROW nMember);
70 void RemoveMember();
72 const std::vector<Member>& GetMembers() const { return maMembers; }
74 private:
75 std::vector<Member> maMembers;
78 typedef ::std::vector<sal_Int32> ScMemberSortOrder;
80 /**
81 * Select subtotal information, passed down the dimensions.
83 struct ScDPSubTotalState
85 ScSubTotalFunc eColForce;
86 ScSubTotalFunc eRowForce;
87 long nColSubTotalFunc;
88 long nRowSubTotalFunc;
90 ScDPSubTotalState() :
91 eColForce( SUBTOTAL_FUNC_NONE ),
92 eRowForce( SUBTOTAL_FUNC_NONE ),
93 nColSubTotalFunc( -1 ),
94 nRowSubTotalFunc( -1 )
98 /**
99 * indexes when calculating running totals
101 * Col/RowVisible: simple counts from 0 - without sort order applied
102 * - visible index (only used for running total / relative index)
104 * Col/RowSorted: with sort order applied - member index (used otherwise -
105 * so other members' children can be accessed).
107 class ScDPRunningTotalState
109 public:
110 typedef std::vector<long> IndexArray; /// array of long integers terminated by -1.
112 ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* pRowRoot );
114 ScDPResultMember* GetColResRoot() const { return pColResRoot; }
115 ScDPResultMember* GetRowResRoot() const { return pRowResRoot; }
117 const IndexArray& GetColVisible() const { return maColVisible;}
118 const IndexArray& GetColSorted() const { return maColSorted;}
119 const IndexArray& GetRowVisible() const { return maRowVisible;}
120 const IndexArray& GetRowSorted() const { return maRowSorted;}
122 void AddColIndex( long nVisible, long nSorted );
123 void AddRowIndex( long nVisible, long nSorted );
124 void RemoveColIndex();
125 void RemoveRowIndex();
127 private:
128 ScDPResultMember* pColResRoot;
129 ScDPResultMember* pRowResRoot;
131 mutable IndexArray maColVisible;
132 mutable IndexArray maColSorted;
133 mutable IndexArray maRowVisible;
134 mutable IndexArray maRowSorted;
137 struct ScDPRelativePos
139 long nBasePos; // simple count, without sort order applied
140 long nDirection;
142 ScDPRelativePos( long nBase, long nDir );
145 // aggregated data
146 //! separate header file?
148 // Possible values for the nCount member:
149 // (greater than 0 counts the collected values)
150 const long SC_DPAGG_EMPTY = 0; // empty during data collection
151 const long SC_DPAGG_DATA_ERROR = -1; // error during data collection
152 const long SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated
153 const long SC_DPAGG_RESULT_VALID = -3; // valid result calculated
154 const long SC_DPAGG_RESULT_ERROR = -4; // error in calculated result
156 class ScDPAggData
158 private:
159 double fVal;
160 double fAux;
161 long nCount;
162 ScDPAggData* pChild;
164 public:
165 ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY), pChild(nullptr) {}
166 ~ScDPAggData() { delete pChild; }
168 void Update( const ScDPValue& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
169 void Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
170 bool IsCalculated() const;
172 double GetResult() const;
173 bool HasError() const;
174 bool HasData() const;
176 void SetResult( double fNew );
177 void SetEmpty( bool bSet );
178 void SetError();
180 double GetAuxiliary() const;
181 void SetAuxiliary( double fNew );
183 void Reset(); // also deletes children
185 const ScDPAggData* GetExistingChild() const { return pChild; }
186 ScDPAggData* GetChild();
188 #if DEBUG_PIVOT_TABLE
189 void Dump(int nIndent) const;
190 #endif
193 // Row and grand total state, passed down (column total is at result member)
195 class ScDPRowTotals
197 ScDPAggData aRowTotal;
198 ScDPAggData aGrandTotal;
199 bool bIsInColRoot;
201 public:
202 ScDPRowTotals();
203 ~ScDPRowTotals();
205 ScDPAggData* GetRowTotal( long nMeasure );
206 ScDPAggData* GetGrandTotal( long nMeasure );
208 bool IsInColRoot() const { return bIsInColRoot; }
209 void SetInColRoot(bool bSet) { bIsInColRoot = bSet; }
212 // results for a hierarchy dimension
214 class ScDPResultDimension;
215 class ScDPDataDimension;
216 class ScDPDataMember;
218 #define SC_DPMEASURE_ALL -1
219 #define SC_DPMEASURE_ANY -2
221 struct MemberHashIndexFunc : public std::unary_function< const SCROW &, size_t >
223 size_t operator() (const SCROW &rDataIndex) const { return rDataIndex; }
226 struct ScDPParentDimData
228 const SCROW mnOrder; //! Ref
229 const ScDPDimension* mpParentDim; //! Ref
230 const ScDPLevel* mpParentLevel; //! Ref
231 const ScDPMember* mpMemberDesc; //! Ref
233 ScDPParentDimData();
234 ScDPParentDimData(SCROW nIndex, const ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember);
237 typedef std::unordered_map < SCROW, ScDPParentDimData *, MemberHashIndexFunc> DimMemberHash;
239 class ResultMembers
241 DimMemberHash maMemberHash;
242 bool mbHasHideDetailsMember;
243 public:
244 ScDPParentDimData* FindMember( SCROW nIndex ) const;
245 void InsertMember( ScDPParentDimData* pNew );
246 bool IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
247 void SetHasHideDetailsMembers( bool b ) { mbHasHideDetailsMember = b; }
248 ResultMembers();
249 virtual ~ResultMembers();
252 class LateInitParams
254 private:
255 const ::std::vector<ScDPDimension*>& mppDim;
256 const ::std::vector<ScDPLevel*>& mppLev;
258 bool mbRow:1;
259 bool mbInitChild:1;
260 bool mbAllChildren:1;
261 public:
262 LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
263 bool bRow);
264 ~LateInitParams();
266 void SetInitChild( bool b ) { mbInitChild = b; }
267 void SetInitAllChildren( bool b ) { mbAllChildren = b; }
269 inline ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
270 inline ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];}
272 bool GetInitChild() const {return mbInitChild; }
273 bool GetInitAllChild() const { return mbAllChildren; }
274 bool IsRow() const { return mbRow; }
275 bool IsEnd( size_t nPos ) const ;
279 * The term 'measure' here roughly equals "data dimension" ?
281 class ScDPResultData
283 ScDPSource& mrSource;
284 //! keep things like measure lists here
286 std::vector<ScSubTotalFunc> maMeasureFuncs;
287 std::vector<css::sheet::DataPilotFieldReference> maMeasureRefs;
288 std::vector<sal_uInt16> maMeasureRefOrients;
289 std::vector<OUString> maMeasureNames;
291 bool bLateInit:1;
292 bool bDataAtCol:1;
293 bool bDataAtRow:1;
295 //! add "displayed values" settings
296 mutable std::vector<ResultMembers*> maDimMembers;
297 public:
298 ScDPResultData( ScDPSource& rSrc );
299 ~ScDPResultData();
301 void SetMeasureData(
302 std::vector<ScSubTotalFunc>& rFunctions,
303 std::vector<css::sheet::DataPilotFieldReference>& rRefs,
304 std::vector<sal_uInt16>& rRefOrient, std::vector<OUString>& rNames );
306 void SetDataLayoutOrientation( sal_uInt16 nOrient );
307 void SetLateInit( bool bSet );
309 long GetMeasureCount() const { return maMeasureFuncs.size(); }
310 ScSubTotalFunc GetMeasureFunction(long nMeasure) const;
311 OUString GetMeasureString(long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
312 OUString GetMeasureDimensionName(long nMeasure) const;
313 const css::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
314 sal_uInt16 GetMeasureRefOrient(long nMeasure) const;
316 bool IsLateInit() const { return bLateInit; }
318 long GetColStartMeasure() const;
319 long GetRowStartMeasure() const;
321 long GetCountForMeasure( long nMeas ) const { return (nMeas == SC_DPMEASURE_ALL) ? maMeasureFuncs.size() : 1; }
323 bool IsBaseForGroup( long nDim ) const; // any group
324 long GetGroupBase( long nGroupDim ) const;
325 bool IsNumOrDateGroup( long nDim ) const;
326 bool IsInGroup( SCROW nGroupDataId, long nGroupIndex,
327 const ScDPItemData& rBaseData, long nBaseIndex ) const;
328 bool HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
329 const ScDPItemData& rSecondData, long nSecondIndex ) const;
331 ResultMembers* GetDimResultMembers(long nDim, ScDPDimension* pDim, ScDPLevel* pLevel) const;
333 const ScDPSource& GetSource() const { return mrSource;}
336 class ScDPResultMember
338 private:
339 const ScDPResultData* pResultData;
340 ScDPParentDimData aParentDimData;
341 ScDPResultDimension* pChildDimension;
342 ScDPDataMember* pDataRoot;
343 bool bHasElements:1;
344 bool bForceSubTotal:1;
345 bool bHasHiddenDetails:1;
346 bool bInitialized:1;
347 bool bAutoHidden:1;
348 ScDPAggData aColTotal; // to store column totals
350 sal_uInt16 nMemberStep; // step to show details
351 public:
352 ScDPResultMember(
353 const ScDPResultData* pData, const ScDPParentDimData& rParentDimData ); //! Ref
354 ScDPResultMember( const ScDPResultData* pData, bool bForceSub );
355 ~ScDPResultMember();
357 void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
358 const ::std::vector<ScDPLevel*>& ppLev,
359 size_t nPos,
360 ScDPInitState& rInitState,
361 bool bInitChild = true );
362 void LateInitFrom(
363 LateInitParams& rParams,
364 const ::std::vector< SCROW >& pItemData,
365 size_t nPos,
366 ScDPInitState& rInitState);
367 void CheckShowEmpty( bool bShow = false );
368 OUString GetName() const;
369 OUString GetDisplayName() const;
371 void FillItemData( ScDPItemData& rData ) const;
372 bool IsValid() const;
373 bool IsVisible() const;
374 long GetSize(long nMeasure) const;
375 // bHasHiddenDetails is set only if the "show details" flag is off,
376 // and there was a child dimension to skip
377 bool HasHiddenDetails() const { return bHasHiddenDetails; }
378 bool IsSubTotalInTitle(long nMeasure) const;
380 long GetSubTotalCount( long* pUserSubStart = nullptr ) const;
382 bool IsNamedItem( SCROW nIndex ) const;
383 bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
385 void SetHasElements() { bHasElements = true; }
386 void SetAutoHidden() { bAutoHidden = true; }
388 void ProcessData( const ::std::vector<SCROW>& aChildMembers,
389 const ScDPResultDimension* pDataDim,
390 const ::std::vector<SCROW>& aDataMembers,
391 const ::std::vector<ScDPValue>& aValues );
392 void FillMemberResults(
393 css::uno::Sequence< css::sheet::MemberResult>* pSequences,
394 long& rPos, long nMeasure, bool bRoot, const OUString* pMemberName, const OUString* pMemberCaption );
396 void FillDataResults(
397 const ScDPResultMember* pRefMember,
398 ScDPResultFilterContext& rFilterCxt,
399 css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult> >& rSequence,
400 long nMeasure) const;
402 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
403 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
404 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
406 void SortMembers( ScDPResultMember* pRefMember );
407 void DoAutoShow( ScDPResultMember* pRefMember );
409 void ResetResults();
411 #if DEBUG_PIVOT_TABLE
412 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
414 void Dump(int nIndent) const;
415 #endif
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 SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
427 bool IsRoot() const { return GetParentLevel() == nullptr; }
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<ScDPValue>& aValues, const ScDPSubTotalState& rSubState );
444 public:
445 ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes );
446 ~ScDPDataMember();
448 void InitFrom( const ScDPResultDimension* pDim );
450 OUString GetName() const;
451 bool IsVisible() const;
452 bool HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
454 bool IsNamedItem( SCROW nRow ) const;
455 bool HasHiddenDetails() const;
457 void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValue>& aValues,
458 const ScDPSubTotalState& rSubState );
459 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(
465 const ScDPResultMember* pRefMember,
466 ScDPResultFilterContext& rFilterCxt,
467 css::uno::Sequence<css::sheet::DataResult>& rSequence,
468 long nMeasure, bool bIsSubTotalRow,
469 const ScDPSubTotalState& rSubState) const;
471 void UpdateDataRow( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
472 const ScDPSubTotalState& rSubState );
473 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
474 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
475 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent );
477 void SortMembers( ScDPResultMember* pRefMember );
478 void DoAutoShow( ScDPResultMember* pRefMember );
480 void ResetResults();
482 #if DEBUG_PIVOT_TABLE
483 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
484 void Dump(int nIndent) const;
485 #endif
487 //! this will be removed!
488 const ScDPDataDimension* GetChildDimension() const { return pChildDimension; }
489 ScDPDataDimension* GetChildDimension() { return pChildDimension; }
492 typedef std::vector<ScDPDataMember*> ScDPDataMembers;
494 // result dimension contains only members
496 class ScDPResultDimension
498 public:
499 typedef std::vector<ScDPResultMember*> MemberArray;
500 typedef std::map<SCROW, ScDPResultMember*> MemberHash;
501 private:
502 const ScDPResultData* pResultData;
503 MemberArray maMemberArray;
504 MemberHash maMemberHash;
505 OUString aDimensionName; //! or ptr to IntDimension?
506 long nSortMeasure;
507 ScMemberSortOrder aMemberOrder; // used when sorted by measure
508 bool bIsDataLayout:1; //! or ptr to IntDimension?
509 bool bSortByData:1;
510 bool bSortAscending:1;
511 bool bAutoShow:1;
512 bool bAutoTopItems:1;
513 bool bInitialized:1;
514 long nAutoMeasure;
515 long nAutoCount;
517 ScDPResultMember* FindMember( SCROW iData ) const;
518 ScDPResultMember* AddMember( const ScDPParentDimData& aData );
519 ScDPResultMember* InsertMember( ScDPParentDimData* pMemberData );
520 void InitWithMembers( LateInitParams& rParams,
521 const ::std::vector< SCROW >& pItemData,
522 size_t nPos,
523 ScDPInitState& rInitState );
524 public:
525 ScDPResultDimension( const ScDPResultData* pData );
526 ~ScDPResultDimension();
528 // allocates new members
529 void InitFrom(
530 const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
531 size_t nPos, ScDPInitState& rInitState, bool bInitChild = true );
532 void LateInitFrom( LateInitParams& rParams,
533 const ::std::vector< SCROW >& pItemData,
534 size_t nPos,
535 ScDPInitState& rInitState );
536 void CheckShowEmpty( bool bShow = false );
538 long GetSize(long nMeasure) const;
540 bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
542 // modifies existing members, allocates data dimensions
543 void ProcessData( const ::std::vector<SCROW>& aMembers,
544 const ScDPResultDimension* pDataDim,
545 const ::std::vector<SCROW>& aDataMembers,
546 const ::std::vector<ScDPValue>& aValues ) const; //! Test
547 void FillMemberResults( css::uno::Sequence<
548 css::sheet::MemberResult>* pSequences,
549 long nStart, long nMeasure );
551 void FillDataResults(
552 const ScDPResultMember* pRefMember,
553 ScDPResultFilterContext& rFilterCxt,
554 css::uno::Sequence<
555 css::uno::Sequence<
556 css::sheet::DataResult> >& rSequence,
557 long nMeasure) const;
559 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
560 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
561 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
563 void SortMembers( ScDPResultMember* pRefMember );
564 long GetSortedIndex( long nUnsorted ) const;
566 void DoAutoShow( ScDPResultMember* pRefMember );
568 void ResetResults();
570 // called for the reference dimension
571 ScDPDataMember* GetRowReferenceMember(
572 const ScDPRelativePos* pMemberPos, const OUString* pName,
573 const long* pRowIndexes, const long* pColIndexes ) const;
575 // uses row root member from ScDPRunningTotalState
576 static ScDPDataMember* GetColReferenceMember(
577 const ScDPRelativePos* pMemberPos, const OUString* pName,
578 long nRefDimPos, const ScDPRunningTotalState& rRunning );
580 #if DEBUG_PIVOT_TABLE
581 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
582 void Dump(int nIndent) const;
583 #endif
585 // for ScDPDataDimension::InitFrom
586 long GetMemberCount() const;
587 const ScDPResultMember* GetMember(long n) const;
588 ScDPResultMember* GetMember(long n);
590 const ScMemberSortOrder& GetMemberOrder() const { return aMemberOrder; }
591 ScMemberSortOrder& GetMemberOrder() { return aMemberOrder; }
593 bool IsDataLayout() const { return bIsDataLayout; }
594 const OUString& GetName() const { return aDimensionName; }
596 bool IsSortByData() const { return bSortByData; }
597 bool IsSortAscending() const { return bSortAscending; }
598 long GetSortMeasure() const { return nSortMeasure; }
600 bool IsAutoShow() const { return bAutoShow; }
601 bool IsAutoTopItems() const { return bAutoTopItems; }
602 long GetAutoMeasure() const { return nAutoMeasure; }
603 long GetAutoCount() const { return nAutoCount; }
605 ScDPResultDimension* GetFirstChildDimension() const;
607 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
610 class ScDPDataDimension
612 private:
613 const ScDPResultData* pResultData;
614 const ScDPResultDimension* pResultDimension; // column
615 ScDPDataMembers maMembers;
616 bool bIsDataLayout; //! or ptr to IntDimension?
618 public:
619 ScDPDataDimension( const ScDPResultData* pData );
620 ~ScDPDataDimension();
622 void InitFrom( const ScDPResultDimension* pDim ); // recursive
623 void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValue>& aValues,
624 const ScDPSubTotalState& rSubState );
625 void FillDataRow(
626 const ScDPResultDimension* pRefDim,
627 ScDPResultFilterContext& rFilterCxt,
628 css::uno::Sequence<css::sheet::DataResult>& rSequence,
629 long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState& rSubState) const;
631 void UpdateDataRow( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
632 const ScDPSubTotalState& rSubState ) const;
633 void UpdateRunningTotals( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
634 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
635 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const;
637 void SortMembers( ScDPResultDimension* pRefDim );
638 long GetSortedIndex( long nUnsorted ) const;
640 void DoAutoShow( ScDPResultDimension* pRefDim );
642 void ResetResults();
644 #if DEBUG_PIVOT_TABLE
645 void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const;
646 void Dump(int nIndent) const;
647 #endif
649 long GetMemberCount() const;
650 const ScDPDataMember* GetMember(long n) const;
651 ScDPDataMember* GetMember(long n);
655 * This class collects visible members of each dimension and uses that
656 * information to create filtering criteria (e.g. for drill-down data).
658 class ScDPResultVisibilityData
660 public:
661 ScDPResultVisibilityData( ScDPSource* pSource);
662 ~ScDPResultVisibilityData();
664 void addVisibleMember(const OUString& rDimName, const ScDPItemData& rMemberItem);
665 void fillFieldFilters(::std::vector<ScDPFilteredCache::Criterion>& rFilters) const;
667 private:
668 struct MemberHash
670 size_t operator()(const ScDPItemData& r) const;
672 typedef std::unordered_set<ScDPItemData, MemberHash> VisibleMemberType;
673 typedef std::unordered_map<OUString, VisibleMemberType, OUStringHash> DimMemberType;
674 DimMemberType maDimensions;
676 ScDPSource* mpSource;
679 #endif
681 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */