[Libreoffice-commits] .: sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Mar 23 21:13:13 PDT 2012
sc/inc/dpgroup.hxx | 33 +-----------
sc/source/core/data/dpdimsave.cxx | 4 -
sc/source/core/data/dpgroup.cxx | 99 ++++++-------------------------------
sc/source/filter/excel/xepivot.cxx | 2
4 files changed, 25 insertions(+), 113 deletions(-)
New commits:
commit 16bbecab811a7ea95439bcbdf99050f766d18a9d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sat Mar 24 00:13:30 2012 -0400
ScDPDateGroupHelper class is no more.
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index fadb830..fe5fd62 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -41,28 +41,6 @@
class ScDocument;
class SvNumberFormatter;
-// ScDPDateGroupHelper is used as part of ScDPGroupDimension (additional dim.)
-// or ScDPNumGroupDimension (innermost, replaces the original dim.).
-// Source index, name and result collection are stored at the parent.
-
-class ScDPDateGroupHelper
-{
- ScDPNumGroupInfo aNumInfo; // only start and end (incl. auto flags) are used
- sal_Int32 nDatePart; // single part
- long mnGroupDim;
-
-public:
- ScDPDateGroupHelper( const ScDPNumGroupInfo& rInfo, long nDim, sal_Int32 nPart );
- ~ScDPDateGroupHelper();
-
- void SetGroupDim(long nDim);
-
- sal_Int32 GetDatePart() const { return nDatePart; }
- const ScDPNumGroupInfo& GetNumInfo() const { return aNumInfo; }
-
- void FillColumnEntries(const ScDPCache* pCache, std::vector<SCROW>& rEntries) const;
-};
-
typedef ::std::vector<ScDPItemData> ScDPItemDataVec;
class ScDPGroupItem
@@ -90,9 +68,9 @@ class ScDPGroupDimension
long nSourceDim;
long nGroupDim;
rtl::OUString aGroupName;
- ScDPDateGroupHelper* pDateHelper;
ScDPGroupItemVec aItems;
- mutable ::std::vector< SCROW > maMemberEntries;
+ mutable std::vector<SCROW> maMemberEntries;
+ bool mbDateDimension;
public:
ScDPGroupDimension( long nSource, const String& rNewName );
ScDPGroupDimension( const ScDPGroupDimension& rOther );
@@ -112,12 +90,11 @@ public:
const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const; // rName = entry in group dim.
const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const;
- void MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
-
void DisposeData();
size_t GetItemCount() const { return aItems.size(); }
+ void SetDateDimension();
bool IsDateDimension() const;
};
@@ -126,8 +103,8 @@ typedef ::std::vector<ScDPGroupDimension> ScDPGroupDimensionVec;
class SC_DLLPUBLIC ScDPNumGroupDimension
{
mutable ScDPNumGroupInfo aGroupInfo; // settings
- ScDPDateGroupHelper* pDateHelper;
mutable std::vector<SCROW> maMemberEntries;
+ bool mbDateDimension;
public:
ScDPNumGroupDimension();
@@ -141,7 +118,7 @@ public:
const std::vector<SCROW>& GetNumEntries(SCCOL nSourceDim, const ScDPCache* pCache) const;
- void MakeDateHelper( const ScDPNumGroupInfo& rInfo, long nDim, sal_Int32 nPart );
+ void SetDateDimension();
void DisposeData();
diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx
index 30ddd74..80257be 100644
--- a/sc/source/core/data/dpdimsave.cxx
+++ b/sc/source/core/data/dpdimsave.cxx
@@ -379,7 +379,7 @@ void ScDPSaveGroupDimension::AddToData( ScDPGroupTableData& rData ) const
{
// date grouping
- aDim.MakeDateHelper( aDateInfo, nDatePart );
+ aDim.SetDateDimension();
}
else
{
@@ -459,7 +459,7 @@ void ScDPSaveNumGroupDimension::AddToData( ScDPGroupTableData& rData ) const
{
ScDPNumGroupDimension aDim( aGroupInfo ); // aGroupInfo: value grouping
if ( nDatePart )
- aDim.MakeDateHelper( aDateInfo, nSource, nDatePart ); // date grouping
+ aDim.SetDateDimension();
rData.SetNumGroupDimension( nSource, aDim );
}
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 5f8865c..a129fec 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -240,19 +240,6 @@ bool ScDPGroupDateFilter::match( const ScDPItemData & rCellData ) const
return false;
}
-// -----------------------------------------------------------------------
-
-ScDPDateGroupHelper::ScDPDateGroupHelper(
- const ScDPNumGroupInfo& rInfo, long nDim, sal_Int32 nPart ) :
- aNumInfo( rInfo ),
- nDatePart( nPart ),
- mnGroupDim(nDim)
-{
-}
-
-ScDPDateGroupHelper::~ScDPDateGroupHelper()
-{
-}
namespace {
@@ -304,18 +291,6 @@ bool isDateInGroup(const ScDPItemData& rGroupItem, const ScDPItemData& rChildIte
}
-void ScDPDateGroupHelper::SetGroupDim(long nDim)
-{
- mnGroupDim = nDim;
-}
-
-void ScDPDateGroupHelper::FillColumnEntries(const ScDPCache* pCache, std::vector<SCROW>& rEntries) const
-{
- pCache->GetGroupDimMemberIds(mnGroupDim, rEntries);
-}
-
-// -----------------------------------------------------------------------
-
ScDPGroupItem::ScDPGroupItem( const ScDPItemData& rName ) :
aGroupName( rName )
{
@@ -361,13 +336,12 @@ ScDPGroupDimension::ScDPGroupDimension( long nSource, const String& rNewName ) :
nSourceDim( nSource ),
nGroupDim( -1 ),
aGroupName( rNewName ),
- pDateHelper( NULL )
+ mbDateDimension(false)
{
}
ScDPGroupDimension::~ScDPGroupDimension()
{
- delete pDateHelper;
maMemberEntries.clear();
}
@@ -375,11 +349,9 @@ ScDPGroupDimension::ScDPGroupDimension( const ScDPGroupDimension& rOther ) :
nSourceDim( rOther.nSourceDim ),
nGroupDim( rOther.nGroupDim ),
aGroupName( rOther.aGroupName ),
- pDateHelper( NULL ),
- aItems( rOther.aItems )
+ aItems( rOther.aItems ),
+ mbDateDimension(rOther.mbDateDimension)
{
- if ( rOther.pDateHelper )
- pDateHelper = new ScDPDateGroupHelper( *rOther.pDateHelper );
}
ScDPGroupDimension& ScDPGroupDimension::operator=( const ScDPGroupDimension& rOther )
@@ -388,22 +360,10 @@ ScDPGroupDimension& ScDPGroupDimension::operator=( const ScDPGroupDimension& rOt
nGroupDim = rOther.nGroupDim;
aGroupName = rOther.aGroupName;
aItems = rOther.aItems;
-
- delete pDateHelper;
- if ( rOther.pDateHelper )
- pDateHelper = new ScDPDateGroupHelper( *rOther.pDateHelper );
- else
- pDateHelper = NULL;
-
+ mbDateDimension = rOther.mbDateDimension;
return *this;
}
-void ScDPGroupDimension::MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart )
-{
- delete pDateHelper;
- pDateHelper = new ScDPDateGroupHelper(rInfo, nGroupDim, nPart);
-}
-
void ScDPGroupDimension::AddItem( const ScDPGroupItem& rItem )
{
aItems.push_back( rItem );
@@ -412,8 +372,6 @@ void ScDPGroupDimension::AddItem( const ScDPGroupItem& rItem )
void ScDPGroupDimension::SetGroupDim( long nDim )
{
nGroupDim = nDim;
- if (pDateHelper)
- pDateHelper->SetGroupDim(nDim);
}
const std::vector<SCROW>& ScDPGroupDimension::GetColumnEntries(
@@ -422,12 +380,6 @@ const std::vector<SCROW>& ScDPGroupDimension::GetColumnEntries(
if (!maMemberEntries.empty())
return maMemberEntries;
- if (pDateHelper)
- {
- pDateHelper->FillColumnEntries(rCacheTable.getCache(), maMemberEntries);
- return maMemberEntries;
- }
-
rCacheTable.getCache()->GetGroupDimMemberIds(nGroupDim, maMemberEntries);
return maMemberEntries;
}
@@ -465,37 +417,30 @@ void ScDPGroupDimension::DisposeData()
maMemberEntries.clear();
}
+void ScDPGroupDimension::SetDateDimension()
+{
+ mbDateDimension = true;
+}
+
bool ScDPGroupDimension::IsDateDimension() const
{
- return pDateHelper != NULL;
+ return mbDateDimension;
}
// -----------------------------------------------------------------------
-ScDPNumGroupDimension::ScDPNumGroupDimension() :
- pDateHelper(NULL) {}
+ScDPNumGroupDimension::ScDPNumGroupDimension() : mbDateDimension(false) {}
ScDPNumGroupDimension::ScDPNumGroupDimension( const ScDPNumGroupInfo& rInfo ) :
- aGroupInfo(rInfo), pDateHelper(NULL) {}
+ aGroupInfo(rInfo), mbDateDimension(false) {}
ScDPNumGroupDimension::ScDPNumGroupDimension( const ScDPNumGroupDimension& rOther ) :
- aGroupInfo( rOther.aGroupInfo ),
- pDateHelper(NULL)
-{
- if ( rOther.pDateHelper )
- pDateHelper = new ScDPDateGroupHelper( *rOther.pDateHelper );
-}
+ aGroupInfo(rOther.aGroupInfo), mbDateDimension(rOther.mbDateDimension) {}
ScDPNumGroupDimension& ScDPNumGroupDimension::operator=( const ScDPNumGroupDimension& rOther )
{
aGroupInfo = rOther.aGroupInfo;
-
- delete pDateHelper;
- if ( rOther.pDateHelper )
- pDateHelper = new ScDPDateGroupHelper( *rOther.pDateHelper );
- else
- pDateHelper = NULL;
-
+ mbDateDimension = rOther.mbDateDimension;
return *this;
}
@@ -507,20 +452,17 @@ void ScDPNumGroupDimension::DisposeData()
bool ScDPNumGroupDimension::IsDateDimension() const
{
- return pDateHelper != NULL;
+ return mbDateDimension;
}
ScDPNumGroupDimension::~ScDPNumGroupDimension()
{
- delete pDateHelper;
}
-void ScDPNumGroupDimension::MakeDateHelper( const ScDPNumGroupInfo& rInfo, long nDim, sal_Int32 nPart )
+void ScDPNumGroupDimension::SetDateDimension()
{
- delete pDateHelper;
- pDateHelper = new ScDPDateGroupHelper(rInfo, nDim, nPart);
-
aGroupInfo.mbEnable = true; //! or query both?
+ mbDateDimension = true;
}
const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
@@ -529,13 +471,6 @@ const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
if (!maMemberEntries.empty())
return maMemberEntries;
- if (pDateHelper)
- {
- // Grouped by dates.
- pDateHelper->FillColumnEntries(pCache, maMemberEntries);
- return maMemberEntries;
- }
-
pCache->GetGroupDimMemberIds(nSourceDim, maMemberEntries);
return maMemberEntries;
}
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index df41e8c..ac0bef9 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -553,7 +553,7 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
// get the string collection with generated grouping elements
ScDPNumGroupDimension aTmpDim( rNumInfo );
if( nDatePart != 0 )
- aTmpDim.MakeDateHelper( rNumInfo, mnFieldIdx, nDatePart );
+ aTmpDim.SetDateDimension();
const std::vector<SCROW>& aMemberIds = aTmpDim.GetNumEntries(
static_cast<SCCOL>(nDim), pCache);
for ( size_t nIdx = 0 ; nIdx < aMemberIds.size(); nIdx++ )
More information about the Libreoffice-commits
mailing list