summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/dbdocfun.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/docshell/dbdocfun.cxx')
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx54
1 files changed, 38 insertions, 16 deletions
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 983f29d431b0..acbace69428a 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -1386,6 +1386,19 @@ bool ScDBDocFunc::CreatePivotTable(const ScDPObject& rDPObj, bool bRecord, bool
if (rDoc.GetDPCollection()->GetByName(rDestObj.GetName()))
rDestObj.SetName(OUString()); // ignore the invalid name, create a new name below
+ // Syncronize groups between linked tables
+ {
+ bool bRefFound = false;
+ const ScDPDimensionSaveData* pGroups = nullptr;
+ bRefFound = rDoc.GetDPCollection()->GetReferenceGroups(rDestObj, &pGroups);
+ if (bRefFound)
+ {
+ ScDPSaveData* pSaveData = rDestObj.GetSaveData();
+ if (pSaveData)
+ pSaveData->SetDimensionData(pGroups);
+ }
+ }
+
if (!rDoc.GetDPCollection()->InsertNewTable(pDestObj.release()))
// Insertion into collection failed.
return false;
@@ -1567,25 +1580,34 @@ void ScDBDocFunc::RefreshPivotTableGroups(ScDPObject* pDPObj)
if (!pSaveData)
return;
- std::set<ScDPObject*> aRefs;
- if (!pDPs->ReloadGroupsInCache(pDPObj, aRefs))
- return;
-
- // We allow pDimData being NULL.
- const ScDPDimensionSaveData* pDimData = pSaveData->GetExistingDimensionData();
- std::set<ScDPObject*>::iterator it = aRefs.begin(), itEnd = aRefs.end();
- for (; it != itEnd; ++it)
+ // Update all linked tables, if this table is part of the cache (ScDPCollection)
+ if (pDPs->HasTable(pDPObj))
{
- ScDPObject* pObj = *it;
- if (pObj != pDPObj)
+ std::set<ScDPObject*> aRefs;
+ if (!pDPs->ReloadGroupsInCache(pDPObj, aRefs))
+ return;
+
+ // We allow pDimData being NULL.
+ const ScDPDimensionSaveData* pDimData = pSaveData->GetExistingDimensionData();
+ std::set<ScDPObject*>::iterator it = aRefs.begin(), itEnd = aRefs.end();
+ for (; it != itEnd; ++it)
{
- pSaveData = pObj->GetSaveData();
- if (pSaveData)
- pSaveData->SetDimensionData(pDimData);
- }
+ ScDPObject* pObj = *it;
+ if (pObj != pDPObj)
+ {
+ pSaveData = pObj->GetSaveData();
+ if (pSaveData)
+ pSaveData->SetDimensionData(pDimData);
+ }
- // This action is intentionally not undoable since it modifies cache.
- UpdatePivotTable(*pObj, false, false);
+ // This action is intentionally not undoable since it modifies cache.
+ UpdatePivotTable(*pObj, false, false);
+ }
+ }
+ else // Otherwise update only this single table
+ {
+ // This table is under construction so no need for a whole update (UpdatePivotTable()).
+ pDPObj->ReloadGroupTableData();
}
}