2010-10-27 06:43:08 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 11:07:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:29:37 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 12:29:37 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 12:29:37 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 12:29:37 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 12:29:37 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 12:29:37 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SC_DPTABRES_HXX
|
|
|
|
#define SC_DPTABRES_HXX
|
|
|
|
|
2009-10-15 17:05:16 -05:00
|
|
|
#include <svl/svarray.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#include <tools/string.hxx>
|
|
|
|
#include <com/sun/star/sheet/MemberResult.hpp>
|
|
|
|
#include <com/sun/star/sheet/DataResult.hpp>
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|
|
|
#include "global.hxx" // enum ScSubTotalFunc
|
2008-11-27 09:23:33 -06:00
|
|
|
#include "dpcachetable.hxx"
|
2011-02-05 17:56:21 -06:00
|
|
|
#include <boost/unordered_map.hpp>
|
|
|
|
#include <boost/unordered_set.hpp>
|
2007-01-25 04:03:28 -06:00
|
|
|
#include <vector>
|
2009-06-18 21:29:09 -05:00
|
|
|
#include <memory>
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
namespace com { namespace sun { namespace star { namespace sheet {
|
|
|
|
struct DataPilotFieldReference;
|
|
|
|
} } } }
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
class ScAddress;
|
|
|
|
class ScDocument;
|
|
|
|
class ScDPSource;
|
|
|
|
class ScDPDimension;
|
2008-11-27 09:23:33 -06:00
|
|
|
class ScDPDimensions;
|
2000-09-18 11:07:07 -05:00
|
|
|
class ScDPLevel;
|
|
|
|
class ScDPMember;
|
|
|
|
class ScDPAggData;
|
2004-06-04 07:55:24 -05:00
|
|
|
class ScDPResultMember;
|
2008-11-27 09:23:33 -06:00
|
|
|
class ScDPResultVisibilityData;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
struct ScDPValueData;
|
2010-02-03 10:59:00 -06:00
|
|
|
class ScDPItemData;
|
2004-08-03 05:29:48 -05:00
|
|
|
//
|
|
|
|
// Member names that are being processed for InitFrom/LateInitFrom
|
|
|
|
// (needed for initialization of grouped items)
|
|
|
|
//
|
|
|
|
|
|
|
|
class ScDPInitState
|
|
|
|
{
|
|
|
|
long* pIndex; // array
|
2010-02-03 10:59:00 -06:00
|
|
|
SCROW* pData; // array
|
2004-08-03 05:29:48 -05:00
|
|
|
long nCount;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScDPInitState();
|
|
|
|
~ScDPInitState();
|
|
|
|
|
2010-02-03 10:59:00 -06:00
|
|
|
void AddMember( long nSourceIndex,SCROW nMember);
|
2004-08-03 05:29:48 -05:00
|
|
|
void RemoveMember();
|
|
|
|
|
|
|
|
long GetCount() const { return nCount; }
|
|
|
|
const long* GetSource() const { return pIndex; }
|
2010-02-03 10:59:00 -06:00
|
|
|
const SCROW* GetNameIds() const { return pData; }
|
2010-04-09 04:22:18 -05:00
|
|
|
SCROW GetNameIdForIndex( long nIndexValue ) const;
|
2004-08-03 05:29:48 -05:00
|
|
|
};
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
typedef ::std::vector<sal_Int32> ScMemberSortOrder;
|
|
|
|
|
|
|
|
//
|
|
|
|
// selected subtotal information, passed down the dimensions
|
|
|
|
//
|
|
|
|
|
|
|
|
struct ScDPSubTotalState
|
|
|
|
{
|
|
|
|
ScSubTotalFunc eColForce;
|
|
|
|
ScSubTotalFunc eRowForce;
|
|
|
|
long nColSubTotalFunc;
|
|
|
|
long nRowSubTotalFunc;
|
|
|
|
|
|
|
|
ScDPSubTotalState() :
|
|
|
|
eColForce( SUBTOTAL_FUNC_NONE ),
|
|
|
|
eRowForce( SUBTOTAL_FUNC_NONE ),
|
|
|
|
nColSubTotalFunc( -1 ),
|
|
|
|
nRowSubTotalFunc( -1 )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// indexes when calculating running totals
|
|
|
|
// Col/RowVisible: simple counts from 0 - without sort order applied - visible index
|
|
|
|
// (only used for running total / relative index)
|
|
|
|
// Col/RowIndexes: with sort order applied - member index
|
|
|
|
// (used otherwise - so other members' children can be accessed)
|
|
|
|
//
|
|
|
|
|
|
|
|
class ScDPRunningTotalState
|
|
|
|
{
|
|
|
|
ScDPResultMember* pColResRoot;
|
|
|
|
ScDPResultMember* pRowResRoot;
|
|
|
|
long* pColVisible;
|
|
|
|
long* pColIndexes;
|
|
|
|
long* pRowVisible;
|
|
|
|
long* pRowIndexes;
|
|
|
|
long nColIndexPos;
|
|
|
|
long nRowIndexPos;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* pRowRoot );
|
|
|
|
~ScDPRunningTotalState();
|
|
|
|
|
|
|
|
ScDPResultMember* GetColResRoot() const { return pColResRoot; }
|
|
|
|
ScDPResultMember* GetRowResRoot() const { return pRowResRoot; }
|
|
|
|
|
|
|
|
const long* GetColVisible() const { return pColVisible; }
|
|
|
|
const long* GetColIndexes() const { return pColIndexes; }
|
|
|
|
const long* GetRowVisible() const { return pRowVisible; }
|
|
|
|
const long* GetRowIndexes() const { return pRowIndexes; }
|
|
|
|
|
|
|
|
void AddColIndex( long nVisible, long nSorted );
|
|
|
|
void AddRowIndex( long nVisible, long nSorted );
|
|
|
|
void RemoveColIndex();
|
|
|
|
void RemoveRowIndex();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScDPRelativePos
|
|
|
|
{
|
|
|
|
long nBasePos; // simple count, without sort order applied
|
|
|
|
long nDirection;
|
|
|
|
|
|
|
|
ScDPRelativePos( long nBase, long nDir );
|
|
|
|
};
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
//
|
|
|
|
// aggregated data
|
|
|
|
//! separate header file?
|
|
|
|
//
|
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
// Possible values for the nCount member:
|
|
|
|
// (greater than 0 counts the collected values)
|
|
|
|
const long SC_DPAGG_EMPTY = 0; // empty during data collection
|
|
|
|
const long SC_DPAGG_DATA_ERROR = -1; // error during data collection
|
|
|
|
const long SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated
|
|
|
|
const long SC_DPAGG_RESULT_VALID = -3; // valid result calculated
|
|
|
|
const long SC_DPAGG_RESULT_ERROR = -4; // error in calculated result
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
class ScDPAggData
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
double fVal;
|
2004-06-04 07:55:24 -05:00
|
|
|
double fAux;
|
2000-09-18 11:07:07 -05:00
|
|
|
long nCount;
|
|
|
|
ScDPAggData* pChild;
|
|
|
|
|
|
|
|
public:
|
2004-06-04 07:55:24 -05:00
|
|
|
ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY), pChild(NULL) {}
|
2000-09-18 11:07:07 -05:00
|
|
|
~ScDPAggData() { delete pChild; }
|
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
void Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
|
|
|
|
void Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsCalculated() const;
|
2004-06-04 07:55:24 -05:00
|
|
|
|
|
|
|
double GetResult() const;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool HasError() const;
|
|
|
|
sal_Bool HasData() const;
|
2004-06-04 07:55:24 -05:00
|
|
|
|
|
|
|
void SetResult( double fNew );
|
2011-01-17 06:20:22 -06:00
|
|
|
void SetEmpty( sal_Bool bSet );
|
2004-06-04 07:55:24 -05:00
|
|
|
void SetError();
|
|
|
|
|
|
|
|
double GetAuxiliary() const;
|
|
|
|
void SetAuxiliary( double fNew );
|
|
|
|
|
|
|
|
void Reset(); // also deletes children
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
const ScDPAggData* GetExistingChild() const { return pChild; }
|
|
|
|
ScDPAggData* GetChild();
|
|
|
|
};
|
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
//
|
|
|
|
// Row and grand total state, passed down (column total is at result member)
|
|
|
|
//
|
|
|
|
|
|
|
|
class ScDPRowTotals
|
|
|
|
{
|
|
|
|
ScDPAggData aRowTotal;
|
|
|
|
ScDPAggData aGrandTotal;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bIsInColRoot;
|
2004-06-04 07:55:24 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
ScDPRowTotals();
|
|
|
|
~ScDPRowTotals();
|
|
|
|
|
|
|
|
ScDPAggData* GetRowTotal( long nMeasure );
|
|
|
|
ScDPAggData* GetGrandTotal( long nMeasure );
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsInColRoot() const { return bIsInColRoot; }
|
|
|
|
void SetInColRoot(sal_Bool bSet) { bIsInColRoot = bSet; }
|
2004-06-04 07:55:24 -05:00
|
|
|
};
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// results for a hierarchy dimension
|
|
|
|
//
|
|
|
|
|
|
|
|
#define SC_DP_RES_GROW 16
|
|
|
|
|
|
|
|
class ScDPResultDimension;
|
|
|
|
class ScDPDataDimension;
|
|
|
|
class ScDPDataMember;
|
|
|
|
|
|
|
|
#define SC_DPMEASURE_ALL -1
|
|
|
|
#define SC_DPMEASURE_ANY -2
|
2010-02-03 10:59:00 -06:00
|
|
|
|
|
|
|
struct MemberHashIndexFunc : public std::unary_function< const SCROW &, size_t >
|
|
|
|
{
|
|
|
|
size_t operator() (const SCROW &rDataIndex) const { return rDataIndex; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class ScDPParentDimData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const SCROW mnOrder; //! Ref
|
|
|
|
const ScDPDimension* mpParentDim; //! Ref
|
|
|
|
const ScDPLevel* mpParentLevel; //! Ref
|
|
|
|
const ScDPMember* mpMemberDesc; //! Ref
|
|
|
|
|
|
|
|
ScDPParentDimData():mnOrder(-1), mpParentDim( NULL), mpParentLevel( NULL ), mpMemberDesc( NULL ){}
|
|
|
|
ScDPParentDimData( const SCROW nIndex, ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember ): mnOrder( nIndex ), mpParentDim( pDim), mpParentLevel( pLev ), mpMemberDesc( pMember ){}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector <ScDPParentDimData *> DimMemberArray;
|
2011-02-05 17:56:21 -06:00
|
|
|
typedef boost::unordered_map < SCROW, ScDPParentDimData *, MemberHashIndexFunc> DimMemberHash;
|
2010-02-03 10:59:00 -06:00
|
|
|
|
|
|
|
class ResultMembers
|
|
|
|
{
|
|
|
|
DimMemberHash maMemberHash;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool mbHasHideDetailsMember;
|
2010-02-03 10:59:00 -06:00
|
|
|
public:
|
|
|
|
ScDPParentDimData* FindMember( const SCROW& nIndex ) const;
|
|
|
|
void InsertMember( ScDPParentDimData* pNew );
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
|
|
|
|
void SetHasHideDetailsMembers( sal_Bool b ) { mbHasHideDetailsMember=b; }
|
2010-02-03 10:59:00 -06:00
|
|
|
ResultMembers();
|
|
|
|
virtual ~ResultMembers();
|
|
|
|
};
|
|
|
|
|
|
|
|
class LateInitParams
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const ::std::vector<ScDPDimension*>& mppDim;
|
|
|
|
const ::std::vector<ScDPLevel*>& mppLev;
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool mbRow;
|
|
|
|
sal_Bool mbInitChild;
|
|
|
|
sal_Bool mbAllChildren;
|
2010-02-03 10:59:00 -06:00
|
|
|
public:
|
|
|
|
LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
|
2011-03-10 15:55:21 -06:00
|
|
|
sal_Bool bRow, sal_Bool bInitChild = sal_True , sal_Bool bAllChildren = false);
|
2010-02-03 10:59:00 -06:00
|
|
|
~LateInitParams();
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
void SetInitChild( sal_Bool b ) { mbInitChild = b; }
|
|
|
|
void SetInitAllChildren( sal_Bool b ) { mbAllChildren = b; }
|
2010-02-03 10:59:00 -06:00
|
|
|
|
|
|
|
inline ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
|
|
|
|
inline ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];}
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
inline sal_Bool GetInitChild() const {return mbInitChild; }
|
|
|
|
inline sal_Bool GetInitAllChild() const { return mbAllChildren; }
|
|
|
|
inline sal_Bool IsRow() const { return mbRow; }
|
|
|
|
sal_Bool IsEnd( size_t nPos ) const ;
|
2010-02-03 10:59:00 -06:00
|
|
|
};
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
class ScDPResultData
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
ScDPSource* pSource; //! Ref
|
|
|
|
//! keep things like measure lists here
|
|
|
|
|
|
|
|
long nMeasCount;
|
|
|
|
ScSubTotalFunc* pMeasFuncs;
|
2004-06-04 07:55:24 -05:00
|
|
|
::com::sun::star::sheet::DataPilotFieldReference* pMeasRefs;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_uInt16* pMeasRefOrient;
|
2011-11-15 01:02:14 -06:00
|
|
|
std::vector<rtl::OUString> maMeasureNames;
|
2011-11-15 00:14:11 -06:00
|
|
|
bool bLateInit:1;
|
|
|
|
bool bDataAtCol:1;
|
|
|
|
bool bDataAtRow:1;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
//! add "displayed values" settings
|
2011-11-15 00:14:11 -06:00
|
|
|
mutable std::vector< ResultMembers* > mpDimMembers;
|
2000-09-18 11:07:07 -05:00
|
|
|
public:
|
|
|
|
ScDPResultData( ScDPSource* pSrc ); //! Ref
|
|
|
|
~ScDPResultData();
|
|
|
|
|
|
|
|
void SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
|
2004-06-04 07:55:24 -05:00
|
|
|
const ::com::sun::star::sheet::DataPilotFieldReference* pRefs,
|
2011-11-15 01:02:14 -06:00
|
|
|
const sal_uInt16* pRefOrient, std::vector<rtl::OUString>& rNames );
|
2011-01-17 06:20:22 -06:00
|
|
|
void SetDataLayoutOrientation( sal_uInt16 nOrient );
|
2011-11-15 00:14:11 -06:00
|
|
|
void SetLateInit( bool bSet );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
long GetMeasureCount() const { return nMeasCount; }
|
|
|
|
ScSubTotalFunc GetMeasureFunction(long nMeasure) const;
|
2011-11-15 01:10:33 -06:00
|
|
|
rtl::OUString GetMeasureString(long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
|
|
|
|
rtl::OUString GetMeasureDimensionName(long nMeasure) const;
|
2004-06-04 07:55:24 -05:00
|
|
|
const ::com::sun::star::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_uInt16 GetMeasureRefOrient(long nMeasure) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2011-11-15 00:14:11 -06:00
|
|
|
bool IsDataAtCol() const { return bDataAtCol; }
|
|
|
|
bool IsDataAtRow() const { return bDataAtRow; }
|
|
|
|
bool IsLateInit() const { return bLateInit; }
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
long GetColStartMeasure() const;
|
|
|
|
long GetRowStartMeasure() const;
|
|
|
|
|
|
|
|
long GetCountForMeasure( long nMeas ) const
|
|
|
|
{ return ( nMeas == SC_DPMEASURE_ALL ) ? nMeasCount : 1; }
|
2004-08-03 05:29:48 -05:00
|
|
|
|
2011-11-15 00:14:11 -06:00
|
|
|
bool IsBaseForGroup( long nDim ) const; // any group
|
2004-08-03 05:29:48 -05:00
|
|
|
long GetGroupBase( long nGroupDim ) const;
|
2011-11-15 00:14:11 -06:00
|
|
|
bool IsNumOrDateGroup( long nDim ) const;
|
|
|
|
bool IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
|
|
|
|
long nBaseDataId, long nBaseIndex ) const;
|
|
|
|
bool IsInGroup( SCROW nGroupDataId, long nGroupIndex,
|
|
|
|
const ScDPItemData& rBaseData, long nBaseIndex ) const;
|
|
|
|
bool HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
|
2004-08-03 05:29:48 -05:00
|
|
|
const ScDPItemData& rSecondData, long nSecondIndex ) const;
|
2009-06-18 21:29:09 -05:00
|
|
|
|
2010-02-03 10:59:00 -06:00
|
|
|
ResultMembers* GetDimResultMembers( long nDim , ScDPDimension* pDim , ScDPLevel* pLevel) const ;
|
|
|
|
|
2009-06-18 21:29:09 -05:00
|
|
|
const ScDPSource* GetSource() const;
|
2000-09-18 11:07:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ScDPResultMember
|
|
|
|
{
|
|
|
|
private:
|
2008-05-20 07:07:23 -05:00
|
|
|
const ScDPResultData* pResultData;
|
2010-02-03 10:59:00 -06:00
|
|
|
ScDPParentDimData aParentDimData;
|
2000-09-18 11:07:07 -05:00
|
|
|
ScDPResultDimension* pChildDimension;
|
|
|
|
ScDPDataMember* pDataRoot;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bHasElements;
|
|
|
|
sal_Bool bForceSubTotal;
|
|
|
|
sal_Bool bHasHiddenDetails;
|
|
|
|
sal_Bool bInitialized;
|
|
|
|
sal_Bool bAutoHidden;
|
2004-06-04 07:55:24 -05:00
|
|
|
ScDPAggData aColTotal; // to store column totals
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_uInt16 nMemberStep; // step to show details
|
2000-09-18 11:07:07 -05:00
|
|
|
public:
|
2010-02-03 10:59:00 -06:00
|
|
|
ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData,
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bForceSub ); //! Ref
|
|
|
|
ScDPResultMember( const ScDPResultData* pData, sal_Bool bForceSub );
|
2010-02-03 10:59:00 -06:00
|
|
|
~ScDPResultMember();
|
|
|
|
|
2008-05-20 07:07:23 -05:00
|
|
|
void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
|
2010-02-03 10:59:00 -06:00
|
|
|
const ::std::vector<ScDPLevel*>& ppLev,
|
|
|
|
size_t nPos,
|
|
|
|
ScDPInitState& rInitState,
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bInitChild = sal_True );
|
2010-02-03 10:59:00 -06:00
|
|
|
void LateInitFrom(
|
|
|
|
LateInitParams& rParams,
|
|
|
|
const ::std::vector< SCROW >& pItemData,
|
|
|
|
size_t nPos,
|
|
|
|
ScDPInitState& rInitState);
|
2011-03-10 15:55:21 -06:00
|
|
|
void CheckShowEmpty( sal_Bool bShow = false );
|
2000-09-18 11:07:07 -05:00
|
|
|
String GetName() const;
|
2004-08-03 05:29:48 -05:00
|
|
|
void FillItemData( ScDPItemData& rData ) const;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsValid() const;
|
|
|
|
sal_Bool IsVisible() const;
|
2000-09-18 11:07:07 -05:00
|
|
|
long GetSize(long nMeasure) const;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool HasHiddenDetails() const;
|
|
|
|
sal_Bool IsSubTotalInTitle(long nMeasure) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
long GetSubTotalCount( long* pUserSubStart = NULL ) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsNamedItem( SCROW nIndex ) const;
|
2010-02-03 10:59:00 -06:00
|
|
|
bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
void SetHasElements() { bHasElements = sal_True; }
|
|
|
|
void SetAutoHidden() { bAutoHidden = sal_True; }
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2010-02-03 10:59:00 -06:00
|
|
|
void ProcessData( const ::std::vector<SCROW>& aChildMembers,
|
|
|
|
const ScDPResultDimension* pDataDim,
|
|
|
|
const ::std::vector<SCROW>& aDataMembers,
|
|
|
|
const ::std::vector<ScDPValueData>& aValues );
|
2000-09-18 11:07:07 -05:00
|
|
|
void FillMemberResults( com::sun::star::uno::Sequence<
|
|
|
|
com::sun::star::sheet::MemberResult>* pSequences,
|
2011-01-17 06:20:22 -06:00
|
|
|
long& rPos, long nMeasure, sal_Bool bRoot,
|
2000-09-18 11:07:07 -05:00
|
|
|
const String* pMemberName,
|
|
|
|
const String* pMemberCaption );
|
|
|
|
|
|
|
|
void FillDataResults( const ScDPResultMember* pRefMember,
|
|
|
|
com::sun::star::uno::Sequence<
|
|
|
|
com::sun::star::uno::Sequence<
|
|
|
|
com::sun::star::sheet::DataResult> >& rSequence,
|
|
|
|
long& rRow, long nMeasure ) const;
|
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
|
|
|
|
void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
|
|
|
|
ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
|
|
|
|
|
|
|
|
void SortMembers( ScDPResultMember* pRefMember );
|
|
|
|
void DoAutoShow( ScDPResultMember* pRefMember );
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
void ResetResults( sal_Bool bRoot );
|
2004-06-04 07:55:24 -05:00
|
|
|
|
|
|
|
void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
//! this will be removed!
|
|
|
|
const ScDPResultDimension* GetChildDimension() const { return pChildDimension; }
|
|
|
|
ScDPResultDimension* GetChildDimension() { return pChildDimension; }
|
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
ScDPDataMember* GetDataRoot() const { return pDataRoot; }
|
|
|
|
|
2010-02-03 10:59:00 -06:00
|
|
|
const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref
|
|
|
|
const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref
|
|
|
|
const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref
|
|
|
|
inline SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
|
2011-01-17 06:20:22 -06:00
|
|
|
inline sal_Bool IsRoot() const { return GetParentLevel() == NULL; }
|
2010-02-03 10:59:00 -06:00
|
|
|
SCROW GetDataId( ) const ;
|
2004-06-04 07:55:24 -05:00
|
|
|
ScDPAggData* GetColTotal( long nMeasure ) const;
|
2008-11-27 09:23:33 -06:00
|
|
|
|
|
|
|
void FillVisibilityData(ScDPResultVisibilityData& rData) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScDPDataMember
|
|
|
|
{
|
|
|
|
private:
|
2008-05-20 07:07:23 -05:00
|
|
|
const ScDPResultData* pResultData;
|
2007-01-25 04:03:28 -06:00
|
|
|
const ScDPResultMember* pResultMember; //! Ref?
|
2000-09-18 11:07:07 -05:00
|
|
|
ScDPDataDimension* pChildDimension;
|
|
|
|
ScDPAggData aAggregate;
|
|
|
|
|
2008-05-20 07:07:23 -05:00
|
|
|
void UpdateValues( const ::std::vector<ScDPValueData>& aValues, const ScDPSubTotalState& rSubState );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
public:
|
2008-05-20 07:07:23 -05:00
|
|
|
ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes );
|
2000-09-18 11:07:07 -05:00
|
|
|
~ScDPDataMember();
|
|
|
|
|
2007-01-25 04:03:28 -06:00
|
|
|
void InitFrom( const ScDPResultDimension* pDim );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
String GetName() const;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsVisible() const;
|
|
|
|
sal_Bool HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsNamedItem( SCROW r ) const;
|
|
|
|
sal_Bool HasHiddenDetails() const;
|
2004-06-04 07:55:24 -05:00
|
|
|
|
2010-02-03 10:59:00 -06:00
|
|
|
void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValueData>& aValues,
|
|
|
|
const ScDPSubTotalState& rSubState );
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool HasError( long nMeasure, const ScDPSubTotalState& rSubState ) const;
|
2004-06-04 07:55:24 -05:00
|
|
|
double GetAggregate( long nMeasure, const ScDPSubTotalState& rSubState ) const;
|
|
|
|
const ScDPAggData* GetConstAggData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
|
|
|
|
ScDPAggData* GetAggData( long nMeasure, const ScDPSubTotalState& rSubState );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
void FillDataRow( const ScDPResultMember* pRefMember,
|
|
|
|
com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
|
2011-01-17 06:20:22 -06:00
|
|
|
long& rCol, long nMeasure, sal_Bool bIsSubTotalRow,
|
2004-06-04 07:55:24 -05:00
|
|
|
const ScDPSubTotalState& rSubState ) const;
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
void UpdateDataRow( const ScDPResultMember* pRefMember, long nMeasure, sal_Bool bIsSubTotalRow,
|
2004-06-04 07:55:24 -05:00
|
|
|
const ScDPSubTotalState& rSubState );
|
2011-01-17 06:20:22 -06:00
|
|
|
void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, sal_Bool bIsSubTotalRow,
|
2004-06-04 07:55:24 -05:00
|
|
|
const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
|
|
|
|
ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent );
|
|
|
|
|
|
|
|
void SortMembers( ScDPResultMember* pRefMember );
|
|
|
|
void DoAutoShow( ScDPResultMember* pRefMember );
|
|
|
|
|
|
|
|
void ResetResults();
|
|
|
|
|
|
|
|
void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
//! this will be removed!
|
|
|
|
const ScDPDataDimension* GetChildDimension() const { return pChildDimension; }
|
|
|
|
ScDPDataDimension* GetChildDimension() { return pChildDimension; }
|
|
|
|
};
|
|
|
|
|
|
|
|
//! replace PtrArr with 32-bit array ????
|
|
|
|
|
|
|
|
typedef ScDPDataMember* ScDPDataMemberPtr;
|
2007-02-27 04:55:52 -06:00
|
|
|
SV_DECL_PTRARR_DEL(ScDPDataMembers, ScDPDataMemberPtr, SC_DP_RES_GROW, SC_DP_RES_GROW)
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
|
|
|
|
// result dimension contains only members
|
|
|
|
|
|
|
|
class ScDPResultDimension
|
|
|
|
{
|
2007-01-25 04:03:28 -06:00
|
|
|
public :
|
2010-02-03 10:59:00 -06:00
|
|
|
typedef std::vector <ScDPResultMember *> MemberArray;
|
|
|
|
typedef std::map < SCROW , ScDPResultMember *> MemberHash;
|
2000-09-18 11:07:07 -05:00
|
|
|
private:
|
2010-02-03 10:59:00 -06:00
|
|
|
const ScDPResultData* pResultData;
|
2007-01-25 04:03:28 -06:00
|
|
|
MemberArray maMemberArray;
|
|
|
|
MemberHash maMemberHash;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bInitialized;
|
2004-06-04 07:55:24 -05:00
|
|
|
String aDimensionName; //! or ptr to IntDimension?
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bIsDataLayout; //! or ptr to IntDimension?
|
|
|
|
sal_Bool bSortByData;
|
|
|
|
sal_Bool bSortAscending;
|
2004-06-04 07:55:24 -05:00
|
|
|
long nSortMeasure;
|
|
|
|
ScMemberSortOrder aMemberOrder; // used when sorted by measure
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bAutoShow;
|
|
|
|
sal_Bool bAutoTopItems;
|
2004-06-04 07:55:24 -05:00
|
|
|
long nAutoMeasure;
|
|
|
|
long nAutoCount;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2010-02-03 10:59:00 -06:00
|
|
|
ScDPResultMember* FindMember( SCROW iData ) const;
|
|
|
|
ScDPResultMember* AddMember( const ScDPParentDimData& aData );
|
|
|
|
ScDPResultMember* InsertMember( ScDPParentDimData* pMemberData );
|
|
|
|
void InitWithMembers( LateInitParams& rParams,
|
|
|
|
const ::std::vector< SCROW >& pItemData,
|
|
|
|
size_t nPos,
|
|
|
|
ScDPInitState& rInitState );
|
2000-09-18 11:07:07 -05:00
|
|
|
public:
|
2010-02-03 10:59:00 -06:00
|
|
|
ScDPResultDimension( const ScDPResultData* pData );
|
|
|
|
~ScDPResultDimension();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// allocates new members
|
2008-05-20 07:07:23 -05:00
|
|
|
void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
|
2010-02-03 10:59:00 -06:00
|
|
|
const ::std::vector<ScDPLevel*>& ppLev,
|
|
|
|
size_t nPos,
|
2011-01-17 06:20:22 -06:00
|
|
|
ScDPInitState& rInitState , sal_Bool bInitChild = sal_True );
|
2010-02-03 10:59:00 -06:00
|
|
|
void LateInitFrom( LateInitParams& rParams,
|
|
|
|
const ::std::vector< SCROW >& pItemData,
|
|
|
|
size_t nPos,
|
|
|
|
ScDPInitState& rInitState );
|
2011-03-10 15:55:21 -06:00
|
|
|
void CheckShowEmpty( sal_Bool bShow = false );
|
2010-02-03 10:59:00 -06:00
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
long GetSize(long nMeasure) const;
|
|
|
|
|
2010-02-03 10:59:00 -06:00
|
|
|
bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
|
|
|
|
|
|
|
|
// modifies existing members, allocates data dimensions
|
|
|
|
void ProcessData( const ::std::vector<SCROW>& aMembers,
|
2008-05-20 07:07:23 -05:00
|
|
|
const ScDPResultDimension* pDataDim,
|
2010-02-03 10:59:00 -06:00
|
|
|
const ::std::vector<SCROW>& aDataMembers,
|
2008-05-20 07:07:23 -05:00
|
|
|
const ::std::vector<ScDPValueData>& aValues ) const; //! Test
|
2000-09-18 11:07:07 -05:00
|
|
|
void FillMemberResults( com::sun::star::uno::Sequence<
|
|
|
|
com::sun::star::sheet::MemberResult>* pSequences,
|
|
|
|
long nStart, long nMeasure );
|
|
|
|
|
|
|
|
void FillDataResults( const ScDPResultMember* pRefMember,
|
|
|
|
com::sun::star::uno::Sequence<
|
|
|
|
com::sun::star::uno::Sequence<
|
|
|
|
com::sun::star::sheet::DataResult> >& rSequence,
|
|
|
|
long nRow, long nMeasure ) const;
|
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
|
|
|
|
void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
|
|
|
|
ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
|
|
|
|
|
|
|
|
void SortMembers( ScDPResultMember* pRefMember );
|
|
|
|
long GetSortedIndex( long nUnsorted ) const;
|
|
|
|
|
|
|
|
void DoAutoShow( ScDPResultMember* pRefMember );
|
|
|
|
|
|
|
|
void ResetResults();
|
|
|
|
|
|
|
|
// called for the reference dimension
|
|
|
|
ScDPDataMember* GetRowReferenceMember( const ScDPRelativePos* pMemberPos, const String* pName,
|
|
|
|
const long* pRowIndexes, const long* pColIndexes ) const;
|
|
|
|
|
|
|
|
// uses row root member from ScDPRunningTotalState
|
|
|
|
static ScDPDataMember* GetColReferenceMember( const ScDPRelativePos* pMemberPos, const String* pName,
|
|
|
|
long nRefDimPos, const ScDPRunningTotalState& rRunning );
|
|
|
|
|
|
|
|
void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
// for ScDPDataDimension::InitFrom
|
|
|
|
long GetMemberCount() const;
|
2007-01-25 04:03:28 -06:00
|
|
|
const ScDPResultMember* GetMember(long n) const;
|
|
|
|
ScDPResultMember* GetMember(long n);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-06-04 07:55:24 -05:00
|
|
|
const ScMemberSortOrder& GetMemberOrder() const { return aMemberOrder; }
|
|
|
|
ScMemberSortOrder& GetMemberOrder() { return aMemberOrder; }
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsDataLayout() const { return bIsDataLayout; }
|
2004-06-04 07:55:24 -05:00
|
|
|
String GetName() const { return aDimensionName; }
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsSortByData() const { return bSortByData; }
|
|
|
|
sal_Bool IsSortAscending() const { return bSortAscending; }
|
2004-06-04 07:55:24 -05:00
|
|
|
long GetSortMeasure() const { return nSortMeasure; }
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool IsAutoShow() const { return bAutoShow; }
|
|
|
|
sal_Bool IsAutoTopItems() const { return bAutoTopItems; }
|
2004-06-04 07:55:24 -05:00
|
|
|
long GetAutoMeasure() const { return nAutoMeasure; }
|
|
|
|
long GetAutoCount() const { return nAutoCount; }
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
ScDPResultDimension* GetFirstChildDimension() const;
|
2008-11-27 09:23:33 -06:00
|
|
|
|
|
|
|
void FillVisibilityData(ScDPResultVisibilityData& rData) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScDPDataDimension
|
|
|
|
{
|
|
|
|
private:
|
2008-05-20 07:07:23 -05:00
|
|
|
const ScDPResultData* pResultData;
|
2007-01-25 04:03:28 -06:00
|
|
|
const ScDPResultDimension* pResultDimension; // column
|
2000-09-18 11:07:07 -05:00
|
|
|
ScDPDataMembers aMembers;
|
2011-01-17 06:20:22 -06:00
|
|
|
sal_Bool bIsDataLayout; //! or ptr to IntDimension?
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
public:
|
2008-05-20 07:07:23 -05:00
|
|
|
ScDPDataDimension( const ScDPResultData* pData );
|
2000-09-18 11:07:07 -05:00
|
|
|
~ScDPDataDimension();
|
|
|
|
|
2007-01-25 04:03:28 -06:00
|
|
|
void InitFrom( const ScDPResultDimension* pDim ); // recursive
|
2010-02-03 10:59:00 -06:00
|
|
|
void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValueData>& aValues,
|
|
|
|
const ScDPSubTotalState& rSubState );
|
2000-09-18 11:07:07 -05:00
|
|
|
void FillDataRow( const ScDPResultDimension* pRefDim,
|
|
|
|
com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
|
2011-01-17 06:20:22 -06:00
|
|
|
long nCol, long nMeasure, sal_Bool bIsSubTotalRow,
|
2004-06-04 07:55:24 -05:00
|
|
|
const ScDPSubTotalState& rSubState ) const;
|
|
|
|
|
2011-01-17 06:20:22 -06:00
|
|
|
void UpdateDataRow( const ScDPResultDimension* pRefDim, long nMeasure, sal_Bool bIsSubTotalRow,
|
2004-06-04 07:55:24 -05:00
|
|
|
const ScDPSubTotalState& rSubState ) const;
|
2011-01-17 06:20:22 -06:00
|
|
|
void UpdateRunningTotals( const ScDPResultDimension* pRefDim, long nMeasure, sal_Bool bIsSubTotalRow,
|
2004-06-04 07:55:24 -05:00
|
|
|
const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning,
|
|
|
|
ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const;
|
|
|
|
|
|
|
|
void SortMembers( ScDPResultDimension* pRefDim );
|
|
|
|
long GetSortedIndex( long nUnsorted ) const;
|
|
|
|
|
|
|
|
void DoAutoShow( ScDPResultDimension* pRefDim );
|
|
|
|
|
|
|
|
void ResetResults();
|
|
|
|
|
|
|
|
void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const;
|
|
|
|
|
|
|
|
long GetMemberCount() const;
|
|
|
|
ScDPDataMember* GetMember(long n) const;
|
2000-09-18 11:07:07 -05:00
|
|
|
};
|
|
|
|
|
2008-11-27 09:23:33 -06:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class collects visible members of each dimension and uses that
|
|
|
|
* information to create filtering criteria (e.g. for drill-down data).
|
|
|
|
*/
|
|
|
|
class ScDPResultVisibilityData
|
|
|
|
{
|
|
|
|
public:
|
2010-02-03 10:59:00 -06:00
|
|
|
ScDPResultVisibilityData( ScDPSource* pSource);
|
2008-11-27 09:23:33 -06:00
|
|
|
~ScDPResultVisibilityData();
|
|
|
|
|
|
|
|
void addVisibleMember(const String& rDimName, const ScDPItemData& rMemberItem);
|
|
|
|
void fillFieldFilters(::std::vector<ScDPCacheTable::Criterion>& rFilters) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct MemberHash
|
|
|
|
{
|
|
|
|
size_t operator()(const ScDPItemData& r) const;
|
|
|
|
};
|
2011-02-05 17:56:21 -06:00
|
|
|
typedef ::boost::unordered_set<ScDPItemData, MemberHash> VisibleMemberType;
|
|
|
|
typedef ::boost::unordered_map<String, VisibleMemberType, ScStringHashCode> DimMemberType;
|
2008-11-27 09:23:33 -06:00
|
|
|
DimMemberType maDimensions;
|
|
|
|
|
|
|
|
ScDPSource* mpSource;
|
|
|
|
};
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
#endif
|
|
|
|
|
2010-10-27 06:43:08 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|