summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-07-14 18:38:16 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-07-14 18:45:43 -0400
commit4da044d0fbc45ad1de5ee8990bd7a5850d7a2fa2 (patch)
tree5c8e4a1d88767dad5676036ff86ae70ae8a2f002
parentcdb8cf074c8536aa3ea30102bcb9b34feda21833 (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.
-rw-r--r--sc/inc/dpobject.hxx2
-rw-r--r--sc/source/core/data/dpobject.cxx35
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx5
-rw-r--r--sc/source/ui/view/dbfunc3.cxx33
4 files changed, 42 insertions, 33 deletions
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 4bc1df9f0..919bc02d0 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 ec8644f07..f0b498c9b 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 a8c6b03b6..270b0979b 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 daa03eab3..3209ad2b5 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 );