Kaydet (Commit) 4cc17f3b authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Remove hard-coded upper field limit from ScDPInitState.

This was going to cause trouble sooner or later....

Change-Id: I5eea2ba7b1cc4e358a0192b4863d79596549bad9
üst d5ea81b8
...@@ -51,35 +51,36 @@ class ScDPResultVisibilityData; ...@@ -51,35 +51,36 @@ class ScDPResultVisibilityData;
struct ScDPValueData; struct ScDPValueData;
class ScDPItemData; class ScDPItemData;
//
// Member names that are being processed for InitFrom/LateInitFrom
// (needed for initialization of grouped items)
//
/**
* Member names that are being processed for InitFrom/LateInitFrom (needed
* for initialization of grouped items).
*/
class ScDPInitState class ScDPInitState
{ {
long* pIndex; // array
SCROW* pData; // array
long nCount;
public: public:
ScDPInitState(); struct Member
~ScDPInitState(); {
long mnSrcIndex;
SCROW mnNameIndex;
Member(long nSrcIndex, SCROW nNameIndex);
};
void AddMember(long nSourceIndex, SCROW nMember);
void RemoveMember();
void AddMember( long nSourceIndex,SCROW nMember); const std::vector<Member>& GetMembers() const { return maMembers; }
void RemoveMember();
long GetCount() const { return nCount; } private:
const long* GetSource() const { return pIndex; } std::vector<Member> maMembers;
const SCROW* GetNameIds() const { return pData; }
}; };
typedef ::std::vector<sal_Int32> ScMemberSortOrder; typedef ::std::vector<sal_Int32> ScMemberSortOrder;
// /**
// selected subtotal information, passed down the dimensions * Select subtotal information, passed down the dimensions.
// */
struct ScDPSubTotalState struct ScDPSubTotalState
{ {
ScSubTotalFunc eColForce; ScSubTotalFunc eColForce;
......
...@@ -222,41 +222,21 @@ sal_Bool ScDPColMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 ) ...@@ -222,41 +222,21 @@ sal_Bool ScDPColMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending ); return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending );
} }
// ----------------------------------------------------------------------- ScDPInitState::Member::Member(long nSrcIndex, SCROW nNameIndex) :
mnSrcIndex(nSrcIndex), mnNameIndex(nNameIndex) {}
ScDPInitState::ScDPInitState() :
nCount( 0 )
{
pIndex = new long[SC_DP_MAX_FIELDS];
pData = new SCROW[SC_DP_MAX_FIELDS];
}
ScDPInitState::~ScDPInitState()
{
delete[] pIndex;
delete[] pData;
}
void ScDPInitState::AddMember( long nSourceIndex, SCROW nMember ) void ScDPInitState::AddMember( long nSourceIndex, SCROW nMember )
{ {
OSL_ENSURE( nCount < SC_DP_MAX_FIELDS, "too many InitState members" ); maMembers.push_back(Member(nSourceIndex, nMember));
if ( nCount < SC_DP_MAX_FIELDS )
{
pIndex[nCount] = nSourceIndex;
pData[nCount] = nMember;
++nCount;
}
} }
void ScDPInitState::RemoveMember() void ScDPInitState::RemoveMember()
{ {
OSL_ENSURE( nCount > 0, "RemoveColIndex without index" ); OSL_ENSURE(!maMembers.empty(), "ScDPInitState::RemoveMember: Attempt to remmove member while empty.");
if ( nCount > 0 ) if (!maMembers.empty())
--nCount; maMembers.pop_back();
} }
// -----------------------------------------------------------------------
static void lcl_DumpRow( const String& rType, const String& rName, const ScDPAggData* pAggData, static void lcl_DumpRow( const String& rType, const String& rName, const ScDPAggData* pAggData,
ScDocument* pDoc, ScAddress& rPos ) ScDocument* pDoc, ScAddress& rPos )
{ {
...@@ -2649,16 +2629,15 @@ sal_Bool ScDPGroupCompare::TestIncluded( const ScDPMember& rMember ) ...@@ -2649,16 +2629,15 @@ sal_Bool ScDPGroupCompare::TestIncluded( const ScDPMember& rMember )
//! get array of groups (or indexes) before loop? //! get array of groups (or indexes) before loop?
ScDPItemData aMemberData; ScDPItemData aMemberData;
rMember.FillItemData( aMemberData ); rMember.FillItemData( aMemberData );
long nInitCount = rInitState.GetCount();
const long* pInitSource = rInitState.GetSource();
const SCROW* pInitNames = rInitState.GetNameIds();
for (long nInitPos=0; nInitPos<nInitCount && bInclude; nInitPos++) const std::vector<ScDPInitState::Member>& rMemStates = rInitState.GetMembers();
std::vector<ScDPInitState::Member>::const_iterator it = rMemStates.begin(), itEnd = rMemStates.end();
for (; it != itEnd && bInclude; ++it)
{ {
if ( pResultData->GetGroupBase( pInitSource[nInitPos] ) == nDimSource ) if (pResultData->GetGroupBase(it->mnSrcIndex) == nDimSource)
{ {
bInclude = pResultData->IsInGroup( pInitNames[nInitPos], pInitSource[nInitPos], bInclude = pResultData->IsInGroup(
aMemberData, nDimSource ); it->mnNameIndex, it->mnSrcIndex, aMemberData, nDimSource);
} }
} }
} }
...@@ -2670,17 +2649,18 @@ sal_Bool ScDPGroupCompare::TestIncluded( const ScDPMember& rMember ) ...@@ -2670,17 +2649,18 @@ sal_Bool ScDPGroupCompare::TestIncluded( const ScDPMember& rMember )
//! get array of groups (or indexes) before loop? //! get array of groups (or indexes) before loop?
ScDPItemData aMemberData; ScDPItemData aMemberData;
rMember.FillItemData( aMemberData ); rMember.FillItemData( aMemberData );
long nInitCount = rInitState.GetCount(); const std::vector<ScDPInitState::Member>& rMemStates = rInitState.GetMembers();
const long* pInitSource = rInitState.GetSource(); std::vector<ScDPInitState::Member>::const_iterator it = rMemStates.begin(), itEnd = rMemStates.end();
/*const ScDPItemData* pInitNames = rInitState.GetNames();*/ for (; it != itEnd && bInclude; ++it)
const SCROW* pInitNames = rInitState.GetNameIds(); {
for (long nInitPos=0; nInitPos<nInitCount && bInclude; nInitPos++) if (pResultData->GetGroupBase(it->mnSrcIndex) == nGroupBase)
if ( pResultData->GetGroupBase( pInitSource[nInitPos] ) == nGroupBase )
{ {
// same base (hierarchy between the two groups is irrelevant) // same base (hierarchy between the two groups is irrelevant)
bInclude = pResultData->HasCommonElement( pInitNames[nInitPos], pInitSource[nInitPos], bInclude = pResultData->HasCommonElement(
aMemberData, nDimSource ); it->mnNameIndex, it->mnSrcIndex, aMemberData, nDimSource);
} }
}
} }
return bInclude; return bInclude;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment