diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-23 21:56:06 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-23 22:27:41 -0400 |
commit | 83a7d544b2d2f6969bdca52b18d99f8a64ed5afa (patch) | |
tree | 03c28845a0a2d5cecd4e91564f4de80dc276bf07 /sc/source | |
parent | 09bc4a1ed1f9b4a4661f16a8af5b2a58e30b9c8b (diff) |
Store the group type (aka date part) with the cache, and use that.
With this, we can phase out the "DateHelper" class...
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/dpcache.cxx | 32 | ||||
-rw-r--r-- | sc/source/core/data/dpdimsave.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/dpgroup.cxx | 7 |
3 files changed, 34 insertions, 11 deletions
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index f271ae38da8e..6908163a215f 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -62,10 +62,10 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; -ScDPCache::GroupItems::GroupItems() {} +ScDPCache::GroupItems::GroupItems() : mnGroupType(0) {} -ScDPCache::GroupItems::GroupItems(const ScDPNumGroupInfo& rInfo) : - maInfo(rInfo) {} +ScDPCache::GroupItems::GroupItems(const ScDPNumGroupInfo& rInfo, sal_Int32 nGroupType) : + maInfo(rInfo), mnGroupType(nGroupType) {} ScDPCache::Field::Field() : mnNumFormat(0) {} @@ -1019,7 +1019,7 @@ long ScDPCache::AppendGroupField() return static_cast<long>(maFields.size() + maGroupFields.size() - 1); } -void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo) +void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nGroupType) { if (nDim < 0) return; @@ -1027,7 +1027,7 @@ void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo) long nSourceCount = static_cast<long>(maFields.size()); if (nDim < nSourceCount) { - maFields.at(nDim).mpGroup.reset(new GroupItems(rNumInfo)); + maFields.at(nDim).mpGroup.reset(new GroupItems(rNumInfo, nGroupType)); return; } @@ -1037,6 +1037,7 @@ void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo) GroupItems& rGI = maGroupFields[nDim]; rGI.maItems.clear(); rGI.maInfo = rNumInfo; + rGI.mnGroupType = nGroupType; } } @@ -1132,6 +1133,27 @@ const ScDPNumGroupInfo* ScDPCache::GetNumGroupInfo(long nDim) const return NULL; } +sal_Int32 ScDPCache::GetGroupType(long nDim) const +{ + if (nDim < 0) + return 0; + + long nSourceCount = static_cast<long>(maFields.size()); + if (nDim < nSourceCount) + { + if (!maFields.at(nDim).mpGroup) + return 0; + + return maFields[nDim].mpGroup->mnGroupType; + } + + nDim -= nSourceCount; + if (nDim < static_cast<long>(maGroupFields.size())) + return maGroupFields.at(nDim).mnGroupType; + + return 0; +} + SCROW ScDPCache::GetOrder(long /*nDim*/, SCROW nIndex) const { return nIndex; diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx index f31399006d3f..30ddd74e68e9 100644 --- a/sc/source/core/data/dpdimsave.cxx +++ b/sc/source/core/data/dpdimsave.cxx @@ -357,7 +357,7 @@ void fillDateGroupDimension( } // Now, populate the group items in the cache. - rCache.ResetGroupItems(nGroupDim, rDateInfo); + rCache.ResetGroupItems(nGroupDim, rDateInfo, nDatePart); for (sal_Int32 nValue = nStart; nValue <= nEnd; ++nValue) rCache.SetGroupItem(nGroupDim, ScDPItemData(nDatePart, nValue)); @@ -408,7 +408,7 @@ void ScDPSaveGroupDimension::AddToCache(ScDPCache& rCache) const return; } - rCache.ResetGroupItems(nDim, aDateInfo); + rCache.ResetGroupItems(nDim, aDateInfo, 0); { ScDPSaveGroupItemVec::const_iterator it = aGroups.begin(), itEnd = aGroups.end(); for (; it != itEnd; ++it) @@ -541,7 +541,7 @@ void ScDPSaveNumGroupDimension::AddToCache(ScDPCache& rCache) const long nLoopCount = 0; double fLoop = aGroupInfo.mfStart; - rCache.ResetGroupItems(nDim, aGroupInfo); + rCache.ResetGroupItems(nDim, aGroupInfo, 0); // Use "less than" instead of "less or equal" for the loop - don't // create a group that consists only of the end value. Instead, the diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx index 3b9c7d6a109d..b2006a4494a0 100644 --- a/sc/source/core/data/dpgroup.cxx +++ b/sc/source/core/data/dpgroup.cxx @@ -901,16 +901,17 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon if (pDateHelper && pNumInfo) { + sal_Int32 nDatePart = pCache->GetGroupType(nColumn); const ScDPItemData* pData = pCache->GetItemDataById(nSourceDim, rItems[i]); if (pData->GetType() == ScDPItemData::Value) { SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); sal_Int32 nPartValue = ScDPUtil::getDatePartValue( - pData->GetValue(), *pNumInfo, pDateHelper->GetDatePart(), pFormatter); + pData->GetValue(), *pNumInfo, nDatePart, pFormatter); rtl::OUString aName = ScDPUtil::getDateGroupName( - pDateHelper->GetDatePart(), nPartValue, pFormatter, pNumInfo->mfStart, pNumInfo->mfEnd); + nDatePart, nPartValue, pFormatter, pNumInfo->mfStart, pNumInfo->mfEnd); - ScDPItemData aItem(pDateHelper->GetDatePart(), nPartValue); + ScDPItemData aItem(nDatePart, nPartValue); rItems[i] = pCache->GetIdByItemData(nColumn, aItem); } } |