Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi there,

I would like to commit the attached change to the -3-4 branch and
hopefully to the 3-4-2 branch as well.

This fixes

https://bugs.freedesktop.org/show_bug.cgi?id=37767

The refresh of data pilot table (or pivot table) was broken from the
UNO API because the code there had not been adopted for the new cache
storage scheme.  What the patch does is to move the code that clears
the existing cache from where it was to a new method, and call that
method from the UNO API code.

Review, sign-off etc appreciated.

Kohei
From 8d1b7b79c6abf63cd4f55a978cc83305a1f87680 Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kyoshida@novell.com>
Date: Thu, 14 Jul 2011 18:38:16 -0400
Subject: [PATCH] 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.
---
 sc/inc/dpobject.hxx              |    2 ++
 sc/source/core/data/dpobject.cxx |   35 +++++++++++++++++++++++++++++++++++
 sc/source/ui/unoobj/dapiuno.cxx  |    5 ++---
 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 510f308..87fb78e 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 93bfebb..4426763 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 9095d6e..e1e2877 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 5f427a8..c01a85b 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 );
-- 
1.7.6


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.