[Libreoffice-commits] .: Branch 'libreoffice-3-4-2' - sc/inc sc/source

Michael Meeks michael at kemper.freedesktop.org
Tue Jul 19 04:05:55 PDT 2011


 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(-)

New commits:
commit a7e403a590146a80e1c44c3c56ebf974801f5b87
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Jul 14 18:38:16 2011 -0400

    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 at googlemail.com>
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>

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 );


More information about the Libreoffice-commits mailing list