tdf#104816 sw: if non-section content, let all sections hide.
[LibreOffice.git] / sc / inc / dptabres.hxx
blob0a20f3cffa761aa0426a34b39fc454823ebbc3cf
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"
26 #include "dpitemdata.hxx"
27 #include "subtotal.hxx"
29 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
30 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
32 #include <map>
33 #include <unordered_map>
34 #include <unordered_set>
35 #include <memory>
36 #include <vector>
38 namespace com { namespace sun { namespace star { namespace sheet { struct DataResult; } } } }
39 namespace com { namespace sun { namespace star { namespace sheet { struct MemberResult; } } } }
40 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Sequence; } } } }
42 class ScDPSource;
43 class ScDPDimension;
44 class ScDPLevel;
45 class ScDPMember;
46 class ScDPResultMember;
47 class ScDPResultVisibilityData;
49 struct ScDPValue;
50 struct ScDPResultFilterContext;
52 /**
53 * Member names that are being processed for InitFrom/LateInitFrom (needed
54 * for initialization of grouped items).
56 class ScDPInitState
58 public:
59 struct Member
61 long const mnSrcIndex;
62 SCROW const mnNameIndex;
64 Member(long nSrcIndex, SCROW nNameIndex);
67 void AddMember(long nSourceIndex, SCROW nMember);
68 void RemoveMember();
70 const std::vector<Member>& GetMembers() const { return maMembers; }
72 private:
73 std::vector<Member> maMembers;
76 typedef ::std::vector<sal_Int32> ScMemberSortOrder;
78 /**
79 * Select subtotal information, passed down the dimensions.
81 struct ScDPSubTotalState
83 ScSubTotalFunc eColForce;
84 ScSubTotalFunc eRowForce;
85 long nColSubTotalFunc;
86 long nRowSubTotalFunc;
88 ScDPSubTotalState() :
89 eColForce( SUBTOTAL_FUNC_NONE ),
90 eRowForce( SUBTOTAL_FUNC_NONE ),
91 nColSubTotalFunc( -1 ),
92 nRowSubTotalFunc( -1 )
96 /**
97 * indexes when calculating running totals
99 * Col/RowVisible: simple counts from 0 - without sort order applied
100 * - visible index (only used for running total / relative index)
102 * Col/RowSorted: with sort order applied - member index (used otherwise -
103 * so other members' children can be accessed).
105 class ScDPRunningTotalState
107 public:
108 typedef std::vector<long> IndexArray; /// array of long integers terminated by -1.
110 ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* pRowRoot );
112 ScDPResultMember* GetColResRoot() const { return pColResRoot; }
113 ScDPResultMember* GetRowResRoot() const { return pRowResRoot; }
115 const IndexArray& GetColVisible() const { return maColVisible;}
116 const IndexArray& GetColSorted() const { return maColSorted;}
117 const IndexArray& GetRowVisible() const { return maRowVisible;}
118 const IndexArray& GetRowSorted() const { return maRowSorted;}
120 void AddColIndex( long nVisible, long nSorted );
121 void AddRowIndex( long nVisible, long nSorted );
122 void RemoveColIndex();
123 void RemoveRowIndex();
125 private:
126 ScDPResultMember* const pColResRoot;
127 ScDPResultMember* const pRowResRoot;
129 mutable IndexArray maColVisible;
130 mutable IndexArray maColSorted;
131 mutable IndexArray maRowVisible;
132 mutable IndexArray maRowSorted;
135 struct ScDPRelativePos
137 long nBasePos; // simple count, without sort order applied
138 long const nDirection;
140 ScDPRelativePos( long nBase, long nDir );
143 // aggregated data
144 //! separate header file?
146 // Possible values for the nCount member:
147 // (greater than 0 counts the collected values)
148 const sal_Int64 SC_DPAGG_EMPTY = 0; // empty during data collection
149 const sal_Int64 SC_DPAGG_DATA_ERROR = -1; // error during data collection
150 const sal_Int64 SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated
151 const sal_Int64 SC_DPAGG_RESULT_VALID = -3; // valid result calculated
152 const sal_Int64 SC_DPAGG_RESULT_ERROR = -4; // error in calculated result
154 class ScDPAggData
156 private:
157 WelfordRunner maWelford;
158 double fVal;
159 double fAux;
160 sal_Int64 nCount;
161 std::unique_ptr<ScDPAggData> pChild;
162 std::vector<double> mSortedValues;
164 public:
165 ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY) {}
167 void Update( const ScDPValue& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
168 void Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
169 bool IsCalculated() const;
171 double GetResult() const;
172 bool HasError() const;
173 bool HasData() const;
175 void SetResult( double fNew );
176 void SetEmpty( bool bSet );
177 void SetError();
179 double GetAuxiliary() const;
180 void SetAuxiliary( double fNew );
182 void Reset(); // also deletes children
184 const ScDPAggData* GetExistingChild() const { return pChild.get(); }
185 ScDPAggData* GetChild();
187 #if DUMP_PIVOT_TABLE
188 void Dump(int nIndent) const;
189 #endif
192 // Row and grand total state, passed down (column total is at result member)
194 class ScDPRowTotals
196 ScDPAggData aRowTotal;
197 ScDPAggData aGrandTotal;
198 bool bIsInColRoot;
200 public:
201 ScDPRowTotals();
202 ~ScDPRowTotals();
204 ScDPAggData* GetRowTotal( long nMeasure );
205 ScDPAggData* GetGrandTotal( long nMeasure );
207 bool IsInColRoot() const { return bIsInColRoot; }
208 void SetInColRoot(bool bSet) { bIsInColRoot = bSet; }
211 // results for a hierarchy dimension
213 class ScDPResultDimension;
214 class ScDPDataDimension;
215 class ScDPDataMember;
217 #define SC_DPMEASURE_ALL -1
218 #define SC_DPMEASURE_ANY -2
220 struct ScDPParentDimData
222 const SCROW mnOrder; //! Ref
223 const ScDPDimension* mpParentDim; //! Ref
224 const ScDPLevel* mpParentLevel; //! Ref
225 const ScDPMember* mpMemberDesc; //! Ref
227 ScDPParentDimData();
228 ScDPParentDimData(SCROW nIndex, const ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember);
231 class ResultMembers final
233 std::unordered_map<SCROW, ScDPParentDimData> maMemberHash;
234 bool mbHasHideDetailsMember;
235 public:
236 const ScDPParentDimData* FindMember( SCROW nIndex ) const;
237 void InsertMember( ScDPParentDimData const & rNew );
238 bool IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
239 void SetHasHideDetailsMembers( bool b ) { mbHasHideDetailsMember = b; }
240 ResultMembers();
241 ~ResultMembers();
244 class LateInitParams
246 private:
247 const ::std::vector<ScDPDimension*>& mppDim;
248 const ::std::vector<ScDPLevel*>& mppLev;
250 bool const mbRow:1;
251 bool mbInitChild:1;
252 bool mbAllChildren:1;
253 public:
254 LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
255 bool bRow);
256 ~LateInitParams();
258 void SetInitChild( bool b ) { mbInitChild = b; }
259 void SetInitAllChildren( bool b ) { mbAllChildren = b; }
261 ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
262 ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];}
264 bool GetInitChild() const {return mbInitChild; }
265 bool GetInitAllChild() const { return mbAllChildren; }
266 bool IsRow() const { return mbRow; }
267 bool IsEnd( size_t nPos ) const ;
271 * The term 'measure' here roughly equals "data dimension" ?
273 class ScDPResultData
275 ScDPSource& mrSource;
276 //! keep things like measure lists here
278 std::vector<ScSubTotalFunc> maMeasureFuncs;
279 std::vector<css::sheet::DataPilotFieldReference> maMeasureRefs;
280 std::vector<css::sheet::DataPilotFieldOrientation> maMeasureRefOrients;
281 std::vector<OUString> maMeasureNames;
283 bool bLateInit:1;
284 bool bDataAtCol:1;
285 bool bDataAtRow:1;
287 //! add "displayed values" settings
288 mutable std::vector<std::unique_ptr<ResultMembers>> maDimMembers;
289 public:
290 ScDPResultData( ScDPSource& rSrc );
291 ~ScDPResultData();
293 void SetMeasureData(
294 std::vector<ScSubTotalFunc>& rFunctions,
295 std::vector<css::sheet::DataPilotFieldReference>& rRefs,
296 std::vector<css::sheet::DataPilotFieldOrientation>& rRefOrient,
297 std::vector<OUString>& rNames );
299 void SetDataLayoutOrientation( css::sheet::DataPilotFieldOrientation nOrient );
300 void SetLateInit( bool bSet );
302 long GetMeasureCount() const { return maMeasureFuncs.size(); }
303 ScSubTotalFunc GetMeasureFunction(long nMeasure) const;
304 OUString GetMeasureString(long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
305 OUString GetMeasureDimensionName(long nMeasure) const;
306 const css::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
307 css::sheet::DataPilotFieldOrientation GetMeasureRefOrient(long nMeasure) const;
309 bool IsLateInit() const { return bLateInit; }
311 long GetColStartMeasure() const;
312 long GetRowStartMeasure() const;
314 long GetCountForMeasure( long nMeas ) const { return (nMeas == SC_DPMEASURE_ALL) ? maMeasureFuncs.size() : 1; }
316 bool IsBaseForGroup( long nDim ) const; // any group
317 long GetGroupBase( long nGroupDim ) const;
318 bool IsNumOrDateGroup( long nDim ) const;
319 bool IsInGroup( SCROW nGroupDataId, long nGroupIndex,
320 const ScDPItemData& rBaseData, long nBaseIndex ) const;
321 bool HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
322 const ScDPItemData& rSecondData, long nSecondIndex ) const;
324 ResultMembers& GetDimResultMembers(long nDim, const ScDPDimension* pDim, ScDPLevel* pLevel) const;
326 const ScDPSource& GetSource() const { return mrSource;}
329 class ScDPResultMember
331 private:
332 const ScDPResultData* pResultData;
333 ScDPParentDimData const aParentDimData;
334 std::unique_ptr<ScDPResultDimension> pChildDimension;
335 std::unique_ptr<ScDPDataMember> pDataRoot;
336 bool bHasElements:1;
337 bool const bForceSubTotal:1;
338 bool bHasHiddenDetails:1;
339 bool bInitialized:1;
340 bool bAutoHidden:1;
341 ScDPAggData aColTotal; // to store column totals
343 sal_uInt16 nMemberStep; // step to show details
344 public:
345 ScDPResultMember(
346 const ScDPResultData* pData, const ScDPParentDimData& rParentDimData ); //! Ref
347 ScDPResultMember( const ScDPResultData* pData, bool bForceSub );
348 ~ScDPResultMember();
350 void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
351 const ::std::vector<ScDPLevel*>& ppLev,
352 size_t nPos,
353 ScDPInitState& rInitState,
354 bool bInitChild = true );
355 void LateInitFrom(
356 LateInitParams& rParams,
357 const ::std::vector< SCROW >& pItemData,
358 size_t nPos,
359 ScDPInitState& rInitState);
360 void CheckShowEmpty( bool bShow = false );
361 OUString GetName() const;
362 OUString GetDisplayName( bool bLocaleIndependent ) const;
364 ScDPItemData FillItemData() const;
365 bool IsValid() const;
366 bool IsVisible() const;
367 long GetSize(long nMeasure) const;
368 // bHasHiddenDetails is set only if the "show details" flag is off,
369 // and there was a child dimension to skip
370 bool HasHiddenDetails() const { return bHasHiddenDetails; }
371 bool IsSubTotalInTitle(long nMeasure) const;
373 long GetSubTotalCount( long* pUserSubStart = nullptr ) const;
375 bool IsNamedItem( SCROW nIndex ) const;
376 bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
378 void SetHasElements() { bHasElements = true; }
379 void SetAutoHidden() { bAutoHidden = true; }
381 void ProcessData( const ::std::vector<SCROW>& aChildMembers,
382 const ScDPResultDimension* pDataDim,
383 const ::std::vector<SCROW>& aDataMembers,
384 const ::std::vector<ScDPValue>& aValues );
385 void FillMemberResults(
386 css::uno::Sequence< css::sheet::MemberResult>* pSequences,
387 long& rPos, long nMeasure, bool bRoot, const OUString* pMemberName, const OUString* pMemberCaption );
389 void FillDataResults(
390 const ScDPResultMember* pRefMember,
391 ScDPResultFilterContext& rFilterCxt,
392 css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult> >& rSequence,
393 long nMeasure) const;
395 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
396 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
397 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
399 void SortMembers( ScDPResultMember* pRefMember );
400 void DoAutoShow( ScDPResultMember* pRefMember );
402 void ResetResults();
404 #if DUMP_PIVOT_TABLE
405 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
407 void Dump(int nIndent) const;
408 #endif
410 //! this will be removed!
411 const ScDPResultDimension* GetChildDimension() const { return pChildDimension.get(); }
412 ScDPResultDimension* GetChildDimension() { return pChildDimension.get(); }
414 ScDPDataMember* GetDataRoot() const { return pDataRoot.get(); }
416 const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref
417 const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref
418 const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref
419 SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
420 bool IsRoot() const { return GetParentLevel() == nullptr; }
421 SCROW GetDataId( ) const ;
422 ScDPAggData* GetColTotal( long nMeasure ) const;
424 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
427 class ScDPDataMember
429 private:
430 const ScDPResultData* pResultData;
431 const ScDPResultMember* pResultMember; //! Ref?
432 std::unique_ptr<ScDPDataDimension>
433 pChildDimension;
434 ScDPAggData aAggregate;
436 void UpdateValues( const ::std::vector<ScDPValue>& aValues, const ScDPSubTotalState& rSubState );
438 public:
439 ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes );
440 ~ScDPDataMember();
442 void InitFrom( const ScDPResultDimension* pDim );
444 OUString GetName() const;
445 bool IsVisible() const;
446 bool HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
448 bool IsNamedItem( SCROW nRow ) const;
449 bool HasHiddenDetails() const;
451 void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValue>& aValues,
452 const ScDPSubTotalState& rSubState );
453 bool HasError( long nMeasure, const ScDPSubTotalState& rSubState ) const;
454 double GetAggregate( long nMeasure, const ScDPSubTotalState& rSubState ) const;
455 const ScDPAggData* GetConstAggData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
456 ScDPAggData* GetAggData( long nMeasure, const ScDPSubTotalState& rSubState );
458 void FillDataRow(
459 const ScDPResultMember* pRefMember,
460 ScDPResultFilterContext& rFilterCxt,
461 css::uno::Sequence<css::sheet::DataResult>& rSequence,
462 long nMeasure, bool bIsSubTotalRow,
463 const ScDPSubTotalState& rSubState) const;
465 void UpdateDataRow( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
466 const ScDPSubTotalState& rSubState );
467 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
468 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
469 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent );
471 void SortMembers( ScDPResultMember* pRefMember );
472 void DoAutoShow( ScDPResultMember* pRefMember );
474 void ResetResults();
476 #if DUMP_PIVOT_TABLE
477 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
478 void Dump(int nIndent) const;
479 #endif
481 //! this will be removed!
482 const ScDPDataDimension* GetChildDimension() const { return pChildDimension.get(); }
483 ScDPDataDimension* GetChildDimension() { return pChildDimension.get(); }
486 typedef std::vector<ScDPDataMember*> ScDPDataMembers;
488 // result dimension contains only members
490 class ScDPResultDimension
492 public:
493 typedef std::vector<std::unique_ptr<ScDPResultMember>> MemberArray;
494 typedef std::map<SCROW, ScDPResultMember*> MemberHash;
495 private:
496 const ScDPResultData* pResultData;
497 MemberArray maMemberArray;
498 MemberHash maMemberHash;
499 OUString aDimensionName; //! or ptr to IntDimension?
500 long nSortMeasure;
501 ScMemberSortOrder aMemberOrder; // used when sorted by measure
502 bool bIsDataLayout:1; //! or ptr to IntDimension?
503 bool bSortByData:1;
504 bool bSortAscending:1;
505 bool bAutoShow:1;
506 bool bAutoTopItems:1;
507 bool bInitialized:1;
508 long nAutoMeasure;
509 long nAutoCount;
511 ScDPResultMember* FindMember( SCROW iData ) const;
512 ScDPResultMember* AddMember( const ScDPParentDimData& aData );
513 ScDPResultMember* InsertMember( const ScDPParentDimData* pMemberData );
514 void InitWithMembers( LateInitParams& rParams,
515 const ::std::vector< SCROW >& pItemData,
516 size_t nPos,
517 ScDPInitState& rInitState );
518 public:
519 ScDPResultDimension( const ScDPResultData* pData );
520 ~ScDPResultDimension();
522 // allocates new members
523 void InitFrom(
524 const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
525 size_t nPos, ScDPInitState& rInitState, bool bInitChild = true );
526 void LateInitFrom( LateInitParams& rParams,
527 const ::std::vector< SCROW >& pItemData,
528 size_t nPos,
529 ScDPInitState& rInitState );
530 void CheckShowEmpty( bool bShow = false );
532 long GetSize(long nMeasure) const;
534 bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
536 // modifies existing members, allocates data dimensions
537 void ProcessData( const ::std::vector<SCROW>& aMembers,
538 const ScDPResultDimension* pDataDim,
539 const ::std::vector<SCROW>& aDataMembers,
540 const ::std::vector<ScDPValue>& aValues ) const; //! Test
541 void FillMemberResults( css::uno::Sequence<
542 css::sheet::MemberResult>* pSequences,
543 long nStart, long nMeasure );
545 void FillDataResults(
546 const ScDPResultMember* pRefMember,
547 ScDPResultFilterContext& rFilterCxt,
548 css::uno::Sequence<
549 css::uno::Sequence<
550 css::sheet::DataResult> >& rSequence,
551 long nMeasure) const;
553 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
554 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
555 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
557 void SortMembers( ScDPResultMember* pRefMember );
558 long GetSortedIndex( long nUnsorted ) const;
560 void DoAutoShow( ScDPResultMember* pRefMember );
562 void ResetResults();
564 // called for the reference dimension
565 ScDPDataMember* GetRowReferenceMember(
566 const ScDPRelativePos* pMemberPos, const OUString* pName,
567 const long* pRowIndexes, const long* pColIndexes ) const;
569 // uses row root member from ScDPRunningTotalState
570 static ScDPDataMember* GetColReferenceMember(
571 const ScDPRelativePos* pMemberPos, const OUString* pName,
572 long nRefDimPos, const ScDPRunningTotalState& rRunning );
574 #if DUMP_PIVOT_TABLE
575 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
576 void Dump(int nIndent) const;
577 #endif
579 // for ScDPDataDimension::InitFrom
580 long GetMemberCount() const;
581 const ScDPResultMember* GetMember(long n) const;
582 ScDPResultMember* GetMember(long n);
584 const ScMemberSortOrder& GetMemberOrder() const { return aMemberOrder; }
585 ScMemberSortOrder& GetMemberOrder() { return aMemberOrder; }
587 bool IsDataLayout() const { return bIsDataLayout; }
588 const OUString& GetName() const { return aDimensionName; }
590 bool IsSortByData() const { return bSortByData; }
591 bool IsSortAscending() const { return bSortAscending; }
592 long GetSortMeasure() const { return nSortMeasure; }
594 bool IsAutoShow() const { return bAutoShow; }
595 bool IsAutoTopItems() const { return bAutoTopItems; }
596 long GetAutoMeasure() const { return nAutoMeasure; }
597 long GetAutoCount() const { return nAutoCount; }
599 ScDPResultDimension* GetFirstChildDimension() const;
601 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
604 class ScDPDataDimension
606 private:
607 const ScDPResultData* pResultData;
608 const ScDPResultDimension* pResultDimension; // column
609 std::vector<std::unique_ptr<ScDPDataMember>> maMembers;
610 bool bIsDataLayout; //! or ptr to IntDimension?
612 public:
613 ScDPDataDimension( const ScDPResultData* pData );
614 ~ScDPDataDimension();
616 void InitFrom( const ScDPResultDimension* pDim ); // recursive
617 void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValue>& aValues,
618 const ScDPSubTotalState& rSubState );
619 void FillDataRow(
620 const ScDPResultDimension* pRefDim,
621 ScDPResultFilterContext& rFilterCxt,
622 css::uno::Sequence<css::sheet::DataResult>& rSequence,
623 long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState& rSubState) const;
625 void UpdateDataRow( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
626 const ScDPSubTotalState& rSubState ) const;
627 void UpdateRunningTotals( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
628 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
629 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const;
631 void SortMembers( ScDPResultDimension* pRefDim );
632 long GetSortedIndex( long nUnsorted ) const;
634 void DoAutoShow( ScDPResultDimension* pRefDim );
636 void ResetResults();
638 #if DUMP_PIVOT_TABLE
639 void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const;
640 void Dump(int nIndent) const;
641 #endif
643 long GetMemberCount() const;
644 const ScDPDataMember* GetMember(long n) const;
645 ScDPDataMember* GetMember(long n);
649 * This class collects visible members of each dimension and uses that
650 * information to create filtering criteria (e.g. for drill-down data).
652 class ScDPResultVisibilityData
654 public:
655 ScDPResultVisibilityData( ScDPSource* pSource);
656 ~ScDPResultVisibilityData();
658 void addVisibleMember(const OUString& rDimName, const ScDPItemData& rMemberItem);
659 void fillFieldFilters(::std::vector<ScDPFilteredCache::Criterion>& rFilters) const;
661 private:
662 struct MemberHash
664 size_t operator()(const ScDPItemData& r) const;
666 typedef std::unordered_set<ScDPItemData, MemberHash> VisibleMemberType;
667 typedef std::unordered_map<OUString, VisibleMemberType> DimMemberType;
668 DimMemberType maDimensions;
670 ScDPSource* mpSource;
673 #endif
675 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */