diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-02-28 21:27:41 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-02-28 21:27:41 -0500 |
commit | e7db4c4fdc5d969f59ebee8a6b7848a9dc733c71 (patch) | |
tree | ccc3c0f443b143e74a3f1bec1c0e9d61efc28707 | |
parent | 3b7bd5c1dd1031a79e82a0333b11bf70bb94102e (diff) |
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.
-rw-r--r-- | sc/inc/dpcachetable.hxx | 4 | ||||
-rw-r--r-- | sc/inc/dpobject.hxx | 13 | ||||
-rw-r--r-- | sc/inc/dpsdbtab.hxx | 3 | ||||
-rw-r--r-- | sc/inc/dpshttab.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/dpcachetable.cxx | 38 | ||||
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 158 | ||||
-rw-r--r-- | sc/source/core/data/dpsdbtab.cxx | 60 | ||||
-rw-r--r-- | sc/source/core/data/dpshttab.cxx | 44 | ||||
-rw-r--r-- | sc/source/ui/inc/dbfunc.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 54 |
11 files changed, 34 insertions, 358 deletions
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx index 25a18bef1c13..5e5bb24c3b21 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 443f4b29bd0f..8cf4661e4f2b 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 ac49e4a642c6..a35b9ce9c3d2 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 7cb899d8b168..601271e72e90 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 a10990ec0722..6ddc61c8871e 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 228859db5e07..eca78bf1dc4b 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 0b9bf6b4d06e..46a6977cca04 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 cae121c36157..2bfee3f6f463 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 +long ScSheetSourceDesc::GetCacheId() 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 -{ - 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 27a7c92f7ebc..6c04731e341f 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 fb775a8ae84c..e0bcc9b65853 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 aeb28de50f3d..d5e91c586b3f 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 ) |