bump product version to 4.1.6.2
[LibreOffice.git] / sc / inc / dptabres.hxx
blobe39b1da118b77e8fa9b306cdd76fe2320a105433
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 "dpmacros.hxx"
27 #include <tools/string.hxx>
28 #include <com/sun/star/sheet/MemberResult.hpp>
29 #include <com/sun/star/sheet/DataResult.hpp>
30 #include <com/sun/star/uno/Sequence.hxx>
32 #include <boost/unordered_map.hpp>
33 #include <boost/unordered_set.hpp>
34 #include <vector>
35 #include <memory>
36 #include <map>
38 namespace com { namespace sun { namespace star { namespace sheet {
39 struct DataPilotFieldReference;
40 } } } }
43 class ScAddress;
44 class ScDocument;
45 class ScDPSource;
46 class ScDPDimension;
47 class ScDPLevel;
48 class ScDPMember;
49 class ScDPAggData;
50 class ScDPResultMember;
51 class ScDPResultVisibilityData;
53 struct ScDPValue;
54 class ScDPItemData;
55 struct ScDPResultFilterContext;
57 /**
58 * Member names that are being processed for InitFrom/LateInitFrom (needed
59 * for initialization of grouped items).
61 class ScDPInitState
63 public:
64 struct Member
66 long mnSrcIndex;
67 SCROW mnNameIndex;
69 Member(long nSrcIndex, SCROW nNameIndex);
72 void AddMember(long nSourceIndex, SCROW nMember);
73 void RemoveMember();
75 const std::vector<Member>& GetMembers() const { return maMembers; }
77 private:
78 std::vector<Member> maMembers;
81 typedef ::std::vector<sal_Int32> ScMemberSortOrder;
83 /**
84 * Select subtotal information, passed down the dimensions.
86 struct ScDPSubTotalState
88 ScSubTotalFunc eColForce;
89 ScSubTotalFunc eRowForce;
90 long nColSubTotalFunc;
91 long nRowSubTotalFunc;
93 ScDPSubTotalState() :
94 eColForce( SUBTOTAL_FUNC_NONE ),
95 eRowForce( SUBTOTAL_FUNC_NONE ),
96 nColSubTotalFunc( -1 ),
97 nRowSubTotalFunc( -1 )
102 * indexes when calculating running totals
104 * Col/RowVisible: simple counts from 0 - without sort order applied
105 * - visible index (only used for running total / relative index)
107 * Col/RowSorted: with sort order applied - member index (used otherwise -
108 * so other members' children can be accessed).
110 class ScDPRunningTotalState
112 public:
113 typedef std::vector<long> IndexArray; /// array of long integers terminated by -1.
115 ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* pRowRoot );
117 ScDPResultMember* GetColResRoot() const { return pColResRoot; }
118 ScDPResultMember* GetRowResRoot() const { return pRowResRoot; }
120 const IndexArray& GetColVisible() const;
121 const IndexArray& GetColSorted() const;
122 const IndexArray& GetRowVisible() const;
123 const IndexArray& GetRowSorted() const;
125 void AddColIndex( long nVisible, long nSorted );
126 void AddRowIndex( long nVisible, long nSorted );
127 void RemoveColIndex();
128 void RemoveRowIndex();
130 private:
131 ScDPResultMember* pColResRoot;
132 ScDPResultMember* pRowResRoot;
134 mutable IndexArray maColVisible;
135 mutable IndexArray maColSorted;
136 mutable IndexArray maRowVisible;
137 mutable IndexArray maRowSorted;
140 struct ScDPRelativePos
142 long nBasePos; // simple count, without sort order applied
143 long nDirection;
145 ScDPRelativePos( long nBase, long nDir );
149 // aggregated data
150 //! separate header file?
153 // Possible values for the nCount member:
154 // (greater than 0 counts the collected values)
155 const long SC_DPAGG_EMPTY = 0; // empty during data collection
156 const long SC_DPAGG_DATA_ERROR = -1; // error during data collection
157 const long SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated
158 const long SC_DPAGG_RESULT_VALID = -3; // valid result calculated
159 const long SC_DPAGG_RESULT_ERROR = -4; // error in calculated result
161 class ScDPAggData
163 private:
164 double fVal;
165 double fAux;
166 long nCount;
167 ScDPAggData* pChild;
169 public:
170 ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY), pChild(NULL) {}
171 ~ScDPAggData() { delete pChild; }
173 void Update( const ScDPValue& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
174 void Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
175 bool IsCalculated() const;
177 double GetResult() const;
178 bool HasError() const;
179 bool HasData() const;
181 void SetResult( double fNew );
182 void SetEmpty( bool bSet );
183 void SetError();
185 double GetAuxiliary() const;
186 void SetAuxiliary( double fNew );
188 void Reset(); // also deletes children
190 const ScDPAggData* GetExistingChild() const { return pChild; }
191 ScDPAggData* GetChild();
193 #if DEBUG_PIVOT_TABLE
194 void Dump(int nIndent) const;
195 #endif
199 // Row and grand total state, passed down (column total is at result member)
202 class ScDPRowTotals
204 ScDPAggData aRowTotal;
205 ScDPAggData aGrandTotal;
206 bool bIsInColRoot;
208 public:
209 ScDPRowTotals();
210 ~ScDPRowTotals();
212 ScDPAggData* GetRowTotal( long nMeasure );
213 ScDPAggData* GetGrandTotal( long nMeasure );
215 bool IsInColRoot() const { return bIsInColRoot; }
216 void SetInColRoot(bool bSet) { bIsInColRoot = bSet; }
219 // --------------------------------------------------------------------
221 // results for a hierarchy dimension
224 class ScDPResultDimension;
225 class ScDPDataDimension;
226 class ScDPDataMember;
228 #define SC_DPMEASURE_ALL -1
229 #define SC_DPMEASURE_ANY -2
231 struct MemberHashIndexFunc : public std::unary_function< const SCROW &, size_t >
233 size_t operator() (const SCROW &rDataIndex) const { return rDataIndex; }
236 struct ScDPParentDimData
238 const SCROW mnOrder; //! Ref
239 const ScDPDimension* mpParentDim; //! Ref
240 const ScDPLevel* mpParentLevel; //! Ref
241 const ScDPMember* mpMemberDesc; //! Ref
243 ScDPParentDimData();
244 ScDPParentDimData(SCROW nIndex, const ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember);
247 typedef std::vector <ScDPParentDimData *> DimMemberArray;
248 typedef boost::unordered_map < SCROW, ScDPParentDimData *, MemberHashIndexFunc> DimMemberHash;
250 class ResultMembers
252 DimMemberHash maMemberHash;
253 bool mbHasHideDetailsMember;
254 public:
255 ScDPParentDimData* FindMember( SCROW nIndex ) const;
256 void InsertMember( ScDPParentDimData* pNew );
257 bool IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
258 void SetHasHideDetailsMembers( bool b ) { mbHasHideDetailsMember = b; }
259 ResultMembers();
260 virtual ~ResultMembers();
263 class LateInitParams
265 private:
266 const ::std::vector<ScDPDimension*>& mppDim;
267 const ::std::vector<ScDPLevel*>& mppLev;
269 bool mbRow:1;
270 bool mbInitChild:1;
271 bool mbAllChildren:1;
272 public:
273 LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
274 bool bRow, bool bInitChild = true, bool bAllChildren = false);
275 ~LateInitParams();
277 void SetInitChild( bool b ) { mbInitChild = b; }
278 void SetInitAllChildren( bool b ) { mbAllChildren = b; }
280 inline ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
281 inline ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];}
283 bool GetInitChild() const {return mbInitChild; }
284 bool GetInitAllChild() const { return mbAllChildren; }
285 bool IsRow() const { return mbRow; }
286 bool IsEnd( size_t nPos ) const ;
290 * The term 'measure' here roughly equals "data dimension" ?
292 class ScDPResultData
294 ScDPSource& mrSource;
295 //! keep things like measure lists here
297 std::vector<ScSubTotalFunc> maMeasureFuncs;
298 std::vector<com::sun::star::sheet::DataPilotFieldReference> maMeasureRefs;
299 std::vector<sal_uInt16> maMeasureRefOrients;
300 std::vector<OUString> maMeasureNames;
302 bool bLateInit:1;
303 bool bDataAtCol:1;
304 bool bDataAtRow:1;
306 //! add "displayed values" settings
307 mutable std::vector<ResultMembers*> maDimMembers;
308 public:
309 ScDPResultData( ScDPSource& rSrc );
310 ~ScDPResultData();
312 void SetMeasureData(
313 std::vector<ScSubTotalFunc>& rFunctions,
314 std::vector<com::sun::star::sheet::DataPilotFieldReference>& rRefs,
315 std::vector<sal_uInt16>& rRefOrient, std::vector<OUString>& rNames );
317 void SetDataLayoutOrientation( sal_uInt16 nOrient );
318 void SetLateInit( bool bSet );
320 long GetMeasureCount() const { return maMeasureFuncs.size(); }
321 ScSubTotalFunc GetMeasureFunction(long nMeasure) const;
322 OUString GetMeasureString(long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
323 OUString GetMeasureDimensionName(long nMeasure) const;
324 const ::com::sun::star::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
325 sal_uInt16 GetMeasureRefOrient(long nMeasure) const;
327 bool IsDataAtCol() const { return bDataAtCol; }
328 bool IsDataAtRow() const { return bDataAtRow; }
329 bool IsLateInit() const { return bLateInit; }
331 long GetColStartMeasure() const;
332 long GetRowStartMeasure() const;
334 long GetCountForMeasure( long nMeas ) const { return (nMeas == SC_DPMEASURE_ALL) ? maMeasureFuncs.size() : 1; }
336 bool IsBaseForGroup( long nDim ) const; // any group
337 long GetGroupBase( long nGroupDim ) const;
338 bool IsNumOrDateGroup( long nDim ) const;
339 bool IsInGroup( SCROW nGroupDataId, long nGroupIndex,
340 const ScDPItemData& rBaseData, long nBaseIndex ) const;
341 bool HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
342 const ScDPItemData& rSecondData, long nSecondIndex ) const;
344 ResultMembers* GetDimResultMembers(long nDim, ScDPDimension* pDim, ScDPLevel* pLevel) const;
346 const ScDPSource& GetSource() const;
350 class ScDPResultMember
352 private:
353 const ScDPResultData* pResultData;
354 ScDPParentDimData aParentDimData;
355 ScDPResultDimension* pChildDimension;
356 ScDPDataMember* pDataRoot;
357 bool bHasElements:1;
358 bool bForceSubTotal:1;
359 bool bHasHiddenDetails:1;
360 bool bInitialized:1;
361 bool bAutoHidden:1;
362 ScDPAggData aColTotal; // to store column totals
364 sal_uInt16 nMemberStep; // step to show details
365 public:
366 ScDPResultMember(
367 const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, bool bForceSub ); //! Ref
368 ScDPResultMember( const ScDPResultData* pData, bool bForceSub );
369 ~ScDPResultMember();
371 void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
372 const ::std::vector<ScDPLevel*>& ppLev,
373 size_t nPos,
374 ScDPInitState& rInitState,
375 bool bInitChild = true );
376 void LateInitFrom(
377 LateInitParams& rParams,
378 const ::std::vector< SCROW >& pItemData,
379 size_t nPos,
380 ScDPInitState& rInitState);
381 void CheckShowEmpty( bool bShow = false );
382 OUString GetName() const;
383 OUString GetDisplayName() const;
385 void FillItemData( ScDPItemData& rData ) const;
386 bool IsValid() const;
387 bool IsVisible() const;
388 long GetSize(long nMeasure) const;
389 bool HasHiddenDetails() const;
390 bool IsSubTotalInTitle(long nMeasure) const;
392 long GetSubTotalCount( long* pUserSubStart = NULL ) const;
394 bool IsNamedItem( SCROW nIndex ) const;
395 bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
397 void SetHasElements() { bHasElements = true; }
398 void SetAutoHidden() { bAutoHidden = true; }
400 void ProcessData( const ::std::vector<SCROW>& aChildMembers,
401 const ScDPResultDimension* pDataDim,
402 const ::std::vector<SCROW>& aDataMembers,
403 const ::std::vector<ScDPValue>& aValues );
404 void FillMemberResults(
405 com::sun::star::uno::Sequence<
406 com::sun::star::sheet::MemberResult>* pSequences,
407 long& rPos, long nMeasure, bool bRoot, const OUString* pMemberName, const OUString* pMemberCaption );
409 void FillDataResults(
410 const ScDPResultMember* pRefMember, ScDPResultFilterContext& rFilterCxt,
411 com::sun::star::uno::Sequence<
412 com::sun::star::uno::Sequence<
413 com::sun::star::sheet::DataResult> >& rSequence,
414 long nMeasure) const;
416 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
417 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
418 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
420 void SortMembers( ScDPResultMember* pRefMember );
421 void DoAutoShow( ScDPResultMember* pRefMember );
423 void ResetResults();
425 #if DEBUG_PIVOT_TABLE
426 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
428 void Dump(int nIndent) const;
429 #endif
431 //! this will be removed!
432 const ScDPResultDimension* GetChildDimension() const { return pChildDimension; }
433 ScDPResultDimension* GetChildDimension() { return pChildDimension; }
435 ScDPDataMember* GetDataRoot() const { return pDataRoot; }
437 const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref
438 const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref
439 const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref
440 SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
441 bool IsRoot() const { return GetParentLevel() == NULL; }
442 SCROW GetDataId( ) const ;
443 ScDPAggData* GetColTotal( long nMeasure ) const;
445 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
448 class ScDPDataMember
450 private:
451 const ScDPResultData* pResultData;
452 const ScDPResultMember* pResultMember; //! Ref?
453 ScDPDataDimension* pChildDimension;
454 ScDPAggData aAggregate;
456 void UpdateValues( const ::std::vector<ScDPValue>& aValues, const ScDPSubTotalState& rSubState );
458 public:
459 ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes );
460 ~ScDPDataMember();
462 void InitFrom( const ScDPResultDimension* pDim );
464 OUString GetName() const;
465 bool IsVisible() const;
466 bool HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
468 bool IsNamedItem( SCROW nRow ) const;
469 bool HasHiddenDetails() const;
471 void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValue>& aValues,
472 const ScDPSubTotalState& rSubState );
473 bool HasError( long nMeasure, const ScDPSubTotalState& rSubState ) const;
474 double GetAggregate( long nMeasure, const ScDPSubTotalState& rSubState ) const;
475 const ScDPAggData* GetConstAggData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
476 ScDPAggData* GetAggData( long nMeasure, const ScDPSubTotalState& rSubState );
478 void FillDataRow(
479 const ScDPResultMember* pRefMember,
480 ScDPResultFilterContext& rFilterCxt,
481 com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
482 long nMeasure, bool bIsSubTotalRow,
483 const ScDPSubTotalState& rSubState) const;
485 void UpdateDataRow( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
486 const ScDPSubTotalState& rSubState );
487 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, bool bIsSubTotalRow,
488 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
489 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent );
491 void SortMembers( ScDPResultMember* pRefMember );
492 void DoAutoShow( ScDPResultMember* pRefMember );
494 void ResetResults();
496 #if DEBUG_PIVOT_TABLE
497 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
498 void Dump(int nIndent) const;
499 #endif
501 //! this will be removed!
502 const ScDPDataDimension* GetChildDimension() const { return pChildDimension; }
503 ScDPDataDimension* GetChildDimension() { return pChildDimension; }
506 typedef std::vector<ScDPDataMember*> ScDPDataMembers;
509 // result dimension contains only members
511 class ScDPResultDimension
513 public:
514 typedef std::vector<ScDPResultMember*> MemberArray;
515 typedef std::map<SCROW, ScDPResultMember*> MemberHash;
516 private:
517 const ScDPResultData* pResultData;
518 MemberArray maMemberArray;
519 MemberHash maMemberHash;
520 OUString aDimensionName; //! or ptr to IntDimension?
521 long nSortMeasure;
522 ScMemberSortOrder aMemberOrder; // used when sorted by measure
523 bool bIsDataLayout:1; //! or ptr to IntDimension?
524 bool bSortByData:1;
525 bool bSortAscending:1;
526 bool bAutoShow:1;
527 bool bAutoTopItems:1;
528 bool bInitialized:1;
529 long nAutoMeasure;
530 long nAutoCount;
532 ScDPResultMember* FindMember( SCROW iData ) const;
533 ScDPResultMember* AddMember( const ScDPParentDimData& aData );
534 ScDPResultMember* InsertMember( ScDPParentDimData* pMemberData );
535 void InitWithMembers( LateInitParams& rParams,
536 const ::std::vector< SCROW >& pItemData,
537 size_t nPos,
538 ScDPInitState& rInitState );
539 public:
540 ScDPResultDimension( const ScDPResultData* pData );
541 ~ScDPResultDimension();
543 // allocates new members
544 void InitFrom(
545 const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
546 size_t nPos, ScDPInitState& rInitState, bool bInitChild = true );
547 void LateInitFrom( LateInitParams& rParams,
548 const ::std::vector< SCROW >& pItemData,
549 size_t nPos,
550 ScDPInitState& rInitState );
551 void CheckShowEmpty( bool bShow = false );
553 long GetSize(long nMeasure) const;
555 bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
557 // modifies existing members, allocates data dimensions
558 void ProcessData( const ::std::vector<SCROW>& aMembers,
559 const ScDPResultDimension* pDataDim,
560 const ::std::vector<SCROW>& aDataMembers,
561 const ::std::vector<ScDPValue>& aValues ) const; //! Test
562 void FillMemberResults( com::sun::star::uno::Sequence<
563 com::sun::star::sheet::MemberResult>* pSequences,
564 long nStart, long nMeasure );
566 void FillDataResults(
567 const ScDPResultMember* pRefMember,
568 ScDPResultFilterContext& rFilterCxt,
569 com::sun::star::uno::Sequence<
570 com::sun::star::uno::Sequence<
571 com::sun::star::sheet::DataResult> >& rSequence,
572 long nMeasure) const;
574 void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
575 void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
576 ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
578 void SortMembers( ScDPResultMember* pRefMember );
579 long GetSortedIndex( long nUnsorted ) const;
581 void DoAutoShow( ScDPResultMember* pRefMember );
583 void ResetResults();
585 // called for the reference dimension
586 ScDPDataMember* GetRowReferenceMember(
587 const ScDPRelativePos* pMemberPos, const OUString* pName,
588 const long* pRowIndexes, const long* pColIndexes ) const;
590 // uses row root member from ScDPRunningTotalState
591 static ScDPDataMember* GetColReferenceMember(
592 const ScDPRelativePos* pMemberPos, const OUString* pName,
593 long nRefDimPos, const ScDPRunningTotalState& rRunning );
595 #if DEBUG_PIVOT_TABLE
596 void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
597 void Dump(int nIndent) const;
598 #endif
600 // for ScDPDataDimension::InitFrom
601 long GetMemberCount() const;
602 const ScDPResultMember* GetMember(long n) const;
603 ScDPResultMember* GetMember(long n);
605 const ScMemberSortOrder& GetMemberOrder() const { return aMemberOrder; }
606 ScMemberSortOrder& GetMemberOrder() { return aMemberOrder; }
608 bool IsDataLayout() const { return bIsDataLayout; }
609 const OUString& GetName() const { return aDimensionName; }
611 bool IsSortByData() const { return bSortByData; }
612 bool IsSortAscending() const { return bSortAscending; }
613 long GetSortMeasure() const { return nSortMeasure; }
615 bool IsAutoShow() const { return bAutoShow; }
616 bool IsAutoTopItems() const { return bAutoTopItems; }
617 long GetAutoMeasure() const { return nAutoMeasure; }
618 long GetAutoCount() const { return nAutoCount; }
620 ScDPResultDimension* GetFirstChildDimension() const;
622 void FillVisibilityData(ScDPResultVisibilityData& rData) const;
625 class ScDPDataDimension
627 private:
628 const ScDPResultData* pResultData;
629 const ScDPResultDimension* pResultDimension; // column
630 ScDPDataMembers maMembers;
631 bool bIsDataLayout; //! or ptr to IntDimension?
633 public:
634 ScDPDataDimension( const ScDPResultData* pData );
635 ~ScDPDataDimension();
637 void InitFrom( const ScDPResultDimension* pDim ); // recursive
638 void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValue>& aValues,
639 const ScDPSubTotalState& rSubState );
640 void FillDataRow(
641 const ScDPResultDimension* pRefDim,
642 ScDPResultFilterContext& rFilterCxt,
643 com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
644 long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState& rSubState) const;
646 void UpdateDataRow( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
647 const ScDPSubTotalState& rSubState ) const;
648 void UpdateRunningTotals( const ScDPResultDimension* pRefDim, long nMeasure, bool bIsSubTotalRow,
649 const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
650 ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const;
652 void SortMembers( ScDPResultDimension* pRefDim );
653 long GetSortedIndex( long nUnsorted ) const;
655 void DoAutoShow( ScDPResultDimension* pRefDim );
657 void ResetResults();
659 #if DEBUG_PIVOT_TABLE
660 void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const;
661 void Dump(int nIndent) const;
662 #endif
664 long GetMemberCount() const;
665 const ScDPDataMember* GetMember(long n) const;
666 ScDPDataMember* GetMember(long n);
669 // ----------------------------------------------------------------------------
672 * This class collects visible members of each dimension and uses that
673 * information to create filtering criteria (e.g. for drill-down data).
675 class ScDPResultVisibilityData
677 public:
678 ScDPResultVisibilityData( ScDPSource* pSource);
679 ~ScDPResultVisibilityData();
681 void addVisibleMember(const OUString& rDimName, const ScDPItemData& rMemberItem);
682 void fillFieldFilters(::std::vector<ScDPFilteredCache::Criterion>& rFilters) const;
684 private:
685 struct MemberHash
687 size_t operator()(const ScDPItemData& r) const;
689 typedef ::boost::unordered_set<ScDPItemData, MemberHash> VisibleMemberType;
690 typedef ::boost::unordered_map<OUString, VisibleMemberType, ScStringHashCode> DimMemberType;
691 DimMemberType maDimensions;
693 ScDPSource* mpSource;
696 #endif
698 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */