diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-07 22:21:23 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-09 11:13:34 -0500 |
commit | 6553fc9dd2cd5986e5127804ba25ad7abf14235c (patch) | |
tree | bea87729b4705c91ab0554cd228d820817d177f6 /sc | |
parent | Properly display grouped range values for range-based grouping. (diff) | |
download | core-6553fc9dd2cd5986e5127804ba25ad7abf14235c.tar.gz core-6553fc9dd2cd5986e5127804ba25ad7abf14235c.zip |
Some adjustments.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/dpgroup.cxx | 50 | ||||
-rw-r--r-- | sc/source/core/data/dptabdat.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/dptabsrc.cxx | 17 |
3 files changed, 30 insertions, 39 deletions
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx index 2d175dae8e0e..1edf0516cc91 100644 --- a/sc/source/core/data/dpgroup.cxx +++ b/sc/source/core/data/dpgroup.cxx @@ -599,34 +599,34 @@ void ScDPGroupDimension::SetGroupDim( long nDim ) if (pDateHelper) pDateHelper->SetGroupDim(nDim); } -const std::vector< SCROW >& ScDPGroupDimension::GetColumnEntries( const ScDPCacheTable& rCacheTable, const std::vector< SCROW >& rOriginal ) const + +const std::vector<SCROW>& ScDPGroupDimension::GetColumnEntries( + const ScDPCacheTable& rCacheTable, const std::vector<SCROW>& rOriginal) const { - if ( maMemberEntries.empty() ) + if (!maMemberEntries.empty()) + return maMemberEntries; + + if (pDateHelper) { - if ( pDateHelper ) + pDateHelper->FillColumnEntries( + GetSourceDim(), const_cast<ScDPCache*>(rCacheTable.getCache()), maMemberEntries, rOriginal); + return maMemberEntries; + } + + for (size_t i = 0, n = rOriginal.size(); i < n; ++i) + { + const ScDPItemData* pItemData = rCacheTable.getCache()->GetItemDataById(nSourceDim, rOriginal[i]); + if (!pItemData || !GetGroupForData(*pItemData)) { - pDateHelper->FillColumnEntries( - GetSourceDim(), const_cast<ScDPCache*>(rCacheTable.getCache()), maMemberEntries, rOriginal); + // not in any group -> add as its own group + maMemberEntries.push_back(rOriginal[i]); } - else - { - for (size_t i =0; i < rOriginal.size( ); i ++) - { - const ScDPItemData* pItemData = rCacheTable.getCache()->GetItemDataById( (SCCOL)GetSourceDim(), rOriginal[i] ); - if ( !pItemData || !GetGroupForData( *pItemData ) ) - { - // not in any group -> add as its own group - maMemberEntries.push_back( rOriginal[i] ); - } - } + } - long nCount = aItems.size(); - for (long i=0; i<nCount; i++) - { - SCROW nNew = rCacheTable.getCache()->GetAdditionalItemID( aItems[i].GetName() ); - lcl_Insert ( (SCCOL)GetSourceDim(), rCacheTable.getCache(), maMemberEntries, nNew ); - } - } + for (size_t i = 0, n = aItems.size(); i < n; ++i) + { + SCROW nNew = rCacheTable.getCache()->GetAdditionalItemID(aItems[i].GetName()); + lcl_Insert ( (SCCOL)GetSourceDim(), rCacheTable.getCache(), maMemberEntries, nNew ); } return maMemberEntries; } @@ -635,8 +635,8 @@ const std::vector< SCROW >& ScDPGroupDimension::GetColumnEntries( const ScDPCac const ScDPGroupItem* ScDPGroupDimension::GetGroupForData( const ScDPItemData& rData ) const { - for ( ScDPGroupItemVec::const_iterator aIter(aItems.begin()); aIter != aItems.end(); aIter++ ) - if ( aIter->HasElement( rData ) ) + for (ScDPGroupItemVec::const_iterator aIter = aItems.begin(); aIter != aItems.end(); ++aIter) + if (aIter->HasElement(rData)) return &*aIter; return NULL; diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx index fd78b8bd9603..0fd0f1f0bf4a 100644 --- a/sc/source/core/data/dptabdat.cxx +++ b/sc/source/core/data/dptabdat.cxx @@ -281,7 +281,7 @@ const ScDPItemData* ScDPTableData::GetMemberByIndex( long nDim, long nIndex ) const ScDPItemData* ScDPTableData::GetMemberById( long nDim, long nId) { - return GetCacheTable().getCache()->GetItemDataById( (SCCOL) nDim, (SCROW)nId); + return GetCacheTable().getCache()->GetItemDataById(nDim, static_cast<SCROW>(nId)); } SCROW ScDPTableData::GetIdOfItemData( long nDim, const ScDPItemData& rData ) diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index bece98cd78b8..e22dda2bc6d3 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -2734,24 +2734,15 @@ const ScDPItemData& ScDPMember::GetItemData() const const ScDPItemData* ScDPSource::GetItemDataById(long nDim, long nId) { - long nSrcDim = GetSourceDim( nDim ); - const ScDPItemData* pItemData = GetData()->GetMemberById( nSrcDim, nId ); - if ( !pItemData ) - { //todo: - ScDPItemData item; - nId = GetCache()->GetAdditionalItemID( item ); - pItemData = GetData()->GetMemberById( nSrcDim, nId ); - } - return pItemData; + return GetData()->GetMemberById(nDim, nId); } -SCROW ScDPSource::GetMemberId( long nDim, const ScDPItemData& rData ) +SCROW ScDPSource::GetMemberId(long nDim, const ScDPItemData& rData) { - long nSrcDim = GetSourceDim( nDim ); - return GetCache()->GetIdByItemData( nSrcDim, rData ); + return GetCache()->GetIdByItemData(nDim, rData); } -const ScDPItemData* ScDPMembers::GetSrcItemDataByIndex( SCROW nIndex) +const ScDPItemData* ScDPMembers::GetSrcItemDataByIndex(SCROW nIndex) { const std::vector< SCROW >& memberIds = pSource->GetData()->GetColumnEntries( nDim ); if ( nIndex >= (long )(memberIds.size()) || nIndex < 0 ) |