summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-03-23 23:49:43 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-03-23 23:49:43 -0400
commit7a1401e953e10194a7d693e590dc4e6c34a37ec4 (patch)
treeee6bf2c7302b8bb1d6d50842b9f65021fd2824de
parent2d3c700725736a5e59e60b80018582480674074d (diff)
More on avoiding use of date helper.
-rw-r--r--sc/inc/dpgroup.hxx4
-rw-r--r--sc/source/core/data/dpgroup.cxx50
2 files changed, 27 insertions, 27 deletions
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index eb4668542f81..fadb830c9cca 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -112,8 +112,6 @@ public:
const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const; // rName = entry in group dim.
const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const;
- const ScDPDateGroupHelper* GetDateHelper() const { return pDateHelper; }
-
void MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
void DisposeData();
@@ -141,8 +139,6 @@ public:
const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
- const ScDPDateGroupHelper* GetDateHelper() const { return pDateHelper; }
-
const std::vector<SCROW>& GetNumEntries(SCCOL nSourceDim, const ScDPCache* pCache) const;
void MakeDateHelper( const ScDPNumGroupInfo& rInfo, long nDim, sal_Int32 nPart );
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 872ddfcb145c..5f8865cd7c6d 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -722,6 +722,7 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
// Go through all the filtered field names and process them appropriately.
+ const ScDPCache* pCache = GetCacheTable().getCache();
vector<ScDPCacheTable::Criterion>::const_iterator itrEnd = rCriteria.end();
GroupFieldMapType::const_iterator itrGrpEnd = aGroupFieldIds.end();
for (vector<ScDPCacheTable::Criterion>::const_iterator itr = rCriteria.begin(); itr != itrEnd; ++itr)
@@ -740,20 +741,23 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
ScDPCacheTable::Criterion aCri;
aCri.mnFieldIndex = itr->mnFieldIndex;
const ScDPNumGroupDimension& rNumGrpDim = pNumGroups[itr->mnFieldIndex];
- const ScDPDateGroupHelper* pDateHelper = rNumGrpDim.GetDateHelper();
+ const ScDPNumGroupInfo* pNumInfo = pCache->GetNumGroupInfo(itr->mnFieldIndex);
- if (pDateHelper)
- {
- // grouped by dates.
- aCri.mpFilter.reset(
- new ScDPGroupDateFilter(
- pFilter->getMatchValue(), *pDoc->GetFormatTable()->GetNullDate(), pDateHelper->GetNumInfo()));
- }
- else
+ if (pNumInfo)
{
- // This dimension is grouped by numeric ranges.
- aCri.mpFilter.reset(
- new ScDPGroupNumFilter(pFilter->getMatchValue(), rNumGrpDim.GetInfo()));
+ if (rNumGrpDim.IsDateDimension())
+ {
+ // grouped by dates.
+ aCri.mpFilter.reset(
+ new ScDPGroupDateFilter(
+ pFilter->getMatchValue(), *pDoc->GetFormatTable()->GetNullDate(), *pNumInfo));
+ }
+ else
+ {
+ // This dimension is grouped by numeric ranges.
+ aCri.mpFilter.reset(
+ new ScDPGroupNumFilter(pFilter->getMatchValue(), *pNumInfo));
+ }
}
aNewCriteria.push_back(aCri);
@@ -770,16 +774,17 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
const ScDPGroupDimension* pGrpDim = itrGrp->second;
long nSrcDim = pGrpDim->GetSourceDim();
- const ScDPDateGroupHelper* pDateHelper = pGrpDim->GetDateHelper();
+ long nGrpDim = pGrpDim->GetGroupDim();
+ const ScDPNumGroupInfo* pNumInfo = pCache->GetNumGroupInfo(nGrpDim);
- if (pDateHelper)
+ if (pGrpDim->IsDateDimension() && pNumInfo)
{
// external number group
ScDPCacheTable::Criterion aCri;
aCri.mnFieldIndex = nSrcDim; // use the source dimension, not the group dimension.
aCri.mpFilter.reset(
new ScDPGroupDateFilter(
- pFilter->getMatchValue(), *pDoc->GetFormatTable()->GetNullDate(), pDateHelper->GetNumInfo()));
+ pFilter->getMatchValue(), *pDoc->GetFormatTable()->GetNullDate(), *pNumInfo));
aNewCriteria.push_back(aCri);
}
@@ -960,14 +965,14 @@ sal_Bool ScDPGroupTableData::IsNumOrDateGroup(long nDimension) const
if ( nDimension < nSourceCount )
{
return pNumGroups[nDimension].GetInfo().mbEnable ||
- pNumGroups[nDimension].GetDateHelper();
+ pNumGroups[nDimension].IsDateDimension();
}
for ( ScDPGroupDimensionVec::const_iterator aIter(aGroups.begin()); aIter != aGroups.end(); aIter++ )
{
const ScDPGroupDimension& rDim = *aIter;
if ( rDim.GetGroupDim() == nDimension )
- return ( rDim.GetDateHelper() != NULL );
+ return rDim.IsDateDimension();
}
return false;
@@ -981,8 +986,7 @@ sal_Bool ScDPGroupTableData::IsInGroup( const ScDPItemData& rGroupData, long nGr
const ScDPGroupDimension& rDim = *aIter;
if ( rDim.GetGroupDim() == nGroupIndex && rDim.GetSourceDim() == nBaseIndex )
{
- const ScDPDateGroupHelper* pGroupDateHelper = rDim.GetDateHelper();
- if ( pGroupDateHelper )
+ if (rDim.IsDateDimension())
{
return isDateInGroup(rGroupData, rBaseData);
}
@@ -1017,12 +1021,12 @@ sal_Bool ScDPGroupTableData::HasCommonElement( const ScDPItemData& rFirstData, l
}
if ( pFirstDim && pSecondDim )
{
- const ScDPDateGroupHelper* pFirstDateHelper = pFirstDim->GetDateHelper();
- const ScDPDateGroupHelper* pSecondDateHelper = pSecondDim->GetDateHelper();
- if ( pFirstDateHelper || pSecondDateHelper )
+ bool bFirstDate = pFirstDim->IsDateDimension();
+ bool bSecondDate = pSecondDim->IsDateDimension();
+ if (bFirstDate || bSecondDate)
{
// If one is a date group dimension, the other one must be, too.
- if ( !pFirstDateHelper || !pSecondDateHelper )
+ if (!bFirstDate || !bSecondDate)
{
OSL_FAIL( "mix of date and non-date groups" );
return true;