diff options
Diffstat (limited to 'sc/source/core/data')
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 531ab8176a0b..db529fbdff4c 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2847,7 +2847,10 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co } if (pDimData) + { + (itCache->second)->ClearGroupFields(); pDimData->WriteToCache(*itCache->second); + } return itCache->second.get(); } @@ -3440,6 +3443,71 @@ bool ScDPCollection::ReloadGroupsInCache(ScDPObject* pDPObj, std::set<ScDPObject return true; } +bool ScDPCollection::GetReferenceGroups(const ScDPObject& rDPObj, const ScDPDimensionSaveData** pGroups) const +{ + for (const std::unique_ptr<ScDPObject>& aTable : maTables) + { + const ScDPObject& rRefObj = *aTable.get(); + + if (&rRefObj == &rDPObj) + continue; + + if (rDPObj.IsSheetData()){ + if(!rRefObj.IsSheetData()) + continue; + + const ScSheetSourceDesc* pDesc = rDPObj.GetSheetDesc(); + const ScSheetSourceDesc* pRefDesc = rRefObj.GetSheetDesc(); + if (pDesc == nullptr || pRefDesc == nullptr) + continue; + + if (pDesc->HasRangeName()) + { + if (!pRefDesc->HasRangeName()) + continue; + + if (pDesc->GetRangeName() == pRefDesc->GetRangeName()) + { + *pGroups = rRefObj.GetSaveData()->GetExistingDimensionData(); + return true; + } + } + else + { + if (pRefDesc->HasRangeName()) + continue; + + if (pDesc->GetSourceRange() == pRefDesc->GetSourceRange()) + { + *pGroups = rRefObj.GetSaveData()->GetExistingDimensionData(); + return true; + } + } + } + else if (rDPObj.IsImportData()) + { + if (!rRefObj.IsImportData ()) + continue; + + const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc(); + const ScImportSourceDesc* pRefDesc = rRefObj.GetImportSourceDesc(); + if (pDesc == nullptr || pRefDesc == nullptr) + continue; + + if (pDesc->aDBName.equals(pRefDesc->aDBName) && + pDesc->aObject.equals(pRefDesc->aObject) && + pDesc->GetCommandType() == pRefDesc->GetCommandType()) + { + *pGroups = rRefObj.GetSaveData()->GetExistingDimensionData(); + return true; + } + + } + } + return false; +} + + void ScDPCollection::DeleteOnTab( SCTAB nTab ) { maTables.erase( std::remove_if(maTables.begin(), maTables.end(), MatchByTable(nTab)), maTables.end()); @@ -3619,6 +3687,18 @@ bool ScDPCollection::InsertNewTable(ScDPObject* pDPObj) return true; } +bool ScDPCollection::HasTable(const ScDPObject* pDPObj) const +{ + for (const std::unique_ptr<ScDPObject>& aTable : maTables) + { + if (aTable.get() == pDPObj) + { + return true; + } + } + return false; +} + ScDPCollection::SheetCaches& ScDPCollection::GetSheetCaches() { return maSheetCaches; |