summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/dbfunc3.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/view/dbfunc3.cxx')
-rw-r--r--sc/source/ui/view/dbfunc3.cxx42
1 files changed, 39 insertions, 3 deletions
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index d2e185d05b47..e8e5baafb1f7 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -72,6 +72,8 @@
#include "dbdocfun.hxx"
#include "dpoutput.hxx"
#include "dptabsrc.hxx"
+#include "dpshttab.hxx"
+#include "dpsdbtab.hxx"
#include "editable.hxx"
#include "docpool.hxx"
#include "patattr.hxx"
@@ -697,13 +699,47 @@ void ScDBFunc::RecalcPivotTable()
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocument* pDoc = GetViewData()->GetDocument();
- // old pivot not used any more
-
+ ScDPCollection* pDPs = pDoc->GetDPCollection();
ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(),
GetViewData()->GetCurY(),
GetViewData()->GetTabNo() );
- if ( pDPObj )
+ if (pDPs && pDPObj)
{
+ // Remove existing data cache for the data that this datapilot uses,
+ // to force re-build data cache.
+ if (pDPObj->IsSheetData())
+ {
+ // 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);
+ }
+
ScDBDocFunc aFunc( *pDocSh );
aFunc.DataPilotUpdate( pDPObj, pDPObj, true, false );
CursorPosChanged(); // shells may be switched