diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-07-14 18:38:16 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-07-14 18:45:43 -0400 |
commit | 0e8927f4ab0138f226f70b9e4d772fa06cbf8106 (patch) | |
tree | fe1679e4ceb6d27e9c17b9b3e873a3e49549faa5 /sc | |
parent | 9d489c96a9c2cc53680739db4905976b2b10d20d (diff) |
fdo#37767: Fix broken refresh() from UNO API (and Basic).
We now need to clear the cache before running DataPilotUpdate() in
order to re-populate the cache from the source data.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/dpobject.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 33 |
4 files changed, 42 insertions, 33 deletions
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index ae34b4ba0c52..dc0831eb95a4 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -313,6 +313,8 @@ public: ScDPCollection(const ScDPCollection& r); ~ScDPCollection(); + bool ClearCache(ScDPObject* pDPObj); + SC_DLLPUBLIC size_t GetCount() const; SC_DLLPUBLIC ScDPObject* operator[](size_t nIndex); SC_DLLPUBLIC const ScDPObject* operator[](size_t nIndex) const; diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 17ab9a827cba..5aee5b71b0a9 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2591,6 +2591,41 @@ public: } +bool ScDPCollection::ClearCache(ScDPObject* pDPObj) +{ + if (pDPObj->IsSheetData()) + { + // data source is internal sheet. + const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc(); + if (!pDesc) + return false; + + if (pDesc->HasRangeName()) + { + // cache by named range + ScDPCollection::NameCaches& rCaches = GetNameCaches(); + rCaches.removeCache(pDesc->GetRangeName()); + } + else + { + // cache by cell range + ScDPCollection::SheetCaches& rCaches = GetSheetCaches(); + rCaches.removeCache(pDesc->GetSourceRange()); + } + } + else if (pDPObj->IsImportData()) + { + // data source is external database. + const ScImportSourceDesc* pDesc = pDPObj->GetImportSourceDesc(); + if (!pDesc) + return false; + + ScDPCollection::DBCaches& rCaches = GetDBCaches(); + rCaches.removeCache(pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject); + } + return true; +} + void ScDPCollection::DeleteOnTab( SCTAB nTab ) { maTables.erase( diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 0a269770e878..85702ad5cafb 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1273,10 +1273,9 @@ void SAL_CALL ScDataPilotTableObj::refresh() throw(RuntimeException) 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 + GetDocShell()->GetDocument()->GetDPCollection()->ClearCache(pDPObj); + aFunc.DataPilotUpdate( pDPObj, pDPObj, true, true ); } } diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index ec794dcb7d89..9158fb828633 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -707,37 +707,10 @@ void ScDBFunc::RecalcPivotTable() { // Remove existing data cache for the data that this datapilot uses, // to force re-build data cache. - if (pDPObj->IsSheetData()) + if (!pDPs->ClearCache(pDPObj)) { - // data source is internal sheet. - const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc(); - if (!pDesc) - { - ErrorMessage(STR_PIVOT_NOTFOUND); - return; - } - if (pDesc->HasRangeName()) - { - ScDPCollection::NameCaches& rCaches = pDPs->GetNameCaches(); - rCaches.removeCache(pDesc->GetRangeName()); - } - else - { - ScDPCollection::SheetCaches& rCaches = pDPs->GetSheetCaches(); - rCaches.removeCache(pDesc->GetSourceRange()); - } - } - else if (pDPObj->IsImportData()) - { - // data source is external database. - const ScImportSourceDesc* pDesc = pDPObj->GetImportSourceDesc(); - if (!pDesc) - { - ErrorMessage(STR_PIVOT_NOTFOUND); - return; - } - ScDPCollection::DBCaches& rCaches = pDPs->GetDBCaches(); - rCaches.removeCache(pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject); + ErrorMessage(STR_PIVOT_NOTFOUND); + return; } ScDBDocFunc aFunc( *pDocSh ); |