kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0058-fdo-66969-Reset-group-dimension-data-from-all-refere.patch

f0633d
From b8339a06050fcbff25e3c990e1ff8ca02dc7bad5 Mon Sep 17 00:00:00 2001
f0633d
From: Kohei Yoshida <kohei.yoshida@collabora.com>
f0633d
Date: Tue, 10 Dec 2013 15:56:06 -0500
f0633d
Subject: [PATCH 058/109] fdo#66969: Reset group dimension data from all
f0633d
 referencing pivot objects.
f0633d
f0633d
The previous code was doing it only with the first referencing pivot table,
f0633d
which would break the rest of them sharing the same cache if
f0633d
the first one doesn't contain all group dimensions used in all of the
f0633d
referencing pivot tables.
f0633d
f0633d
Change-Id: I35d6907ef8db7ed69db42583cac92b2b74406e2c
f0633d
(cherry picked from commit b3977983e9f662392426f581516d86d7034ad0fd)
f0633d
Reviewed-on: https://gerrit.libreoffice.org/7028
f0633d
Reviewed-by: Eike Rathke <erack@redhat.com>
f0633d
Tested-by: Eike Rathke <erack@redhat.com>
f0633d
---
f0633d
 sc/inc/dpobject.hxx              | 10 +++----
f0633d
 sc/source/core/data/dpobject.cxx | 57 ++++++++++++++++++++++++++--------------
f0633d
 2 files changed, 42 insertions(+), 25 deletions(-)
f0633d
f0633d
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
f0633d
index 06d4957..51d4790 100644
f0633d
--- a/sc/inc/dpobject.hxx
f0633d
+++ b/sc/inc/dpobject.hxx
f0633d
@@ -290,7 +290,7 @@ public:
f0633d
     private:
f0633d
         ScDPCache* getExistingCache(const ScRange& rRange);
f0633d
 
f0633d
-        void updateCache(const ScRange& rRange, const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs);
f0633d
+        void updateCache(const ScRange& rRange, std::set<ScDPObject*>& rRefs);
f0633d
         bool remove(const ScDPCache* p);
f0633d
     };
f0633d
 
f0633d
@@ -313,8 +313,7 @@ public:
f0633d
         ScDPCache* getExistingCache(const OUString& rName);
f0633d
 
f0633d
         void updateCache(
f0633d
-            const OUString& rName, const ScRange& rRange,
f0633d
-            const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs);
f0633d
+            const OUString& rName, const ScRange& rRange, std::set<ScDPObject*>& rRefs);
f0633d
         bool remove(const ScDPCache* p);
f0633d
     };
f0633d
 
f0633d
@@ -358,8 +357,9 @@ public:
f0633d
         com::sun::star::uno::Reference<com::sun::star::sdbc::XRowSet> createRowSet(
f0633d
             sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand);
f0633d
 
f0633d
-        void updateCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand,
f0633d
-                         const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs);
f0633d
+        void updateCache(
f0633d
+            sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand,
f0633d
+            std::set<ScDPObject*>& rRefs);
f0633d
         bool remove(const ScDPCache* p);
f0633d
     };
f0633d
 
f0633d
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
f0633d
index 169231a..653bc0c 100644
f0633d
--- a/sc/source/core/data/dpobject.cxx
f0633d
+++ b/sc/source/core/data/dpobject.cxx
f0633d
@@ -2809,6 +2809,25 @@ struct FindInvalidRange : public std::unary_function<ScRange, bool>
f0633d
     }
f0633d
 };
f0633d
 
f0633d
+void setGroupItemsToCache( ScDPCache& rCache, const std::set<ScDPObject*>& rRefs )
f0633d
+{
f0633d
+    // Go through all referencing pivot tables, and re-fill the group dimension info.
f0633d
+    std::set<ScDPObject*>::const_iterator itRef = rRefs.begin(), itRefEnd = rRefs.end();
f0633d
+    for (; itRef != itRefEnd; ++itRef)
f0633d
+    {
f0633d
+        const ScDPObject* pObj = *itRef;
f0633d
+        const ScDPSaveData* pSave = pObj->GetSaveData();
f0633d
+        if (!pSave)
f0633d
+            continue;
f0633d
+
f0633d
+        const ScDPDimensionSaveData* pGroupDims = pSave->GetExistingDimensionData();
f0633d
+        if (!pGroupDims)
f0633d
+            continue;
f0633d
+
f0633d
+        pGroupDims->WriteToCache(rCache);
f0633d
+    }
f0633d
+}
f0633d
+
f0633d
 }
f0633d
 
f0633d
 bool ScDPCollection::SheetCaches::hasCache(const ScRange& rRange) const
f0633d
@@ -2926,8 +2945,7 @@ void ScDPCollection::SheetCaches::updateReference(
f0633d
     }
f0633d
 }
f0633d
 
f0633d
-void ScDPCollection::SheetCaches::updateCache(
f0633d
-    const ScRange& rRange, const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs)
f0633d
+void ScDPCollection::SheetCaches::updateCache(const ScRange& rRange, std::set<ScDPObject*>& rRefs)
f0633d
 {
f0633d
     RangeIndexType::iterator it = std::find(maRanges.begin(), maRanges.end(), rRange);
f0633d
     if (it == maRanges.end())
f0633d
@@ -2947,12 +2965,15 @@ void ScDPCollection::SheetCaches::updateCache(
f0633d
     }
f0633d
 
f0633d
     ScDPCache& rCache = *itCache->second;
f0633d
+
f0633d
+    // Update the cache with new cell values. This will clear all group dimension info.
f0633d
     rCache.InitFromDoc(mpDoc, rRange);
f0633d
-    if (pDimData)
f0633d
-        pDimData->WriteToCache(rCache);
f0633d
 
f0633d
     std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
f0633d
     rRefs.swap(aRefs);
f0633d
+
f0633d
+    // Make sure to re-populate the group dimension info.
f0633d
+    setGroupItemsToCache(rCache, rRefs);
f0633d
 }
