[Libreoffice-commits] .: 12 commits - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Feb 28 21:30:21 PST 2011
sc/inc/dpcachetable.hxx | 26 +---
sc/inc/dpglobal.hxx | 2
sc/inc/dpgroup.hxx | 10 +
sc/inc/dpobject.hxx | 31 +----
sc/inc/dpsave.hxx | 6 -
sc/inc/dpsdbtab.hxx | 16 +-
sc/inc/dpshttab.hxx | 9 -
sc/inc/dptabdat.hxx | 6 -
sc/inc/dptablecache.hxx | 27 ++--
sc/inc/dptabsrc.hxx | 2
sc/source/core/data/dpcachetable.cxx | 52 ++++-----
sc/source/core/data/dpgroup.cxx | 31 ++---
sc/source/core/data/dpobject.cxx | 194 ++---------------------------------
sc/source/core/data/dpsave.cxx | 9 -
sc/source/core/data/dpsdbtab.cxx | 72 +-----------
sc/source/core/data/dpshttab.cxx | 55 +--------
sc/source/core/data/dptabdat.cxx | 16 --
sc/source/core/data/dptablecache.cxx | 119 ++++++++++-----------
sc/source/core/data/dptabsrc.cxx | 2
sc/source/filter/excel/xepivot.cxx | 3
sc/source/filter/xml/xmldpimp.cxx | 6 -
sc/source/ui/docshell/dbdocfun.cxx | 2
sc/source/ui/inc/dbfunc.hxx | 2
sc/source/ui/unoobj/dapiuno.cxx | 14 +-
sc/source/ui/view/cellsh2.cxx | 2
sc/source/ui/view/dbfunc3.cxx | 54 ---------
26 files changed, 211 insertions(+), 557 deletions(-)
New commits:
commit 6078dfb07c575616b75a448a45a0d2a8f08483df
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Mar 1 00:24:37 2011 -0500
Renamed ScDPTableDataCache to simply ScDPCache.
There were so many classes with 'DPTable' in them it was confusing.
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 6d04c56..b8ae177 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -50,7 +50,7 @@ namespace com { namespace sun { namespace star {
class Date;
class ScDPItemData;
-class ScDPTableDataCache;
+class ScDPCache;
class ScDocument;
class ScRange;
struct ScDPValueData;
@@ -121,13 +121,13 @@ public:
Criterion();
};
- ScDPCacheTable(ScDPTableDataCache* pCache);
+ ScDPCacheTable(ScDPCache* pCache);
~ScDPCacheTable();
sal_Int32 getRowSize() const;
sal_Int32 getColSize() const;
- const ScDPTableDataCache* getCache() const;
+ const ScDPCache* getCache() const;
/** Fill the internal table from the cell range provided. This function
assumes that the first row is the column header. */
@@ -169,13 +169,13 @@ public:
SCROW getOrder(long nDim, SCROW nIndex) const;
void clear();
bool empty() const;
- void setCache(ScDPTableDataCache* p);
+ void setCache(ScDPCache* p);
private:
ScDPCacheTable();
ScDPCacheTable(const ScDPCacheTable&);
- ScDPTableDataCache* getCache();
+ ScDPCache* getCache();
/**
* Check if a given row meets all specified criteria.
@@ -193,7 +193,7 @@ private:
has the index of 0. */
::std::vector<bool> maRowsVisible;
- ScDPTableDataCache* mpCache;
+ ScDPCache* mpCache;
};
#endif
diff --git a/sc/inc/dpglobal.hxx b/sc/inc/dpglobal.hxx
index 2fe184f..7005a4f 100644
--- a/sc/inc/dpglobal.hxx
+++ b/sc/inc/dpglobal.hxx
@@ -126,7 +126,7 @@ private:
double fValue;
BYTE mbFlag;
- friend class ScDPTableDataCache;
+ friend class ScDPCache;
public:
ScDPItemData() : nNumFormat( 0 ), fValue(0.0), mbFlag( 0 ){}
ScDPItemData( ULONG nNF, const String & rS, double fV, BYTE bF ):nNumFormat(nNF), aString(rS), fValue(fV), mbFlag( bF ){}
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index f4e11a0..0d0f95e 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -75,7 +75,7 @@ public:
const ScDPNumGroupInfo& GetNumInfo() const { return aNumInfo; }
void FillColumnEntries(
- SCCOL nSourceDim, const ScDPTableDataCache* pCahe , std::vector<SCROW>& rEntries,
+ SCCOL nSourceDim, const ScDPCache* pCahe , std::vector<SCROW>& rEntries,
const std::vector<SCROW>& rOriginal) const;
};
@@ -166,7 +166,7 @@ public:
const ScDPDateGroupHelper* GetDateHelper() const { return pDateHelper; }
const std::vector<SCROW>& GetNumEntries(
- SCCOL nSourceDim, const ScDPTableDataCache* pCache,
+ SCCOL nSourceDim, const ScDPCache* pCache,
const std::vector< SCROW >& rOriginal) const;
void MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index b98fb21..3b02841 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -61,7 +61,7 @@ struct ScImportSourceDesc
bNative == rOther.bNative &&
mpDoc == rOther.mpDoc; }
- ScDPTableDataCache* CreateCache() const;
+ ScDPCache* CreateCache() const;
};
class ScDatabaseDPData : public ScDPTableData
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 1eb12e8..662e8ca 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -78,7 +78,7 @@ public:
const ScQueryParam& GetQueryParam() const;
bool operator== ( const ScSheetSourceDesc& rOther ) const;
- ScDPTableDataCache* CreateCache() const;
+ ScDPCache* CreateCache() const;
/**
* Check the sanity of the data source range.
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index b797608..6af1f34 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -42,7 +42,11 @@
struct ScQueryParam;
-class SC_DLLPUBLIC ScDPTableDataCache
+/**
+ * This class represents the cached data part of the datapilot cache table
+ * implementation.
+ */
+class SC_DLLPUBLIC ScDPCache
{
friend class ScDPCacheTable;
public:
@@ -96,10 +100,10 @@ public:
const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
- bool operator== ( const ScDPTableDataCache& r ) const;
+ bool operator== ( const ScDPCache& r ) const;
- ScDPTableDataCache(ScDocument* pDoc);
- virtual ~ScDPTableDataCache();
+ ScDPCache(ScDocument* pDoc);
+ virtual ~ScDPCache();
private:
SCROW GetOrder( long nDim, SCROW nIndex ) const;
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index d4e8a60..a145c26 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -174,7 +174,7 @@ public:
long GetDataDimensionCount();
ScDPDimension* GetDataDimension(long nIndex);
String GetDataDimName(long nIndex);
- const ScDPTableDataCache* GetCache();
+ const ScDPCache* GetCache();
const ScDPItemData* GetItemDataById( long nDim, long nId );
long GetDataLayoutDim(){ return pData->GetColumnCount(); }
SCROW GetMemberId( long nDim, const ScDPItemData& rData );
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 5f292b1..53227eb 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -158,7 +158,7 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
-ScDPCacheTable::ScDPCacheTable(ScDPTableDataCache* pCache) :
+ScDPCacheTable::ScDPCacheTable(ScDPCache* pCache) :
mpCache(pCache)
{
}
@@ -411,7 +411,7 @@ bool ScDPCacheTable::empty() const
return mpCache == NULL || maFieldEntries.empty();
}
-void ScDPCacheTable::setCache(ScDPTableDataCache* p)
+void ScDPCacheTable::setCache(ScDPCache* p)
{
delete mpCache;
mpCache = p;
@@ -438,12 +438,12 @@ bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCr
return true;
}
-const ScDPTableDataCache* ScDPCacheTable::getCache() const
+const ScDPCache* ScDPCacheTable::getCache() const
{
return mpCache;
}
-ScDPTableDataCache* ScDPCacheTable::getCache()
+ScDPCache* ScDPCacheTable::getCache()
{
return mpCache;
}
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index d612cb6..4a514b4 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -80,7 +80,7 @@ const sal_Int32 SC_DP_DATE_LAST = 10000;
// ============================================================================
namespace
{
- BOOL lcl_Search( SCCOL nSourceDim, const ScDPTableDataCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
+ BOOL lcl_Search( SCCOL nSourceDim, const ScDPCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
{
rIndex = vIdx.size();
BOOL bFound = FALSE;
@@ -112,7 +112,7 @@ namespace
return bFound;
}
- void lcl_Insert( SCCOL nSourceDim, const ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, SCROW nNew )
+ void lcl_Insert( SCCOL nSourceDim, const ScDPCache* pCache , std::vector< SCROW >& vIdx, SCROW nNew )
{
SCROW nIndex = 0;
if ( !lcl_Search( nSourceDim, pCache, vIdx, nNew ,nIndex ) )
@@ -120,10 +120,10 @@ namespace
}
template<bool bUpdateData>
- SCROW lcl_InsertValue(SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData);
+ SCROW lcl_InsertValue(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData);
template<>
- SCROW lcl_InsertValue<false>(SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
+ SCROW lcl_InsertValue<false>(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
{
SCROW nNewID = pCache->GetAdditionalItemID(rData);
lcl_Insert(nSourceDim, pCache, vIdx, nNewID);
@@ -131,7 +131,7 @@ namespace
}
template<>
- SCROW lcl_InsertValue<true>(SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
+ SCROW lcl_InsertValue<true>(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
{
SCROW nItemId = lcl_InsertValue<false>( nSourceDim, pCache, vIdx, rData );
@@ -142,13 +142,13 @@ namespace
}
template<bool bUpdateData>
- void lcl_InsertValue ( SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue )
+ void lcl_InsertValue ( SCCOL nSourceDim, const ScDPCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue )
{
lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( rString, fValue, TRUE ) );
}
template<bool bUpdateData>
- void lcl_InsertValue ( SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue, sal_Int32 nDatePart )
+ void lcl_InsertValue ( SCCOL nSourceDim, const ScDPCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue, sal_Int32 nDatePart )
{
lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( nDatePart, rString, fValue, ScDPItemData::MK_DATA|ScDPItemData::MK_VAL|ScDPItemData::MK_DATEPART ) );
}
@@ -601,7 +601,7 @@ String lcl_GetSpecialDateName( double fValue, bool bFirst, SvNumberFormatter* pF
}
void ScDPDateGroupHelper::FillColumnEntries(
- SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& rEntries, const std::vector<SCROW>& rOriginal) const
+ SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& rEntries, const std::vector<SCROW>& rOriginal) const
{
// auto min/max is only used for "Years" part, but the loop is always needed
double fSourceMin = 0.0;
@@ -902,7 +902,7 @@ void ScDPNumGroupDimension::MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_I
}
const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
- SCCOL nSourceDim, const ScDPTableDataCache* pCache, const std::vector<SCROW>& rOriginal) const
+ SCCOL nSourceDim, const ScDPCache* pCache, const std::vector<SCROW>& rOriginal) const
{
if ( maMemberEntries.empty() )
{
@@ -1338,7 +1338,7 @@ void ScDPGroupTableData::FillGroupValues( /*ScDPItemData* pItemData*/ SCROW* pIt
{
long nGroupedColumns = aGroups.size();
- const ScDPTableDataCache* pCache = GetCacheTable().getCache();
+ const ScDPCache* pCache = GetCacheTable().getCache();
for (long nDim=0; nDim<nCount; nDim++)
{
const ScDPDateGroupHelper* pDateHelper = NULL;
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index b03144a..1de322d 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -1305,7 +1305,7 @@ void ScDPSaveDimension::Refresh( const com::sun::star::uno::Reference<
if ( xSource.is() )
{
ScDPSource* pTabSource = static_cast<ScDPSource*>( xSource.get() );
- const ScDPTableDataCache* pCache = pTabSource->GetCache();
+ const ScDPCache* pCache = pTabSource->GetCache();
SCCOL nSrcDim = pCache->GetDimensionIndex( GetName() );
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index cd3d514..1b8915a 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -75,7 +75,7 @@ using ::com::sun::star::uno::UNO_QUERY;
#define SC_DBPROP_COMMAND "Command"
#define SC_DBPROP_COMMANDTYPE "CommandType"
-ScDPTableDataCache* ScImportSourceDesc::CreateCache() const
+ScDPCache* ScImportSourceDesc::CreateCache() const
{
if (!mpDoc)
return NULL;
@@ -91,7 +91,7 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache() const
return NULL;
}
- ScDPTableDataCache* pCache = new ScDPTableDataCache(mpDoc);
+ ScDPCache* pCache = new ScDPCache(mpDoc);
uno::Reference<sdbc::XRowSet> xRowSet ;
try
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 83502aa..cbc19f6 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -306,7 +306,7 @@ bool ScSheetSourceDesc::operator== (const ScSheetSourceDesc& rOther) const
maQueryParam == rOther.maQueryParam;
}
-ScDPTableDataCache* ScSheetSourceDesc::CreateCache() const
+ScDPCache* ScSheetSourceDesc::CreateCache() const
{
if (!mpDoc)
return NULL;
@@ -318,7 +318,7 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache() const
return NULL;
}
- ScDPTableDataCache* pCache = new ScDPTableDataCache(mpDoc);
+ ScDPCache* pCache = new ScDPCache(mpDoc);
pCache->InitFromDoc(mpDoc, GetSourceRange());
return pCache;
}
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 2a935fc..2bf2dd0 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -65,7 +65,7 @@ bool lcl_isDate( ULONG nNumType )
return ((nNumType & NUMBERFORMAT_DATE) != 0) ? 1 : 0;
}
-bool lcl_Search( const ScDPTableDataCache::DataListType& list, const ::std::vector<SCROW>& rOrder, const ScDPItemData& item, SCROW& rIndex)
+bool lcl_Search( const ScDPCache::DataListType& list, const ::std::vector<SCROW>& rOrder, const ScDPItemData& item, SCROW& rIndex)
{
rIndex = list.size();
bool bFound = false;
@@ -360,7 +360,7 @@ void ScDPItemData::SetDate( bool b )
//class ScDPTableDataCache
//To cache the pivot table data source
-bool ScDPTableDataCache::operator== ( const ScDPTableDataCache& r ) const
+bool ScDPCache::operator== ( const ScDPCache& r ) const
{
if ( GetColumnCount() == r.GetColumnCount() )
{
@@ -398,17 +398,17 @@ bool ScDPTableDataCache::operator== ( const ScDPTableDataCache& r ) const
return true;
}
-ScDPTableDataCache::ScDPTableDataCache(ScDocument* pDoc) :
+ScDPCache::ScDPCache(ScDocument* pDoc) :
mpDoc( pDoc ),
mnColumnCount ( 0 )
{
}
-ScDPTableDataCache::~ScDPTableDataCache()
+ScDPCache::~ScDPCache()
{
}
-bool ScDPTableDataCache::IsValid() const
+bool ScDPCache::IsValid() const
{
return !maTableDataValues.empty() && !maSourceData.empty() && mnColumnCount > 0;
}
@@ -437,7 +437,7 @@ private:
}
-bool ScDPTableDataCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
+bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
{
// Make sure the formula cells within the data range are interpreted
// during this call, for this method may be called from the interpretation
@@ -486,7 +486,7 @@ bool ScDPTableDataCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
return true;
}
-bool ScDPTableDataCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowSet, const Date& rNullDate)
+bool ScDPCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowSet, const Date& rNullDate)
{
if (!xRowSet.is())
// Dont' even waste time to go any further.
@@ -555,7 +555,7 @@ bool ScDPTableDataCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowS
}
}
-ULONG ScDPTableDataCache::GetDimNumType( SCCOL nDim) const
+ULONG ScDPCache::GetDimNumType( SCCOL nDim) const
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
DBG_ASSERT( nDim < mnColumnCount && nDim >=0, " dimention out of bound " );
@@ -565,7 +565,7 @@ ULONG ScDPTableDataCache::GetDimNumType( SCCOL nDim) const
return GetNumType(maTableDataValues[nDim][0].nNumFormat);
}
-bool ScDPTableDataCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpecial)
+bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpecial)
{
if (!rParam.GetEntry(0).bDoQuery)
return true;
@@ -777,17 +777,17 @@ bool ScDPTableDataCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, boo
return bRet;
}
-bool ScDPTableDataCache::IsRowEmpty( SCROW nRow ) const
+bool ScDPCache::IsRowEmpty( SCROW nRow ) const
{
return mbEmptyRow[ nRow ];
}
-bool ScDPTableDataCache::IsEmptyMember( SCROW nRow, USHORT nColumn ) const
+bool ScDPCache::IsEmptyMember( SCROW nRow, USHORT nColumn ) const
{
return !GetItemDataById( nColumn, GetItemDataId( nColumn, nRow, false ) )->IsHasData();
}
-bool ScDPTableDataCache::AddData(long nDim, ScDPItemData* pitemData)
+bool ScDPCache::AddData(long nDim, ScDPItemData* pitemData)
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
DBG_ASSERT( nDim < mnColumnCount && nDim >=0 , "dimension out of bound" );
@@ -823,7 +823,7 @@ bool ScDPTableDataCache::AddData(long nDim, ScDPItemData* pitemData)
}
-String ScDPTableDataCache::GetDimensionName( USHORT nColumn ) const
+String ScDPCache::GetDimensionName( USHORT nColumn ) const
{
DBG_ASSERT(nColumn < maLabelNames.size()-1 , "ScDPTableDataCache::GetDimensionName");
DBG_ASSERT(maLabelNames.size() == static_cast <USHORT> (mnColumnCount+1), "ScDPTableDataCache::GetDimensionName");
@@ -836,7 +836,7 @@ String ScDPTableDataCache::GetDimensionName( USHORT nColumn ) const
return String();
}
-void ScDPTableDataCache::AddLabel(ScDPItemData *pData)
+void ScDPCache::AddLabel(ScDPItemData *pData)
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
@@ -867,7 +867,7 @@ void ScDPTableDataCache::AddLabel(ScDPItemData *pData)
maLabelNames.push_back( pData );
}
-SCROW ScDPTableDataCache::GetItemDataId(USHORT nDim, SCROW nRow, bool bRepeatIfEmpty) const
+SCROW ScDPCache::GetItemDataId(USHORT nDim, SCROW nRow, bool bRepeatIfEmpty) const
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
DBG_ASSERT( /* nDim >= 0 && */ nDim < mnColumnCount, "ScDPTableDataCache::GetItemDataId " );
@@ -881,7 +881,7 @@ SCROW ScDPTableDataCache::GetItemDataId(USHORT nDim, SCROW nRow, bool bRepeatIfE
return maSourceData[nDim][nRow];
}
-const ScDPItemData* ScDPTableDataCache::GetItemDataById(long nDim, SCROW nId) const
+const ScDPItemData* ScDPCache::GetItemDataById(long nDim, SCROW nId) const
{
if ( nId >= GetRowCount() )
return maAdditionalData.getData( nId - GetRowCount() );
@@ -892,7 +892,7 @@ const ScDPItemData* ScDPTableDataCache::GetItemDataById(long nDim, SCROW nId) co
return &maTableDataValues[nDim][nId];
}
-SCROW ScDPTableDataCache::GetRowCount() const
+SCROW ScDPCache::GetRowCount() const
{
if ( IsValid() )
return maSourceData[0].size();
@@ -900,13 +900,13 @@ SCROW ScDPTableDataCache::GetRowCount() const
return 0;
}
-const ScDPTableDataCache::DataListType& ScDPTableDataCache::GetDimMemberValues(SCCOL nDim) const
+const ScDPCache::DataListType& ScDPCache::GetDimMemberValues(SCCOL nDim) const
{
DBG_ASSERT( nDim>=0 && nDim < mnColumnCount ," nDim < mnColumnCount ");
return maTableDataValues[nDim];
}
-SCROW ScDPTableDataCache::GetSortedItemDataId(SCCOL nDim, SCROW nOrder) const
+SCROW ScDPCache::GetSortedItemDataId(SCCOL nDim, SCROW nOrder) const
{
DBG_ASSERT ( IsValid(), "IsValid");
DBG_ASSERT( nDim>=0 && nDim < mnColumnCount, "nDim < mnColumnCount");
@@ -915,7 +915,7 @@ SCROW ScDPTableDataCache::GetSortedItemDataId(SCCOL nDim, SCROW nOrder) const
return maGlobalOrder[nDim][nOrder];
}
-ULONG ScDPTableDataCache::GetNumType(ULONG nFormat) const
+ULONG ScDPCache::GetNumType(ULONG nFormat) const
{
SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
ULONG nType = NUMBERFORMAT_NUMBER;
@@ -924,7 +924,7 @@ ULONG ScDPTableDataCache::GetNumType(ULONG nFormat) const
return nType;
}
-ULONG ScDPTableDataCache::GetNumberFormat( long nDim ) const
+ULONG ScDPCache::GetNumberFormat( long nDim ) const
{
if ( nDim >= mnColumnCount )
return 0;
@@ -934,7 +934,7 @@ ULONG ScDPTableDataCache::GetNumberFormat( long nDim ) const
return maTableDataValues[nDim][0].nNumFormat;
}
-bool ScDPTableDataCache::IsDateDimension( long nDim ) const
+bool ScDPCache::IsDateDimension( long nDim ) const
{
if ( nDim >= mnColumnCount )
return false;
@@ -945,19 +945,19 @@ bool ScDPTableDataCache::IsDateDimension( long nDim ) const
}
-SCROW ScDPTableDataCache::GetDimMemberCount( SCCOL nDim ) const
+SCROW ScDPCache::GetDimMemberCount( SCCOL nDim ) const
{
DBG_ASSERT( nDim>=0 && nDim < mnColumnCount ," ScDPTableDataCache::GetDimMemberCount : out of bound ");
return maTableDataValues[nDim].size();
}
-const ScDPItemData* ScDPTableDataCache::GetSortedItemData(SCCOL nDim, SCROW nOrder) const
+const ScDPItemData* ScDPCache::GetSortedItemData(SCCOL nDim, SCROW nOrder) const
{
SCROW n = GetSortedItemDataId( nDim, nOrder );
return GetItemDataById( nDim, n );
}
-SCCOL ScDPTableDataCache::GetDimensionIndex(String sName) const
+SCCOL ScDPCache::GetDimensionIndex(String sName) const
{
for (size_t i = 1; i < maLabelNames.size(); ++i)
{
@@ -967,7 +967,7 @@ SCCOL ScDPTableDataCache::GetDimensionIndex(String sName) const
return -1;
}
-SCROW ScDPTableDataCache::GetIdByItemData(long nDim, String sItemData ) const
+SCROW ScDPCache::GetIdByItemData(long nDim, String sItemData ) const
{
if ( nDim < mnColumnCount && nDim >=0 )
{
@@ -982,7 +982,7 @@ SCROW ScDPTableDataCache::GetIdByItemData(long nDim, String sItemData ) const
return GetRowCount() +maAdditionalData.getDataId(rData);
}
-SCROW ScDPTableDataCache::GetIdByItemData( long nDim, const ScDPItemData& rData ) const
+SCROW ScDPCache::GetIdByItemData( long nDim, const ScDPItemData& rData ) const
{
if ( nDim < mnColumnCount && nDim >=0 )
{
@@ -995,19 +995,19 @@ SCROW ScDPTableDataCache::GetIdByItemData( long nDim, const ScDPItemData& rData
return GetRowCount() + maAdditionalData.getDataId(rData);
}
-SCROW ScDPTableDataCache::GetAdditionalItemID ( String sItemData ) const
+SCROW ScDPCache::GetAdditionalItemID ( String sItemData ) const
{
ScDPItemData rData ( sItemData );
return GetAdditionalItemID( rData );
}
-SCROW ScDPTableDataCache::GetAdditionalItemID( const ScDPItemData& rData ) const
+SCROW ScDPCache::GetAdditionalItemID( const ScDPItemData& rData ) const
{
return GetRowCount() + maAdditionalData.insertData( rData );
}
-SCROW ScDPTableDataCache::GetOrder(long nDim, SCROW nIndex) const
+SCROW ScDPCache::GetOrder(long nDim, SCROW nIndex) const
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
DBG_ASSERT( nDim >=0 && nDim < mnColumnCount, "ScDPTableDataCache::GetOrder : out of bound" );
@@ -1027,12 +1027,12 @@ SCROW ScDPTableDataCache::GetOrder(long nDim, SCROW nIndex) const
return maIndexOrder[nDim][nIndex];
}
-ScDocument* ScDPTableDataCache::GetDoc() const
+ScDocument* ScDPCache::GetDoc() const
{
return mpDoc;
};
-long ScDPTableDataCache::GetColumnCount() const
+long ScDPCache::GetColumnCount() const
{
return mnColumnCount;
}
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 936bd0f..7d35c56 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -2796,7 +2796,7 @@ uno::Any SAL_CALL ScDPMember::getPropertyValue( const rtl::OUString& aPropertyNa
SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPMember )
-const ScDPTableDataCache* ScDPSource::GetCache()
+const ScDPCache* ScDPSource::GetCache()
{
DBG_ASSERT( GetData() , "empty ScDPTableData pointer");
return ( GetData()!=NULL) ? GetData()->GetCacheTable().getCache() : NULL ;
commit 22086a78222d3f2084ff50e2a27d8ece7ea3b3ad
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Mar 1 00:02:01 2011 -0500
Finally get the refresh to work properly.
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index afecfb3..6d04c56 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -169,6 +169,7 @@ public:
SCROW getOrder(long nDim, SCROW nIndex) const;
void clear();
bool empty() const;
+ void setCache(ScDPTableDataCache* p);
private:
ScDPCacheTable();
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index 810b71e..b98fb21 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -50,22 +50,25 @@ struct ScImportSourceDesc
String aObject;
USHORT nType; // enum DataImportMode
BOOL bNative;
+ ScDocument* mpDoc;
- ScImportSourceDesc() : nType(0), bNative(FALSE) {}
+ ScImportSourceDesc(ScDocument* pDoc) : nType(0), bNative(FALSE), mpDoc(pDoc) {}
BOOL operator== ( const ScImportSourceDesc& rOther ) const
{ return aDBName == rOther.aDBName &&
aObject == rOther.aObject &&
nType == rOther.nType &&
- bNative == rOther.bNative; }
+ bNative == rOther.bNative &&
+ mpDoc == rOther.mpDoc; }
- ScDPTableDataCache* CreateCache(ScDocument* pDoc) const;
+ ScDPTableDataCache* CreateCache() const;
};
class ScDatabaseDPData : public ScDPTableData
{
private:
- ScDPCacheTable aCacheTable;
+ const ScImportSourceDesc& mrImport;
+ ScDPCacheTable aCacheTable;
public:
ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport);
virtual ~ScDatabaseDPData();
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index ff720f3..1eb12e8 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -110,6 +110,7 @@ private:
bool bIgnoreEmptyRows;
bool bRepeatIfEmpty;
+ const ScSheetSourceDesc& mrDesc;
ScDPCacheTable aCacheTable;
public:
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index ce8294b..5f292b1 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -402,6 +402,8 @@ void ScDPCacheTable::clear()
{
maFieldEntries.clear();
maRowsVisible.clear();
+ delete mpCache;
+ mpCache = NULL;
}
bool ScDPCacheTable::empty() const
@@ -409,6 +411,12 @@ bool ScDPCacheTable::empty() const
return mpCache == NULL || maFieldEntries.empty();
}
+void ScDPCacheTable::setCache(ScDPTableDataCache* p)
+{
+ delete mpCache;
+ mpCache = p;
+}
+
bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const
{
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index c3c3cfe..cd3d514 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -75,9 +75,9 @@ using ::com::sun::star::uno::UNO_QUERY;
#define SC_DBPROP_COMMAND "Command"
#define SC_DBPROP_COMMANDTYPE "CommandType"
-ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc) const
+ScDPTableDataCache* ScImportSourceDesc::CreateCache() const
{
- if ( !pDoc )
+ if (!mpDoc)
return NULL;
sal_Int32 nSdbType = -1;
@@ -91,7 +91,7 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc) const
return NULL;
}
- ScDPTableDataCache* pCache = new ScDPTableDataCache( pDoc );
+ ScDPTableDataCache* pCache = new ScDPTableDataCache(mpDoc);
uno::Reference<sdbc::XRowSet> xRowSet ;
try
@@ -131,7 +131,7 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc) const
}
else
xRowSet->execute();
- SvNumberFormatter aFormat( pDoc->GetServiceManager(), ScGlobal::eLnge);
+ SvNumberFormatter aFormat(mpDoc->GetServiceManager(), ScGlobal::eLnge);
pCache->InitFromDataBase( xRowSet, *aFormat.GetNullDate() );
}
}
@@ -157,7 +157,8 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc) const
ScDatabaseDPData::ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport) :
ScDPTableData(pDoc),
- aCacheTable(rImport.CreateCache(pDoc))
+ mrImport(rImport),
+ aCacheTable(rImport.CreateCache())
{
}
@@ -168,7 +169,7 @@ ScDatabaseDPData::~ScDatabaseDPData()
void ScDatabaseDPData::DisposeData()
{
//! use OpenDatabase here?
- aCacheTable.clear();
+ aCacheTable.clear();
}
long ScDatabaseDPData::GetColumnCount()
@@ -213,6 +214,7 @@ void ScDatabaseDPData::CreateCacheTable()
if (!aCacheTable.empty())
return;
+ aCacheTable.setCache(mrImport.CreateCache());
aCacheTable.fillTable();
}
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 0199eca..83502aa 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -66,6 +66,7 @@ ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc) :
pSpecial(NULL),
bIgnoreEmptyRows( FALSE ),
bRepeatIfEmpty(FALSE),
+ mrDesc(rDesc),
aCacheTable(rDesc.CreateCache())
{
SCSIZE nEntryCount( aQuery.GetEntryCount());
@@ -200,8 +201,8 @@ void ScSheetDPData::CreateCacheTable()
// already cached.
return;
- aCacheTable.fillTable( aQuery, pSpecial,
- bIgnoreEmptyRows, bRepeatIfEmpty );
+ aCacheTable.setCache(mrDesc.CreateCache());
+ aCacheTable.fillTable(aQuery, pSpecial, bIgnoreEmptyRows, bRepeatIfEmpty);
}
void ScSheetDPData::FilterCacheTable(const vector<ScDPCacheTable::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 63f6375..7922f09 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -409,7 +409,7 @@ void ScXMLDataPilotTableContext::EndElement()
{
case SQL :
{
- ScImportSourceDesc aImportDesc;
+ ScImportSourceDesc aImportDesc(pDoc);
aImportDesc.aDBName = sDatabaseName;
aImportDesc.aObject = sSourceObject;
aImportDesc.nType = sheet::DataImportMode_SQL;
@@ -419,7 +419,7 @@ void ScXMLDataPilotTableContext::EndElement()
break;
case TABLE :
{
- ScImportSourceDesc aImportDesc;
+ ScImportSourceDesc aImportDesc(pDoc);
aImportDesc.aDBName = sDatabaseName;
aImportDesc.aObject = sSourceObject;
aImportDesc.nType = sheet::DataImportMode_TABLE;
@@ -428,7 +428,7 @@ void ScXMLDataPilotTableContext::EndElement()
break;
case QUERY :
{
- ScImportSourceDesc aImportDesc;
+ ScImportSourceDesc aImportDesc(pDoc);
aImportDesc.aDBName = sDatabaseName;
aImportDesc.aObject = sSourceObject;
aImportDesc.nType = sheet::DataImportMode_QUERY;
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 1726434..20fa0b5 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -833,7 +833,7 @@ void SAL_CALL ScDataPilotDescriptorBase::setPropertyValue( const OUString& aProp
uno::Sequence<beans::PropertyValue> aArgSeq;
if ( aValue >>= aArgSeq )
{
- ScImportSourceDesc aImportDesc;
+ ScImportSourceDesc aImportDesc(pDocShell->GetDocument());
const ScImportSourceDesc* pOldDesc = pDPObject->GetImportSourceDesc();
if (pOldDesc)
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 1b036a5..e637b39 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -809,7 +809,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
DBG_ASSERT(pDataDlg, "Dialog create fail!");
if ( pDataDlg->Execute() == RET_OK )
{
- ScImportSourceDesc aImpDesc;
+ ScImportSourceDesc aImpDesc(pDoc);
pDataDlg->GetValues( aImpDesc );
pNewDPObject = new ScDPObject( pDoc );
pNewDPObject->SetImportDesc( aImpDesc );
commit 41bfc272caf2563f4815e48787e2e1827e584313
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 22:48:11 2011 -0500
Let's rename InvalidateSource() to ClearSource().
Because that's what the method does; it clears all the source data.
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index a12298d..21dcdf5 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -135,7 +135,7 @@ public:
void SetAllowMove(BOOL bSet);
void InvalidateData();
- void InvalidateSource();
+ void ClearSource();
void Output( const ScAddress& rPos );
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index d8ceeef..b0414f7 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -212,7 +212,7 @@ ScDPObject::~ScDPObject()
delete pSheetDesc;
delete pImpDesc;
delete pServDesc;
- InvalidateSource();
+ ClearSource();
}
void ScDPObject::SetAlive(BOOL bSet)
@@ -276,7 +276,7 @@ void ScDPObject::SetSheetDesc(const ScSheetSourceDesc& rDesc)
aParam.bHasHeader = true;
pSheetDesc->SetQueryParam(aParam);
- InvalidateSource(); // new source must be created
+ ClearSource(); // new source must be created
}
void ScDPObject::SetImportDesc(const ScImportSourceDesc& rDesc)
@@ -290,7 +290,7 @@ void ScDPObject::SetImportDesc(const ScImportSourceDesc& rDesc)
delete pImpDesc;
pImpDesc = new ScImportSourceDesc(rDesc);
- InvalidateSource(); // new source must be created
+ ClearSource(); // new source must be created
}
void ScDPObject::SetServiceData(const ScDPServiceDesc& rDesc)
@@ -304,7 +304,7 @@ void ScDPObject::SetServiceData(const ScDPServiceDesc& rDesc)
delete pServDesc;
pServDesc = new ScDPServiceDesc(rDesc);
- InvalidateSource(); // new source must be created
+ ClearSource(); // new source must be created
}
void ScDPObject::WriteSourceDataTo( ScDPObject& rDest ) const
@@ -438,7 +438,7 @@ void ScDPObject::CreateObjects()
{
// if groups are involved, create a new source with the ScDPGroupTableData
if ( bSettingsChanged && pSaveData && pSaveData->GetExistingDimensionData() )
- InvalidateSource();
+ ClearSource();
if (!xSource.is())
{
@@ -492,7 +492,7 @@ void ScDPObject::InvalidateData()
bSettingsChanged = TRUE;
}
-void ScDPObject::InvalidateSource()
+void ScDPObject::ClearSource()
{
Reference< XComponent > xObjectComp( xSource, UNO_QUERY );
if ( xObjectComp.is() )
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 487a364..d48ef3a 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -1299,7 +1299,7 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
// (and re-read column entry collections)
// so all changes take effect
if ( pNewObj == pOldObj && pDestObj->IsImportData() )
- pDestObj->InvalidateSource();
+ pDestObj->ClearSource();
pDestObj->InvalidateData(); // before getting the new output area
commit d8183c10e09834ec8d89a6de566af8eeab3d27be
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 22:02:53 2011 -0500
More cleanups.
ScDPObject::bRefresh flag is no longer used.
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 9118326..a12298d 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -122,10 +122,9 @@ private:
long mnCacheId;
public:
- inline void SetRefresh() { bRefresh = TRUE; }
- ScDPObject( ScDocument* pD );
- ScDPObject(const ScDPObject& r);
- ~ScDPObject();
+ ScDPObject(ScDocument* pD);
+ ScDPObject(const ScDPObject& r);
+ ~ScDPObject();
/**
* When a DP object is "alive", it has table output on a sheet. This flag
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index fc2050a..b797608 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -52,9 +52,7 @@ private:
typedef ::boost::ptr_vector< ::std::vector<SCROW> > RowGridType;
ScDocument* mpDoc;
-
- long mnID;
- long mnColumnCount;
+ long mnColumnCount;
DataGridType maTableDataValues; // Data Pilot Table's index - value map
RowGridType maSourceData; // Data Pilot Table's source data
@@ -82,7 +80,6 @@ public:
SCROW GetSortedItemDataId( SCCOL nDim, SCROW nOrder ) const;
const DataListType& GetDimMemberValues( SCCOL nDim ) const;
- void SetId( long nId ){ mnID = nId;}
bool InitFromDoc(ScDocument* pDoc, const ScRange& rRange);
bool InitFromDataBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& xRowSet, const Date& rNullDate);
@@ -96,7 +93,6 @@ public:
ScDocument* GetDoc() const;//ms-cache-core
long GetColumnCount() const;
- long GetId() const;
const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 4e42206..d8ceeef 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -172,8 +172,7 @@ ScDPObject::ScDPObject( ScDocument* pD ) :
mnAutoFormatIndex( 65535 ),
bAllowMove( FALSE ),
nHeaderRows( 0 ),
- mbHeaderLayout(false),
- bRefresh( FALSE )
+ mbHeaderLayout(false)
{
}
@@ -193,8 +192,7 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
mnAutoFormatIndex( r.mnAutoFormatIndex ),
bAllowMove( FALSE ),
nHeaderRows( r.nHeaderRows ),
- mbHeaderLayout( r.mbHeaderLayout ),
- bRefresh( r.bRefresh )
+ mbHeaderLayout( r.mbHeaderLayout )
{
if (r.pSaveData)
pSaveData = new ScDPSaveData(*r.pSaveData);
@@ -459,17 +457,11 @@ void ScDPObject::CreateObjects()
{
DBG_ASSERT( !pServDesc, "DPSource could not be created" );
ScDPTableData* pData = GetTableData();
-
ScDPSource* pSource = new ScDPSource( pData );
xSource = pSource;
-
- if ( pSaveData && bRefresh )
- {
- pSaveData->Refresh( xSource );
- bRefresh = FALSE;
- }
}
- if (pSaveData )
+
+ if (pSaveData)
pSaveData->WriteToSource( xSource );
}
else if (bSettingsChanged)
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 22733b3..b03144a 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -1306,8 +1306,6 @@ void ScDPSaveDimension::Refresh( const com::sun::star::uno::Reference<
{
ScDPSource* pTabSource = static_cast<ScDPSource*>( xSource.get() );
const ScDPTableDataCache* pCache = pTabSource->GetCache();
- if ( pCache->GetId() == -1 )
- return;
SCCOL nSrcDim = pCache->GetDimensionIndex( GetName() );
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 4f6af7d..2a935fc 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -400,7 +400,6 @@ bool ScDPTableDataCache::operator== ( const ScDPTableDataCache& r ) const
ScDPTableDataCache::ScDPTableDataCache(ScDocument* pDoc) :
mpDoc( pDoc ),
- mnID(-1),
mnColumnCount ( 0 )
{
}
@@ -1038,10 +1037,4 @@ long ScDPTableDataCache::GetColumnCount() const
return mnColumnCount;
}
-long ScDPTableDataCache::GetId() const
-{
- return mnID;
-}
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5f10bd6bd5995fd229fa1a316dee787457a4d43a
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 21:49:38 2011 -0500
Remove old container that stored data caches.
We may revive this later when we decide to pool the data cache
once again.
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 616e106..9118326 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -263,13 +263,10 @@ public:
class ScDPCollection
{
private:
- ScDocument* pDoc;
-
- typedef ::boost::ptr_list<ScDPTableDataCache> DataCachesType;
- typedef ::boost::ptr_vector<ScDPObject> TablesType;
+ typedef ::boost::ptr_vector<ScDPObject> TablesType;
- TablesType maTables;
- DataCachesType maDPDataCaches;
+ ScDocument* pDoc;
+ TablesType maTables;
public:
ScDPCollection(ScDocument* pDocument);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 3545a73..4e42206 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2404,8 +2404,7 @@ ScDPCollection::ScDPCollection(ScDocument* pDocument) :
}
ScDPCollection::ScDPCollection(const ScDPCollection& r) :
- pDoc(r.pDoc),
- maDPDataCaches(r.maDPDataCaches)
+ pDoc(r.pDoc)
{
}
commit 919960d66a6d8b0593608b1478aae08ec5717e81
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 21:36:18 2011 -0500
More removal of cache ID related stuff.
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index 25d49c5..810b71e 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -59,7 +59,7 @@ struct ScImportSourceDesc
nType == rOther.nType &&
bNative == rOther.bNative; }
- ScDPTableDataCache* CreateCache( ScDocument* pDoc , long nID ) const;
+ ScDPTableDataCache* CreateCache(ScDocument* pDoc) const;
};
class ScDatabaseDPData : public ScDPTableData
@@ -67,7 +67,7 @@ class ScDatabaseDPData : public ScDPTableData
private:
ScDPCacheTable aCacheTable;
public:
- ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport, long nCacheId = -1);
+ ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport);
virtual ~ScDatabaseDPData();
virtual long GetColumnCount();
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 08f5541..ff720f3 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -78,7 +78,7 @@ public:
const ScQueryParam& GetQueryParam() const;
bool operator== ( const ScSheetSourceDesc& rOther ) const;
- ScDPTableDataCache* CreateCache(long nID = -1) const;
+ ScDPTableDataCache* CreateCache() const;
/**
* Check the sanity of the data source range.
@@ -113,7 +113,7 @@ private:
ScDPCacheTable aCacheTable;
public:
- ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc, long nCacheId = -1 );
+ ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc);
virtual ~ScSheetDPData();
virtual long GetColumnCount();
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 8d38475..b1dce11 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -97,8 +97,7 @@ class SC_DLLPUBLIC ScDPTableData
long nLastHier;
long nLastLevel;
long nLastRet;
- long mnCacheId;
- const ScDocument* mpDoc;
+ const ScDocument* mpDoc;
public:
/** This structure stores dimension information used when calculating
@@ -124,7 +123,7 @@ public:
CalcInfo();
};
- ScDPTableData(ScDocument* pDoc, long nCacheId );
+ ScDPTableData(ScDocument* pDoc);
virtual ~ScDPTableData();
long GetDatePart( long nDateVal, long nHierarchy, long nLevel );
@@ -134,7 +133,6 @@ public:
virtual long GetColumnCount() = 0;
virtual const std::vector< SCROW >& GetColumnEntries( long nColumn ) ;
- long GetCacheId() const;
virtual String getDimensionName(long nColumn) = 0;
virtual BOOL getIsDataLayoutDimension(long nColumn) = 0;
virtual BOOL IsDateDimension(long nDim) = 0;
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 5f89a45..d612cb6 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -1009,7 +1009,7 @@ const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
}
ScDPGroupTableData::ScDPGroupTableData( const shared_ptr<ScDPTableData>& pSource, ScDocument* pDocument ) :
- ScDPTableData(pDocument, pSource->GetCacheId() ),
+ ScDPTableData(pDocument),
pSourceData( pSource ),
pDoc( pDocument )
{
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index 287a559..c3c3cfe 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -75,7 +75,7 @@ using ::com::sun::star::uno::UNO_QUERY;
#define SC_DBPROP_COMMAND "Command"
#define SC_DBPROP_COMMANDTYPE "CommandType"
-ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc , long nID) const
+ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc) const
{
if ( !pDoc )
return NULL;
@@ -155,11 +155,9 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc , long nID)
return pCache;
}
-ScDatabaseDPData::ScDatabaseDPData(
- ScDocument* pDoc,
- const ScImportSourceDesc& rImport, long nCacheId /*=-1 */ ) :
- ScDPTableData(pDoc, -1),
- aCacheTable(rImport.CreateCache(pDoc, -1))
+ScDatabaseDPData::ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport) :
+ ScDPTableData(pDoc),
+ aCacheTable(rImport.CreateCache(pDoc))
{
}
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 006ab61..0199eca 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -60,13 +60,13 @@ using ::std::vector;
// -----------------------------------------------------------------------
-ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc , long nCacheId) :
- ScDPTableData(pD, -1),
+ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc) :
+ ScDPTableData(pD),
aQuery ( rDesc.GetQueryParam() ),
pSpecial(NULL),
bIgnoreEmptyRows( FALSE ),
bRepeatIfEmpty(FALSE),
- aCacheTable(rDesc.CreateCache(-1))
+ aCacheTable(rDesc.CreateCache())
{
SCSIZE nEntryCount( aQuery.GetEntryCount());
pSpecial = new bool[nEntryCount];
@@ -305,7 +305,7 @@ bool ScSheetSourceDesc::operator== (const ScSheetSourceDesc& rOther) const
maQueryParam == rOther.maQueryParam;
}
-ScDPTableDataCache* ScSheetSourceDesc::CreateCache(long nID) const
+ScDPTableDataCache* ScSheetSourceDesc::CreateCache() const
{
if (!mpDoc)
return NULL;
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index a4a239c..a1bd3c3 100644
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -62,9 +62,8 @@ ScDPTableData::CalcInfo::CalcInfo() :
// ---------------------------------------------------------------------------
-ScDPTableData::ScDPTableData(ScDocument* pDoc, long nCacheId ) :
- mnCacheId( nCacheId ),
- mpDoc ( pDoc )
+ScDPTableData::ScDPTableData(ScDocument* pDoc) :
+ mpDoc(pDoc)
{
nLastDateVal = nLastHier = nLastLevel = nLastRet = -1; // invalid
@@ -264,11 +263,6 @@ long ScDPTableData::GetMembersCount( long nDim )
return GetCacheTable().getFieldEntries( nDim ).size();
}
-long ScDPTableData::GetCacheId() const
-{
- return mnCacheId;
-}
-
const ScDPItemData* ScDPTableData::GetMemberByIndex( long nDim, long nIndex )
{
if ( nIndex >= GetMembersCount( nDim ) )
commit 4544a34042cd940e763c2607dc3d0e0cbe81da31
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 21:27:41 2011 -0500
Data cache is now stored in the cashe table object for now.
With this commit, data caches are no longer stored outside the cache
table and managed by their ID's. Each cache table stores and manages
its own data "cache", but then calling it a cache is a mis-nomer.
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index e1bc3dd..afecfb3 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -121,7 +121,7 @@ public:
Criterion();
};
- ScDPCacheTable( ScDocument* pDoc, long nId );
+ ScDPCacheTable(ScDPTableDataCache* pCache);
~ScDPCacheTable();
sal_Int32 getRowSize() const;
@@ -183,7 +183,6 @@ private:
* @param rCriteria a list of criteria
*/
bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const;
- void initNoneCache( ScDocument* pDoc );
private:
/** unique field entires for each field (column). */
@@ -194,7 +193,6 @@ private:
::std::vector<bool> maRowsVisible;
ScDPTableDataCache* mpCache;
- ScDPTableDataCache* mpNoneCache;
};
#endif
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index e33a11a..616e106 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -123,9 +123,6 @@ private:
public:
inline void SetRefresh() { bRefresh = TRUE; }
- long GetCacheId() const;
- void SetCacheId( long nCacheId );
- ULONG RefreshCache();
ScDPObject( ScDocument* pD );
ScDPObject(const ScDPObject& r);
~ScDPObject();
@@ -307,16 +304,6 @@ public:
SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj);
bool HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
-
- ScDPTableDataCache* GetDPObjectCache( long nID );
- ScDPTableDataCache* GetUsedDPObjectCache ( const ScRange& rRange );
- long AddDPObjectCache( ScDPTableDataCache* pData );
- void RemoveDPObjectCache( long nID );
-
- /**
- * Get an available, unique ID value for datapilot data cache.
- */
- long GetNewDPObjectCacheId ();
};
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index 420acab..25d49c5 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -59,10 +59,7 @@ struct ScImportSourceDesc
nType == rOther.nType &&
bNative == rOther.bNative; }
- ScDPTableDataCache* GetExistDPObjectCache( ScDocument* pDoc ) const;
ScDPTableDataCache* CreateCache( ScDocument* pDoc , long nID ) const;
- ScDPTableDataCache* GetCache( ScDocument* pDoc, long nID ) const;
- long GetCacheId( ScDocument* pDoc, long nID ) const;
};
class ScDatabaseDPData : public ScDPTableData
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index cf0de65..08f5541 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -89,9 +89,7 @@ public:
* returned.
*/
ULONG CheckSourceRange() const;
- ScDPTableDataCache* GetCache(long nID) const;
- ScDPTableDataCache* GetExistDPObjectCache() const;
- long GetCacheId(long nID) const;
+ long GetCacheId() const;
private:
mutable ScRange maSourceRange;
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 0392893..ce8294b 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -158,20 +158,14 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
-ScDPCacheTable::ScDPCacheTable( ScDocument* pDoc, long nId ) :
- mpCache( NULL ),
- mpNoneCache( NULL )
+ScDPCacheTable::ScDPCacheTable(ScDPTableDataCache* pCache) :
+ mpCache(pCache)
{
- if ( nId >= 0 )
- mpCache = pDoc->GetDPCollection()->GetDPObjectCache( nId );
- else
- { //create a temp cache object
- initNoneCache( NULL );
- }
}
ScDPCacheTable::~ScDPCacheTable()
{
+ delete mpCache;
}
sal_Int32 ScDPCacheTable::getRowSize() const
@@ -187,10 +181,6 @@ sal_Int32 ScDPCacheTable::getColSize() const
void ScDPCacheTable::fillTable(
const ScQueryParam& rQuery, bool* pSpecial, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
{
- // check cache
- if ( mpCache == NULL )
- initNoneCache( NULL );
-
const SCROW nRowCount = getRowSize();
const SCCOL nColCount = (SCCOL) getColSize();
if ( nRowCount <= 0 || nColCount <= 0)
@@ -242,10 +232,6 @@ void ScDPCacheTable::fillTable(
void ScDPCacheTable::fillTable()
{
- // check cache
- if ( mpCache == NULL )
- initNoneCache( NULL );
-
const SCROW nRowCount = getRowSize();
const SCCOL nColCount = (SCCOL) getColSize();
if ( nRowCount <= 0 || nColCount <= 0)
@@ -420,7 +406,7 @@ void ScDPCacheTable::clear()
bool ScDPCacheTable::empty() const
{
- return ( mpCache == NULL&& mpNoneCache == NULL ) || maFieldEntries.size()==0;
+ return mpCache == NULL || maFieldEntries.empty();
}
bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
@@ -444,26 +430,14 @@ bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCr
return true;
}
-
-void ScDPCacheTable::initNoneCache( ScDocument* pDoc )
-{
- mpCache = NULL;
- delete mpNoneCache;
- mpNoneCache = new ScDPTableDataCache( pDoc );
-}
-
const ScDPTableDataCache* ScDPCacheTable::getCache() const
{
- if ( mpCache )
- return mpCache;
- return mpNoneCache;
+ return mpCache;
}
ScDPTableDataCache* ScDPCacheTable::getCache()
{
- if ( mpCache )
- return mpCache;
- return mpNoneCache;
+ return mpCache;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 56d66ac..3545a73 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -173,8 +173,7 @@ ScDPObject::ScDPObject( ScDocument* pD ) :
bAllowMove( FALSE ),
nHeaderRows( 0 ),
mbHeaderLayout(false),
- bRefresh( FALSE ),
- mnCacheId( -1)
+ bRefresh( FALSE )
{
}
@@ -195,8 +194,7 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
bAllowMove( FALSE ),
nHeaderRows( r.nHeaderRows ),
mbHeaderLayout( r.mbHeaderLayout ),
- bRefresh( r.bRefresh ),
- mnCacheId ( r.mnCacheId )
+ bRefresh( r.bRefresh )
{
if (r.pSaveData)
pSaveData = new ScDPSaveData(*r.pSaveData);
@@ -216,7 +214,6 @@ ScDPObject::~ScDPObject()
delete pSheetDesc;
delete pImpDesc;
delete pServDesc;
- mnCacheId = -1;
InvalidateSource();
}
@@ -412,7 +409,7 @@ ScDPTableData* ScDPObject::GetTableData()
if ( pImpDesc )
{
// database data
- pData.reset(new ScDatabaseDPData(pDoc, *pImpDesc, GetCacheId()));
+ pData.reset(new ScDatabaseDPData(pDoc, *pImpDesc));
}
else
{
@@ -422,7 +419,7 @@ ScDPTableData* ScDPObject::GetTableData()
DBG_ERROR("no source descriptor");
pSheetDesc = new ScSheetSourceDesc(pDoc); // dummy defaults
}
- pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, GetCacheId()));
+ pData.reset(new ScSheetDPData(pDoc, *pSheetDesc));
}
// grouping (for cell or database data)
@@ -433,9 +430,6 @@ ScDPTableData* ScDPObject::GetTableData()
pData = pGroupData;
}
- if ( pData )
- SetCacheId( pData->GetCacheId()); // resets mpTableData
-
mpTableData = pData; // after SetCacheId
}
@@ -2564,73 +2558,6 @@ String ScDPCollection::CreateNewName( USHORT nMin ) const
return String(); // should not happen
}
-long ScDPObject::GetCacheId() const
-{
- return mnCacheId;
-}
-
-ULONG ScDPObject::RefreshCache()
-{
- if ( pServDesc )
- {
- // cache table isn't used for external service - do nothing, no error
- return 0;
- }
-
- CreateObjects();
- ULONG nErrId = 0;
- if ( pSheetDesc)
- nErrId = pSheetDesc->CheckSourceRange();
- if ( nErrId == 0 )
- {
- // First remove the old cache if exists.
- ScDPCollection* pDPCollection = pDoc->GetDPCollection();
- long nOldId = GetCacheId();
- long nNewId = pDPCollection->GetNewDPObjectCacheId();
- if ( nOldId >= 0 )
- pDPCollection->RemoveDPObjectCache( nOldId );
-
- // Create a new cache.
- ScDPTableDataCache* pCache = NULL;
- if ( pSheetDesc )
- pCache = pSheetDesc->CreateCache(nNewId);
- else if ( pImpDesc )
- pCache = pImpDesc->CreateCache(pDoc, nNewId);
-
- if ( pCache == NULL )
- {
- //cache failed
- DBG_ASSERT( pCache , "pCache == NULL" );
- return STR_ERR_DATAPILOTSOURCE;
- }
-
- nNewId = pCache->GetId();
-
- bRefresh = TRUE;
- size_t nCount = pDPCollection->GetCount();
- for (size_t i=0; i<nCount; ++i)
- { //set new cache id
- if ( (*pDPCollection)[i]->GetCacheId() == nOldId )
- {
- (*pDPCollection)[i]->SetCacheId( nNewId );
- (*pDPCollection)[i]->SetRefresh();
-
- }
- }
- DBG_ASSERT( GetCacheId() >= 0, " GetCacheId() >= 0 " );
- }
- return nErrId;
-}
-
-void ScDPObject::SetCacheId( long nCacheId )
-{
- if ( GetCacheId() != nCacheId )
- {
- InvalidateSource();
- mnCacheId = nCacheId;
- }
-}
-
void ScDPCollection::FreeTable(ScDPObject* pDPObj)
{
const ScRange& rOutRange = pDPObj->GetOutRange();
@@ -2671,81 +2598,4 @@ bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
return pMergeAttr->HasDPTable();
}
-ScDPTableDataCache* ScDPCollection::GetDPObjectCache( long nID )
-{
- DataCachesType::iterator itr = maDPDataCaches.begin(), itrEnd = maDPDataCaches.end();
- for (; itr != itrEnd; ++itr)
- {
- if ( nID == itr->GetId() )
- return &(*itr);
- }
- return NULL;
-}
-
-ScDPTableDataCache* ScDPCollection::GetUsedDPObjectCache ( const ScRange& rRange )
-{
- ScDPTableDataCache* pCache = NULL;
- for (size_t i=maTables.size(); i > 0 ; --i)
- {
- if ( const ScSheetSourceDesc* pUsedSheetDesc = maTables[i-1].GetSheetDesc() )
- if ( rRange == pUsedSheetDesc->GetSourceRange() )
- {
- long nID = maTables[i-1].GetCacheId();
- if ( nID >= 0 )
- pCache= GetDPObjectCache( nID );
- if ( pCache )
- return pCache;
- }
- }
- return pCache;
-}
-
-long ScDPCollection::AddDPObjectCache( ScDPTableDataCache* pData )
-{
- if ( pData->GetId() < 0 )
- { //create a id for it
- pData->SetId( GetNewDPObjectCacheId() );
- }
- maDPDataCaches.push_back( pData );
- return pData->GetId();
-}
-
-void ScDPCollection::RemoveDPObjectCache( long nID )
-{
- DataCachesType::iterator itr = maDPDataCaches.begin(), itrEnd = maDPDataCaches.end();
- for (; itr != itrEnd; ++itr)
- {
- if ( nID == itr->GetId() )
- {
- maDPDataCaches.erase(itr);
- break;
- }
- }
-}
-
-long ScDPCollection::GetNewDPObjectCacheId()
-{
- long nID = 0;
-
- bool bFound = false;
- DataCachesType::const_iterator itr, itrEnd = maDPDataCaches.end();
- do
- {
- for ( itr = maDPDataCaches.begin(); itr != itrEnd; ++itr )
- {
- if ( nID == itr->GetId() )
- {
- nID++;
- bFound = true;
- break;
- }
- }
- if ( itr == itrEnd )
- bFound = false;
- }
- while ( bFound );
-
- return nID;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index ab6e16e..287a559 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -74,28 +74,8 @@ using ::com::sun::star::uno::UNO_QUERY;
#define SC_DBPROP_DATASOURCENAME "DataSourceName"
#define SC_DBPROP_COMMAND "Command"
#define SC_DBPROP_COMMANDTYPE "CommandType"
-// -----------------------------------------------------------------------
- ScDPTableDataCache* ScImportSourceDesc::GetExistDPObjectCache( ScDocument* pDoc ) const
-{
- ScDPTableDataCache* pCache = NULL;
- ScDPCollection* pDPCollection= pDoc->GetDPCollection();
- size_t nCount = pDPCollection->GetCount();
- for (size_t i = nCount; i > 0; --i)
- {
- if ( const ScImportSourceDesc* pUsedDesc = (*pDPCollection)[i-1]->GetImportSourceDesc() )
- if ( *this == *pUsedDesc )
- {
- long nID = (*pDPCollection)[i-1]->GetCacheId();
- if ( nID >= 0 )
- pCache= pDPCollection->GetDPObjectCache( nID );
- if ( pCache )
- return pCache;
- }
- }
- return NULL;
-}
-ScDPTableDataCache* ScImportSourceDesc::CreateCache( ScDocument* pDoc , long nID ) const
+ScDPTableDataCache* ScImportSourceDesc::CreateCache(ScDocument* pDoc , long nID) const
{
if ( !pDoc )
return NULL;
@@ -111,14 +91,7 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache( ScDocument* pDoc , long nID
return NULL;
}
-
- ScDPTableDataCache* pCache = GetExistDPObjectCache( pDoc );
-
- if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
- return pCache;
-
- if ( pCache == NULL )
- pCache = new ScDPTableDataCache( pDoc );
+ ScDPTableDataCache* pCache = new ScDPTableDataCache( pDoc );
uno::Reference<sdbc::XRowSet> xRowSet ;
try
@@ -160,9 +133,6 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache( ScDocument* pDoc , long nID
xRowSet->execute();
SvNumberFormatter aFormat( pDoc->GetServiceManager(), ScGlobal::eLnge);
pCache->InitFromDataBase( xRowSet, *aFormat.GetNullDate() );
- pCache->SetId( nID );
- pDoc->GetDPCollection()->AddDPObjectCache( pCache );
- DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
}
}
catch ( sdbc::SQLException& rError )
@@ -185,34 +155,12 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache( ScDocument* pDoc , long nID
return pCache;
}
-ScDPTableDataCache* ScImportSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
-{
- ScDPTableDataCache* pCache = pDoc->GetDPCollection()->GetDPObjectCache( nID );
- if ( NULL == pCache && pDoc )
- pCache = GetExistDPObjectCache( pDoc);
- if ( NULL == pCache )
- pCache = CreateCache( pDoc , nID );
- return pCache;
-}
-
-long ScImportSourceDesc:: GetCacheId( ScDocument* pDoc, long nID ) const
-{
- ScDPTableDataCache* pCache = GetCache( pDoc, nID);
- if ( NULL == pCache )
- return -1;
- else
- return pCache->GetId();
-}
-
-// -----------------------------------------------------------------------
-
ScDatabaseDPData::ScDatabaseDPData(
ScDocument* pDoc,
const ScImportSourceDesc& rImport, long nCacheId /*=-1 */ ) :
- ScDPTableData(pDoc, rImport.GetCacheId( pDoc, nCacheId) ),
- aCacheTable( pDoc, rImport.GetCacheId( pDoc, nCacheId))
+ ScDPTableData(pDoc, -1),
+ aCacheTable(rImport.CreateCache(pDoc, -1))
{
-
}
ScDatabaseDPData::~ScDatabaseDPData()
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index d137454..006ab61 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -61,12 +61,12 @@ using ::std::vector;
// -----------------------------------------------------------------------
ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc , long nCacheId) :
- ScDPTableData(pD, rDesc.GetCacheId(nCacheId) ),
+ ScDPTableData(pD, -1),
aQuery ( rDesc.GetQueryParam() ),
pSpecial(NULL),
bIgnoreEmptyRows( FALSE ),
bRepeatIfEmpty(FALSE),
- aCacheTable( pD, rDesc.GetCacheId(nCacheId))
+ aCacheTable(rDesc.CreateCache(-1))
{
SCSIZE nEntryCount( aQuery.GetEntryCount());
pSpecial = new bool[nEntryCount];
@@ -310,10 +310,6 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache(long nID) const
if (!mpDoc)
return NULL;
- ScDPTableDataCache* pCache = GetExistDPObjectCache();
- if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
- return pCache;
-
ULONG nErrId = CheckSourceRange();
if (nErrId)
{
@@ -321,44 +317,14 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache(long nID) const
return NULL;
}
- pCache = new ScDPTableDataCache(mpDoc);
-
+ ScDPTableDataCache* pCache = new ScDPTableDataCache(mpDoc);
pCache->InitFromDoc(mpDoc, GetSourceRange());
- pCache->SetId( nID );
- mpDoc->GetDPCollection()->AddDPObjectCache(pCache);
-
- DBG_TRACE1("Create a cache id = %d \n", pCache->GetId());
-
- return pCache;
-}
-
-ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache() const
-{
- return mpDoc->GetDPCollection()->GetUsedDPObjectCache( GetSourceRange() );
-}
-
-ScDPTableDataCache* ScSheetSourceDesc::GetCache(long nID) const
-{
- if (!mpDoc)
- return NULL;
-
- ScDPTableDataCache* pCache = mpDoc->GetDPCollection()->GetDPObjectCache(nID);
- if (NULL == pCache)
- pCache = GetExistDPObjectCache();
-
- if (NULL == pCache)
- pCache = CreateCache();
-
return pCache;
}
-long ScSheetSourceDesc::GetCacheId(long nID) const
+long ScSheetSourceDesc::GetCacheId() const
{
- ScDPTableDataCache* pCache = GetCache(nID);
- if ( NULL == pCache )
- return -1;
- else
- return pCache->GetId();
+ return -1;
}
ULONG ScSheetSourceDesc::CheckSourceRange() const
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index c43ea21..f327418 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -86,7 +86,7 @@ public:
bool MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, BOOL bNewTable,
const ScDPObject& rSource, BOOL bApi = FALSE );
void DeletePivotTable();
- ULONG RecalcPivotTable();
+ void RecalcPivotTable();
BOOL HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts );
BOOL HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo );
void GroupDataPilot();
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 8fe24f9..1726434 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -1276,13 +1276,17 @@ CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRange() throw(RuntimeExc
return aRet;
}
-ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, BOOL bRecord, BOOL bApi );
-
void SAL_CALL ScDataPilotTableObj::refresh() throw(RuntimeException)
{
SolarMutexGuard aGuard;
- if( ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName) )
- RefreshDPObject( pDPObj, NULL, GetDocShell(), TRUE, TRUE );
+ ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName);
+ if (pDPObj)
+ {
+ ScDPObject* pNew = new ScDPObject(*pDPObj);
+ ScDBDocFunc aFunc(*GetDocShell());
+ aFunc.DataPilotUpdate( pDPObj, pNew, TRUE, TRUE );
+ delete pNew; // DataPilotUpdate copies settings from "new" object
+ }
}
Sequence< Sequence<Any> > SAL_CALL ScDataPilotTableObj::getDrillDownData(const CellAddress& aAddr)
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 35bcc3a..efe0f98 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -652,9 +652,6 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
bool bAllowMove = (pDPObj != NULL); // allow re-positioning when editing existing table
- if (aObj.RefreshCache())
- return false;
-
ScDBDocFunc aFunc( *pDocSh );
bool bSuccess = aFunc.DataPilotUpdate( pDPObj, &aObj, TRUE, FALSE, bAllowMove );
@@ -685,44 +682,8 @@ void ScDBFunc::DeletePivotTable()
else
ErrorMessage(STR_PIVOT_NOTFOUND);
}
-ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, BOOL bRecord, BOOL bApi )
-{
- if( !pDPObj )
- return STR_PIVOT_NOTFOUND;
-
- if ( pDocSh && !pDoc )
- pDoc = pDocSh->GetDocument();
-
- if( !pDoc )
- return static_cast<ULONG>(-1);
- if( !pDocSh && ( pDocSh = PTR_CAST( ScDocShell, pDoc->GetDocumentShell() ) ) == NULL )
- return static_cast<ULONG>(-1);
-
- if( ULONG nErrId = pDPObj->RefreshCache() )
- return nErrId;
- else if ( nErrId == 0 )
- {
- //Refresh all dpobjects
- ScDPCollection* pDPCollection = pDoc->GetDPCollection();
- size_t nCount = pDPCollection->GetCount();
- for (size_t i=0; i<nCount; ++i)
- {
- if ( (*pDPCollection)[i]->GetCacheId() == pDPObj->GetCacheId() )
- {
- ScDBDocFunc aFunc( * pDocSh );
- if ( !aFunc.DataPilotUpdate( (*pDPCollection)[i], (*pDPCollection)[i], bRecord, bApi ) )
- break;
- }
- }
-
- return nErrId;
- }
-
- return 0U;
-}
-
-ULONG ScDBFunc::RecalcPivotTable()
+void ScDBFunc::RecalcPivotTable()
{
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocument* pDoc = GetViewData()->GetDocument();
@@ -734,19 +695,12 @@ ULONG ScDBFunc::RecalcPivotTable()
GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ULONG nErrId = RefreshDPObject( pDPObj, pDoc, pDocSh, TRUE, FALSE );
- if ( nErrId == 0 )
- {
- // There is no undo for the refresh of the cache table, but the undo history for cell changes
- // remains valid and should be preserved, so the history isn't cleared here.
- }
- else if (nErrId <= USHRT_MAX)
- ErrorMessage(static_cast<USHORT>(nErrId));
- return nErrId;
+ ScDBDocFunc aFunc( *pDocSh );
+ aFunc.DataPilotUpdate( pDPObj, pDPObj, TRUE, FALSE );
+ CursorPosChanged(); // shells may be switched
}
else
ErrorMessage(STR_PIVOT_NOTFOUND);
- return STR_PIVOT_NOTFOUND;
}
void ScDBFunc::GetSelectedMemberList( ScStrCollection& rEntries, long& rDimension )
commit 768ea092c286d52e4d05616a27f21396cf3420ca
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 20:34:30 2011 -0500
Remove cache ID storage from ScDPSaveData.
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 792ff9b..2d9ba1b 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -247,7 +247,6 @@ private:
sal_uInt16 nRepeatEmptyMode;
bool bFilterButton; // not passed to DataPilotSource
bool bDrillDown; // not passed to DataPilotSource
- long mnCacheId;
/** if true, all dimensions already have all of their member instances
* created. */
@@ -327,11 +326,6 @@ public:
void WriteToSource( const com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier>& xSource );
void Refresh( const com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier>& xSource );
bool IsEmpty() const;
- inline long GetCacheId() const
- { return mnCacheId; }
-
- inline void SetCacheId( long nCacheId )
- { mnCacheId = nCacheId; }
const ScDPDimensionSaveData* GetExistingDimensionData() const
{ return pDimensionData; }
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index f112971..56d66ac 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -236,10 +236,6 @@ void ScDPObject::SetSaveData(const ScDPSaveData& rData)
{
delete pSaveData;
pSaveData = new ScDPSaveData( rData );
- if ( rData.GetCacheId() >= 0 )
- mnCacheId = rData.GetCacheId();
- else if ( mnCacheId >= 0 )
- pSaveData->SetCacheId( mnCacheId );
}
InvalidateData(); // re-init source from SaveData
@@ -2570,11 +2566,9 @@ String ScDPCollection::CreateNewName( USHORT nMin ) const
long ScDPObject::GetCacheId() const
{
- if ( GetSaveData() )
- return GetSaveData()->GetCacheId();
- else
- return mnCacheId;
+ return mnCacheId;
}
+
ULONG ScDPObject::RefreshCache()
{
if ( pServDesc )
@@ -2633,9 +2627,6 @@ void ScDPObject::SetCacheId( long nCacheId )
if ( GetCacheId() != nCacheId )
{
InvalidateSource();
- if ( GetSaveData() )
- GetSaveData()->SetCacheId( nCacheId );
-
mnCacheId = nCacheId;
}
}
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index cc7ab86..22733b3 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -737,7 +737,6 @@ ScDPSaveData::ScDPSaveData() :
nRepeatEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
bFilterButton( true ),
bDrillDown( true ),
- mnCacheId( -1),
mbDimensionMembersBuilt(false),
mpGrandTotalName(NULL)
{
@@ -750,7 +749,6 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
nRepeatEmptyMode( r.nRepeatEmptyMode ),
bFilterButton( r.bFilterButton ),
bDrillDown( r.bDrillDown ),
- mnCacheId( r.mnCacheId ),
mbDimensionMembersBuilt(r.mbDimensionMembersBuilt),
mpGrandTotalName(NULL)
{
@@ -782,7 +780,6 @@ bool ScDPSaveData::operator== ( const ScDPSaveData& r ) const
nIgnoreEmptyMode != r.nIgnoreEmptyMode ||
nRepeatEmptyMode != r.nRepeatEmptyMode ||
bFilterButton != r.bFilterButton ||
- mnCacheId != r.mnCacheId ||
bDrillDown != r.bDrillDown ||
mbDimensionMembersBuilt != r.mbDimensionMembersBuilt)
return false;
@@ -1299,8 +1296,8 @@ void ScDPSaveData::Refresh( const uno::Reference<sheet::XDimensionsSupplier>& xS
{
DBG_ERROR("error in ScDPSaveData::Refresh");
}
-
}
+
void ScDPSaveDimension::Refresh( const com::sun::star::uno::Reference<
com::sun::star::sheet::XDimensionsSupplier>& xSource ,
const std::list<rtl::OUString>& deletedDims)
@@ -1308,7 +1305,7 @@ void ScDPSaveDimension::Refresh( const com::sun::star::uno::Reference<
if ( xSource.is() )
{
ScDPSource* pTabSource = static_cast<ScDPSource*>( xSource.get() );
- ScDPTableDataCache* pCache = pTabSource->GetCache();
+ const ScDPTableDataCache* pCache = pTabSource->GetCache();
if ( pCache->GetId() == -1 )
return;
commit 405e39052cb25021818b53ada7b7c2b72bbfdb4a
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 20:04:40 2011 -0500
A little code cleanup.
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 156690a..e1bc3dd 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -49,19 +49,12 @@ namespace com { namespace sun { namespace star {
}}}
class Date;
-
-class ScDocument;
-class ScRange;
-class ScDPDimension;
-class ScDPCollection;
-struct ScDPCacheCell;
-struct ScQueryParam;
class ScDPItemData;
-class Date;
-
class ScDPTableDataCache;
+class ScDocument;
+class ScRange;
struct ScDPValueData;
-// ----------------------------------------------------------------------------
+struct ScQueryParam;
class SC_DLLPUBLIC ScDPCacheTable
{
@@ -190,7 +183,6 @@ private:
* @param rCriteria a list of criteria
*/
bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const;
- void getValueData(ScDocument* pDoc, const ScAddress& rPos, ScDPCacheCell& rCell);
void initNoneCache( ScDocument* pDoc );
private:
commit 83b8b96825cf54ea088ed66166a7b50c996c0a0d
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 19:55:32 2011 -0500
Some whitespace cleanups.
Also, n is usually reserved to store container size; let's not use
it as loop counter.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 886420f..4f6af7d 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -62,7 +62,7 @@ namespace {
bool lcl_isDate( ULONG nNumType )
{
- return ( (nNumType & NUMBERFORMAT_DATE) != 0 )? 1:0 ;
+ return ((nNumType & NUMBERFORMAT_DATE) != 0) ? 1 : 0;
}
bool lcl_Search( const ScDPTableDataCache::DataListType& list, const ::std::vector<SCROW>& rOrder, const ScDPItemData& item, SCROW& rIndex)
@@ -93,8 +93,8 @@ bool lcl_Search( const ScDPTableDataCache::DataListType& list, const ::std::vect
return bFound;
}
-ScDPItemData* lcl_GetItemValue(const Reference<sdbc::XRow>& xRow, sal_Int32 nType, long nCol,
- const Date& rNullDate )
+ScDPItemData* lcl_GetItemValue(
+ const Reference<sdbc::XRow>& xRow, sal_Int32 nType, long nCol, const Date& rNullDate)
{
short nNumType = NUMBERFORMAT_NUMBER;
try
@@ -171,13 +171,13 @@ ScDPItemData* lcl_GetItemValue(const Reference<sdbc::XRow>& xRow, sal_Int32 nTy
}
-ScDPItemData::ScDPItemData( const String& rS, double fV/* = 0.0*/, bool bHV/* = false*/, const ULONG nNumFormatP /*= 0*/ , bool bData/* = true*/) :
+ScDPItemData::ScDPItemData(const String& rS, double fV, bool bHV, const ULONG nNumFormatP, bool bData) :
nNumFormat( nNumFormatP ), aString(rS), fValue(fV),
mbFlag( (MK_VAL*!!bHV) | (MK_DATA*!!bData) | (MK_ERR*!!false) | (MK_DATE*!!lcl_isDate( nNumFormat ) ) )
{
}
-ScDPItemData::ScDPItemData( ScDocument* pDoc, SCROW nRow, USHORT nCol, USHORT nDocTab ) :
+ScDPItemData::ScDPItemData(ScDocument* pDoc, SCROW nRow, USHORT nCol, USHORT nDocTab) :
nNumFormat( 0 ), fValue(0.0), mbFlag( 0 )
{
String aDocStr;
@@ -287,7 +287,7 @@ void ScDPItemData::dump() const
}
#endif
-TypedStrData* ScDPItemData::CreateTypeString( )
+TypedStrData* ScDPItemData::CreateTypeString( )
{
if ( IsValue() )
return new TypedStrData( aString, fValue, SC_STRTYPE_VALUE );
@@ -794,7 +794,7 @@ bool ScDPTableDataCache::AddData(long nDim, ScDPItemData* pitemData)
DBG_ASSERT( nDim < mnColumnCount && nDim >=0 , "dimension out of bound" );
SCROW nIndex = 0;
- bool bInserted = false;
+ bool bInserted = false;
pitemData->SetDate( lcl_isDate( GetNumType( pitemData->nNumFormat ) ) );
@@ -809,7 +809,7 @@ bool ScDPTableDataCache::AddData(long nDim, ScDPItemData* pitemData)
else
maSourceData[nDim].push_back( maGlobalOrder[nDim][nIndex] );
//init empty row tag
- size_t nCurRow = maSourceData[nDim].size() -1 ;
+ size_t nCurRow = maSourceData[nDim].size() - 1;
while ( mbEmptyRow.size() <= nCurRow )
mbEmptyRow.push_back( true );
@@ -876,7 +876,7 @@ SCROW ScDPTableDataCache::GetItemDataId(USHORT nDim, SCROW nRow, bool bRepeatIfE
if ( bRepeatIfEmpty )
{
while ( nRow >0 && !maTableDataValues[nDim][ maSourceData[nDim][nRow] ].IsHasData() )
- --nRow;
+ --nRow;
}
return maSourceData[nDim][nRow];
@@ -960,10 +960,10 @@ const ScDPItemData* ScDPTableDataCache::GetSortedItemData(SCCOL nDim, SCROW nOrd
SCCOL ScDPTableDataCache::GetDimensionIndex(String sName) const
{
- for ( size_t n = 1; n < maLabelNames.size(); n ++ )
+ for (size_t i = 1; i < maLabelNames.size(); ++i)
{
- if ( maLabelNames[n].GetString() == sName )
- return (SCCOL)(n-1);
+ if ( maLabelNames[i].GetString() == sName )
+ return (SCCOL)(i-1);
}
return -1;
}
@@ -972,10 +972,10 @@ SCROW ScDPTableDataCache::GetIdByItemData(long nDim, String sItemData ) const
{
if ( nDim < mnColumnCount && nDim >=0 )
{
- for ( size_t n = 0; n< maTableDataValues[nDim].size(); n++ )
+ for (size_t i = 0; i < maTableDataValues[nDim].size(); ++i)
{
- if ( maTableDataValues[nDim][n].GetString() == sItemData )
- return n;
+ if ( maTableDataValues[nDim][i].GetString() == sItemData )
+ return i;
}
}
@@ -987,10 +987,10 @@ SCROW ScDPTableDataCache::GetIdByItemData( long nDim, const ScDPItemData& rData
{
if ( nDim < mnColumnCount && nDim >=0 )
{
- for ( size_t n = 0; n< maTableDataValues[nDim].size(); n++ )
+ for (size_t i = 0; i < maTableDataValues[nDim].size(); ++i)
{
- if ( maTableDataValues[nDim][n] == rData )
- return n;
+ if ( maTableDataValues[nDim][i] == rData )
+ return i;
}
}
return GetRowCount() + maAdditionalData.getDataId(rData);
@@ -1015,17 +1015,17 @@ SCROW ScDPTableDataCache::GetOrder(long nDim, SCROW nIndex) const
if ( maIndexOrder[nDim].size() != maGlobalOrder[nDim].size() )
{ //not inited
- SCROW i = 0;
+ SCROW nRow = 0;
maIndexOrder[nDim].resize(maGlobalOrder[nDim].size(), 0);
- for ( size_t n = 0 ; n< maGlobalOrder[nDim].size(); n++ )
+ for (size_t i = 0 ; i < maGlobalOrder[nDim].size(); ++i)
{
- i = maGlobalOrder[nDim][n];
- maIndexOrder[nDim][i] = n;
+ nRow = maGlobalOrder[nDim][i];
+ maIndexOrder[nDim][nRow] = i;
}
}
DBG_ASSERT( nIndex>=0 && (size_t)nIndex < maIndexOrder[nDim].size() , "ScDPTableDataCache::GetOrder");
- return maIndexOrder[nDim][nIndex];
+ return maIndexOrder[nDim][nIndex];
}
ScDocument* ScDPTableDataCache::GetDoc() const
commit e24f0c8a5899893d5499d04b4bb0c1fe9240f022
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 19:34:44 2011 -0500
Make sure everybody calls ScDPCacheTable::getOrder() publicly.
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index 52fb794..fc2050a 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -44,6 +44,7 @@ struct ScQueryParam;
class SC_DLLPUBLIC ScDPTableDataCache
{
+ friend class ScDPCacheTable;
public:
typedef ::boost::ptr_vector<ScDPItemData> DataListType;
private:
@@ -65,7 +66,6 @@ private:
mutable ScDPItemDataPool maAdditionalData;
public:
- SCROW GetOrder( long nDim, SCROW nIndex ) const;
SCROW GetIdByItemData( long nDim, String sItemData ) const;
SCROW GetIdByItemData( long nDim, const ScDPItemData& rData ) const;
@@ -106,6 +106,7 @@ public:
virtual ~ScDPTableDataCache();
private:
+ SCROW GetOrder( long nDim, SCROW nIndex ) const;
void AddLabel( ScDPItemData* pData);
bool AddData( long nDim, ScDPItemData* itemData );
};
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 1084fa7..0392893 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -214,7 +214,7 @@ void ScDPCacheTable::fillTable(
for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
{
SCROW nIndex = getCache()->GetItemDataId( nCol, nRow, bRepeatIfEmpty );
- SCROW nOrder = getCache()->GetOrder( nCol, nIndex );
+ SCROW nOrder = getOrder( nCol, nIndex );
if ( nCol == 0 )
maRowsVisible.push_back(false);
@@ -270,7 +270,7 @@ void ScDPCacheTable::fillTable()
for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
{
SCROW nIndex = getCache()->GetItemDataId( nCol, nRow, false );
- SCROW nOrder = getCache()->GetOrder( nCol, nIndex );
+ SCROW nOrder = getOrder( nCol, nIndex );
if ( nCol == 0 )
maRowsVisible.push_back(true);
commit dfc672f151817d6e5d78a9af8ce403e2fac305aa
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Feb 28 18:14:22 2011 -0500
Make sure nobody modifies the table cache outside of ScDPCacheTable.
Use const to ensure that nobody modifies the content of the table
cache outside of ScDPCacheTable.
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index bcd1a56..156690a 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -134,7 +134,7 @@ public:
sal_Int32 getRowSize() const;
sal_Int32 getColSize() const;
- ScDPTableDataCache* getCache() const;
+ const ScDPTableDataCache* getCache() const;
/** Fill the internal table from the cell range provided. This function
assumes that the first row is the column header. */
@@ -173,6 +173,7 @@ public:
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rTabData,
const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims);
+ SCROW getOrder(long nDim, SCROW nIndex) const;
void clear();
bool empty() const;
@@ -180,6 +181,8 @@ private:
ScDPCacheTable();
ScDPCacheTable(const ScDPCacheTable&);
+ ScDPTableDataCache* getCache();
+
/**
* Check if a given row meets all specified criteria.
*
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index 4494dba..f4e11a0 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -74,8 +74,9 @@ public:
sal_Int32 GetDatePart() const { return nDatePart; }
const ScDPNumGroupInfo& GetNumInfo() const { return aNumInfo; }
- void FillColumnEntries( SCCOL nSourceDim, ScDPTableDataCache* pCahe , std::vector< SCROW >& rEntries,
- const std::vector< SCROW >& rOriginal ) const;
+ void FillColumnEntries(
+ SCCOL nSourceDim, const ScDPTableDataCache* pCahe , std::vector<SCROW>& rEntries,
+ const std::vector<SCROW>& rOriginal) const;
};
// --------------------------------------------------------------------
@@ -164,8 +165,9 @@ public:
const ScDPDateGroupHelper* GetDateHelper() const { return pDateHelper; }
- const std::vector< SCROW >& GetNumEntries( SCCOL nSourceDim, ScDPTableDataCache* pCache,
- const std::vector< SCROW >& rOriginal ) const;
+ const std::vector<SCROW>& GetNumEntries(
+ SCCOL nSourceDim, const ScDPTableDataCache* pCache,
+ const std::vector< SCROW >& rOriginal) const;
void MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index 16a231e..52fb794 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -58,19 +58,19 @@ private:
DataGridType maTableDataValues; // Data Pilot Table's index - value map
RowGridType maSourceData; // Data Pilot Table's source data
RowGridType maGlobalOrder; // Sorted members index
- RowGridType maIndexOrder; // Index the sorted numbers
+ mutable RowGridType maIndexOrder; // Index the sorted numbers
DataListType maLabelNames; // Source label data
std::vector<bool> mbEmptyRow; //If empty row?
mutable ScDPItemDataPool maAdditionalData;
public:
- SCROW GetOrder( long nDim, SCROW nIndex );
+ SCROW GetOrder( long nDim, SCROW nIndex ) const;
SCROW GetIdByItemData( long nDim, String sItemData ) const;
SCROW GetIdByItemData( long nDim, const ScDPItemData& rData ) const;
- SCROW GetAdditionalItemID ( String sItemData );
- SCROW GetAdditionalItemID( const ScDPItemData& rData );
+ SCROW GetAdditionalItemID ( String sItemData ) const;
+ SCROW GetAdditionalItemID( const ScDPItemData& rData ) const;
SCCOL GetDimensionIndex( String sName) const;
const ScDPItemData* GetSortedItemData( SCCOL nDim, SCROW nOrder ) const;
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index ecd9a3d..d4e8a60 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -174,7 +174,7 @@ public:
long GetDataDimensionCount();
ScDPDimension* GetDataDimension(long nIndex);
String GetDataDimName(long nIndex);
- ScDPTableDataCache* GetCache();
+ const ScDPTableDataCache* GetCache();
const ScDPItemData* GetItemDataById( long nDim, long nId );
long GetDataLayoutDim(){ return pData->GetColumnCount(); }
SCROW GetMemberId( long nDim, const ScDPItemData& rData );
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index f14354e..1084fa7 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -407,6 +407,11 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
rTabData[i] = tableData[i];
}
+SCROW ScDPCacheTable::getOrder(long nDim, SCROW nIndex) const
+{
+ return getCache()->GetOrder(nDim, nIndex);
+}
+
void ScDPCacheTable::clear()
{
maFieldEntries.clear();
@@ -447,7 +452,14 @@ void ScDPCacheTable::initNoneCache( ScDocument* pDoc )
mpNoneCache = new ScDPTableDataCache( pDoc );
}
-ScDPTableDataCache* ScDPCacheTable::getCache() const
+const ScDPTableDataCache* ScDPCacheTable::getCache() const
+{
+ if ( mpCache )
+ return mpCache;
+ return mpNoneCache;
+}
+
+ScDPTableDataCache* ScDPCacheTable::getCache()
{
if ( mpCache )
return mpCache;
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index b321b87..5f89a45 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -80,7 +80,7 @@ const sal_Int32 SC_DP_DATE_LAST = 10000;
// ============================================================================
namespace
{
- BOOL lcl_Search( SCCOL nSourceDim, ScDPTableDataCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
+ BOOL lcl_Search( SCCOL nSourceDim, const ScDPTableDataCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
{
rIndex = vIdx.size();
BOOL bFound = FALSE;
@@ -112,7 +112,7 @@ namespace
return bFound;
}
- void lcl_Insert( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, SCROW nNew )
+ void lcl_Insert( SCCOL nSourceDim, const ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, SCROW nNew )
{
SCROW nIndex = 0;
if ( !lcl_Search( nSourceDim, pCache, vIdx, nNew ,nIndex ) )
@@ -120,18 +120,18 @@ namespace
}
template<bool bUpdateData>
- SCROW lcl_InsertValue( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const ScDPItemData & rData );
+ SCROW lcl_InsertValue(SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData);
template<>
- SCROW lcl_InsertValue<false>( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const ScDPItemData & rData )
+ SCROW lcl_InsertValue<false>(SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
{
- SCROW nNewID = pCache->GetAdditionalItemID( rData );
- lcl_Insert( nSourceDim, pCache, vIdx, nNewID );
+ SCROW nNewID = pCache->GetAdditionalItemID(rData);
+ lcl_Insert(nSourceDim, pCache, vIdx, nNewID);
return nNewID;
}
template<>
- SCROW lcl_InsertValue<true>( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const ScDPItemData & rData )
+ SCROW lcl_InsertValue<true>(SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
{
SCROW nItemId = lcl_InsertValue<false>( nSourceDim, pCache, vIdx, rData );
@@ -142,13 +142,13 @@ namespace
}
template<bool bUpdateData>
- void lcl_InsertValue ( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const String& rString, const double& fValue )
+ void lcl_InsertValue ( SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue )
{
lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( rString, fValue, TRUE ) );
}
template<bool bUpdateData>
- void lcl_InsertValue ( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const String& rString, const double& fValue, sal_Int32 nDatePart )
+ void lcl_InsertValue ( SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue, sal_Int32 nDatePart )
{
lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( nDatePart, rString, fValue, ScDPItemData::MK_DATA|ScDPItemData::MK_VAL|ScDPItemData::MK_DATEPART ) );
}
@@ -600,7 +600,8 @@ String lcl_GetSpecialDateName( double fValue, bool bFirst, SvNumberFormatter* pF
return aBuffer.makeStringAndClear();
}
-void ScDPDateGroupHelper::FillColumnEntries( SCCOL nSourceDim, ScDPTableDataCache* pCache, std::vector< SCROW >& rEntries, const std::vector< SCROW >& rOriginal ) const
+void ScDPDateGroupHelper::FillColumnEntries(
+ SCCOL nSourceDim, const ScDPTableDataCache* pCache, std::vector<SCROW>& rEntries, const std::vector<SCROW>& rOriginal) const
{
// auto min/max is only used for "Years" part, but the loop is always needed
double fSourceMin = 0.0;
@@ -900,8 +901,8 @@ void ScDPNumGroupDimension::MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_I
aGroupInfo.Enable = sal_True; //! or query both?
}
-const std::vector< SCROW >& ScDPNumGroupDimension::GetNumEntries( SCCOL nSourceDim, ScDPTableDataCache* pCache,
- const std::vector< SCROW >& rOriginal ) const
+const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
+ SCCOL nSourceDim, const ScDPTableDataCache* pCache, const std::vector<SCROW>& rOriginal) const
{
if ( maMemberEntries.empty() )
{
@@ -1095,7 +1096,7 @@ const std::vector< SCROW >& ScDPGroupTableData::GetColumnEntries( long nColumn
{
// dimension number is unchanged for numerical groups
const std::vector< SCROW >& rOriginal = pSourceData->GetColumnEntries( nColumn );
- return pNumGroups[nColumn].GetNumEntries( (SCCOL)nColumn, GetCacheTable().getCache(), rOriginal );
+ return pNumGroups[nColumn].GetNumEntries( (SCCOL)nColumn, GetCacheTable().getCache(), rOriginal );
}
return pSourceData->GetColumnEntries( nColumn );
@@ -1337,7 +1338,7 @@ void ScDPGroupTableData::FillGroupValues( /*ScDPItemData* pItemData*/ SCROW* pIt
{
long nGroupedColumns = aGroups.size();
- ScDPTableDataCache* pCache = GetCacheTable().getCache();
+ const ScDPTableDataCache* pCache = GetCacheTable().getCache();
for (long nDim=0; nDim<nCount; nDim++)
{
const ScDPDateGroupHelper* pDateHelper = NULL;
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 5aef6c3..d137454 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -144,7 +144,7 @@ BOOL ScSheetDPData::IsDateDimension(long nDim)
}
else
{
- return aCacheTable.getCache()->IsDateDimension( nDim);
+ return GetCacheTable().getCache()->IsDateDimension( nDim);
}
}
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index ddcbb31..a4a239c 100644
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -301,13 +301,13 @@ long ScDPTableData::GetSourceDim( long nDim )
}
- long ScDPTableData::Compare( long nDim, long nDataId1, long nDataId2)
+long ScDPTableData::Compare( long nDim, long nDataId1, long nDataId2)
{
if ( getIsDataLayoutDimension(nDim) )
return 0;
- long n1 = GetCacheTable().getCache()->GetOrder( nDim, nDataId1);
- long n2 = GetCacheTable().getCache()->GetOrder( nDim, nDataId2);
+ long n1 = GetCacheTable().getOrder(nDim, nDataId1);
+ long n2 = GetCacheTable().getOrder(nDim, nDataId2);
if ( n1 > n2 )
return 1;
else if ( n1 == n2 )
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index f482d13..886420f 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -996,19 +996,19 @@ SCROW ScDPTableDataCache::GetIdByItemData( long nDim, const ScDPItemData& rData
return GetRowCount() + maAdditionalData.getDataId(rData);
}
-SCROW ScDPTableDataCache::GetAdditionalItemID ( String sItemData )
+SCROW ScDPTableDataCache::GetAdditionalItemID ( String sItemData ) const
{
ScDPItemData rData ( sItemData );
return GetAdditionalItemID( rData );
}
-SCROW ScDPTableDataCache::GetAdditionalItemID( const ScDPItemData& rData )
+SCROW ScDPTableDataCache::GetAdditionalItemID( const ScDPItemData& rData ) const
{
return GetRowCount() + maAdditionalData.insertData( rData );
}
-SCROW ScDPTableDataCache::GetOrder(long nDim, SCROW nIndex)
+SCROW ScDPTableDataCache::GetOrder(long nDim, SCROW nIndex) const
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
DBG_ASSERT( nDim >=0 && nDim < mnColumnCount, "ScDPTableDataCache::GetOrder : out of bound" );
@@ -1016,7 +1016,7 @@ SCROW ScDPTableDataCache::GetOrder(long nDim, SCROW nIndex)
if ( maIndexOrder[nDim].size() != maGlobalOrder[nDim].size() )
{ //not inited
SCROW i = 0;
- maIndexOrder[nDim].resize( maGlobalOrder[nDim].size(), 0 );
+ maIndexOrder[nDim].resize(maGlobalOrder[nDim].size(), 0);
for ( size_t n = 0 ; n< maGlobalOrder[nDim].size(); n++ )
{
i = maGlobalOrder[nDim][n];
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 685ace4..936bd0f 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -2796,7 +2796,7 @@ uno::Any SAL_CALL ScDPMember::getPropertyValue( const rtl::OUString& aPropertyNa
SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPMember )
-ScDPTableDataCache* ScDPSource::GetCache()
+const ScDPTableDataCache* ScDPSource::GetCache()
{
DBG_ASSERT( GetData() , "empty ScDPTableData pointer");
return ( GetData()!=NULL) ? GetData()->GetCacheTable().getCache() : NULL ;
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 43813b6..050b72c 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -544,7 +544,8 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
ScDPNumGroupDimension aTmpDim( rNumInfo );
if( nDatePart != 0 )
aTmpDim.MakeDateHelper( rNumInfo, nDatePart );
- const std::vector< SCROW > aMemberIds = aTmpDim.GetNumEntries( static_cast< SCCOL >( GetBaseFieldIndex() ), aDPData.GetCacheTable().getCache(), aOrignial );
+ const std::vector<SCROW>& aMemberIds = aTmpDim.GetNumEntries(
+ static_cast<SCCOL>( GetBaseFieldIndex() ), aDPData.GetCacheTable().getCache(), aOrignial);
for ( size_t nIdx = 0 ; nIdx < aMemberIds.size(); nIdx++ )
{
const ScDPItemData* pData = aDPData.GetMemberById( static_cast< long >( GetBaseFieldIndex() ) , aMemberIds[ nIdx] );
More information about the Libreoffice-commits
mailing list