diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-07-14 18:38:16 -0400 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-07-15 01:21:02 +0200 |
commit | 09de7aee1763246642c9e0991180793fda31adc2 (patch) | |
tree | 90acaab0f39ab7f0211dd43f3478daee8a11f85e | |
parent | 923514a2dc7a0de237eba70f131f361efd33865a (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.
Signed-off-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-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 510f3083f..87fb78ee0 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -322,6 +322,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 93bfebba5..442676340 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2575,6 +2575,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 9095d6ecd..e1e2877ab 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1282,10 +1282,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 5f427a80c..c01a85b2f 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 ); |