diff options
-rw-r--r-- | sc/inc/dpcache.hxx | 6 | ||||
-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 |
4 files changed, 38 insertions, 13 deletions
diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx index 3e23f47008c3..68b1029edc5d 100644 --- a/sc/inc/dpcache.hxx +++ b/sc/inc/dpcache.hxx @@ -72,9 +72,10 @@ public: { ItemsType maItems; ScDPNumGroupInfo maInfo; + sal_Int32 mnGroupType; GroupItems(); - GroupItems(const ScDPNumGroupInfo& rInfo); + GroupItems(const ScDPNumGroupInfo& rInfo, sal_Int32 nGroupType); }; struct Field : boost::noncopyable @@ -132,11 +133,12 @@ public: SCROW GetIdByItemData(long nDim, const ScDPItemData& rItem) const; rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const; long AppendGroupField(); - void ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo); + void ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nGroupType); SCROW SetGroupItem(long nDim, const ScDPItemData& rData); void GetGroupDimMemberIds(long nDim, std::vector<SCROW>& rIds) const; void ClearGroupFields(); const ScDPNumGroupInfo* GetNumGroupInfo(long nDim) const; + sal_Int32 GetGroupType(long nDim) const; SCCOL GetDimensionIndex(const rtl::OUString& sName) const; sal_uLong GetNumberFormat( long nDim ) const; 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); } } |