f0633d
 
f0633d
 bool ScDPCollection::SheetCaches::remove(const ScDPCache* p)
f0633d
@@ -3010,8 +3031,7 @@ size_t ScDPCollection::NameCaches::size() const
f0633d
 }
f0633d
 
f0633d
 void ScDPCollection::NameCaches::updateCache(
f0633d
-    const OUString& rName, const ScRange& rRange, const ScDPDimensionSaveData* pDimData,
f0633d
-    std::set<ScDPObject*>& rRefs)
f0633d
+    const OUString& rName, const ScRange& rRange, std::set<ScDPObject*>& rRefs)
f0633d
 {
f0633d
     CachesType::iterator itr = maCaches.find(rName);
f0633d
     if (itr == maCaches.end())
f0633d
@@ -3021,12 +3041,14 @@ void ScDPCollection::NameCaches::updateCache(
f0633d
     }
f0633d
 
f0633d
     ScDPCache& rCache = *itr->second;
f0633d
+    // Update the cache with new cell values. This will clear all group dimension info.
f0633d
     rCache.InitFromDoc(mpDoc, rRange);
f0633d
-    if (pDimData)
f0633d
-        pDimData->WriteToCache(rCache);
f0633d
 
f0633d
     std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
f0633d
     rRefs.swap(aRefs);
f0633d
+
f0633d
+    // Make sure to re-populate the group dimension info.
f0633d
+    setGroupItemsToCache(rCache, rRefs);
f0633d
 }
f0633d
 
f0633d
 bool ScDPCollection::NameCaches::remove(const ScDPCache* p)
f0633d
@@ -3171,7 +3193,7 @@ uno::Reference<sdbc::XRowSet> ScDPCollection::DBCaches::createRowSet(
f0633d
 
f0633d
 void ScDPCollection::DBCaches::updateCache(
f0633d
     sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand,
f0633d
-    const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs)
f0633d
+    std::set<ScDPObject*>& rRefs)
f0633d
 {
f0633d
     DBType aType(nSdbType, rDBName, rCommand);
f0633d
     CachesType::iterator it = maCaches.find(aType);
f0633d
@@ -3204,12 +3226,12 @@ void ScDPCollection::DBCaches::updateCache(
f0633d
         return;
f0633d
     }
f0633d
 
f0633d
-    if (pDimData)
f0633d
-        pDimData->WriteToCache(rCache);
f0633d
-
f0633d
     comphelper::disposeComponent(xRowSet);
f0633d
     std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
f0633d
     aRefs.swap(rRefs);
f0633d
+
f0633d
+    // Make sure to re-populate the group dimension info.
f0633d
+    setGroupItemsToCache(rCache, rRefs);
f0633d
 }
f0633d
 
f0633d
 bool ScDPCollection::DBCaches::remove(const ScDPCache* p)
f0633d
@@ -3271,11 +3293,6 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
f0633d
     if (!pDPObj)
f0633d
         return STR_ERR_DATAPILOTSOURCE;
f0633d
 
f0633d
-    const ScDPSaveData* pSaveData = pDPObj->GetSaveData();
f0633d
-    const ScDPDimensionSaveData* pDimData = NULL;
f0633d
-    if (pSaveData)
f0633d
-        pDimData = pSaveData->GetExistingDimensionData();
f0633d
-
f0633d
     if (pDPObj->IsSheetData())
f0633d
     {
f0633d
         // data source is internal sheet.
f0633d
@@ -3292,7 +3309,7 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
f0633d
             // cache by named range
f0633d
             ScDPCollection::NameCaches& rCaches = GetNameCaches();
f0633d
             if (rCaches.hasCache(pDesc->GetRangeName()))
f0633d
-                rCaches.updateCache(pDesc->GetRangeName(), pDesc->GetSourceRange(), pDimData, rRefs);
f0633d
+                rCaches.updateCache(pDesc->GetRangeName(), pDesc->GetSourceRange(), rRefs);
f0633d
             else
f0633d
             {
f0633d
                 // Not cached yet.  Collect all tables that use this named
f0633d
@@ -3305,7 +3322,7 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
f0633d
             // cache by cell range
f0633d
             ScDPCollection::SheetCaches& rCaches = GetSheetCaches();
f0633d
             if (rCaches.hasCache(pDesc->GetSourceRange()))
f0633d
-                rCaches.updateCache(pDesc->GetSourceRange(), pDimData, rRefs);
f0633d
+                rCaches.updateCache(pDesc->GetSourceRange(), rRefs);
f0633d
             else
f0633d
             {
f0633d
                 // Not cached yet.  Collect all tables that use this range as
f0633d
@@ -3324,7 +3341,7 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
f0633d
         ScDPCollection::DBCaches& rCaches = GetDBCaches();
f0633d
         if (rCaches.hasCache(pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject))
f0633d
             rCaches.updateCache(
f0633d
-                pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject, pDimData, rRefs);
f0633d
+                pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject, rRefs);
f0633d
         else
f0633d
         {
f0633d
             // Not cached yet.  Collect all tables that use this range as
f0633d
-- 
f0633d
1.8.4.2
f0633d