summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/chartlis.hxx2
-rw-r--r--sc/inc/externalrefmgr.hxx2
-rw-r--r--sc/source/core/tool/chartlis.cxx9
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx8
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx3
5 files changed, 19 insertions, 5 deletions
diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index 3273a61a1da2..7e351082f4f7 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -56,7 +56,7 @@ public:
ScChartListener& mrParent;
std::unordered_set<sal_uInt16> maFileIds;
- ScDocument& mrDoc;
+ ScDocument* m_pDoc;
};
private:
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 20931043bfd1..d31145046d52 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -374,7 +374,7 @@ public:
typedef std::set<ScFormulaCell*> RefCellSet;
typedef std::unordered_map<sal_uInt16, RefCellSet> RefCellMap;
- enum LinkUpdateType { LINK_MODIFIED, LINK_BROKEN };
+ enum LinkUpdateType { LINK_MODIFIED, LINK_BROKEN, OH_NO_WE_ARE_GOING_TO_DIE };
/**
* Base class for objects that need to listen to link updates. When a
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 18b69b12d92b..3566e357f67b 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -50,18 +50,18 @@ public:
// ScChartListener
ScChartListener::ExternalRefListener::ExternalRefListener(ScChartListener& rParent, ScDocument& rDoc) :
- mrParent(rParent), mrDoc(rDoc)
+ mrParent(rParent), m_pDoc(&rDoc)
{
}
ScChartListener::ExternalRefListener::~ExternalRefListener()
{
- if (mrDoc.IsInDtorClear())
+ if (!m_pDoc || m_pDoc->IsInDtorClear())
// The document is being destroyed. Do nothing.
return;
// Make sure to remove all pointers to this object.
- mrDoc.GetExternalRefManager()->removeLinkListener(this);
+ m_pDoc->GetExternalRefManager()->removeLinkListener(this);
}
void ScChartListener::ExternalRefListener::notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType)
@@ -79,6 +79,9 @@ void ScChartListener::ExternalRefListener::notify(sal_uInt16 nFileId, ScExternal
case ScExternalRefManager::LINK_BROKEN:
removeFileId(nFileId);
break;
+ case ScExternalRefManager::OH_NO_WE_ARE_GOING_TO_DIE:
+ m_pDoc = nullptr;
+ break;
}
}
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 3d1845cbeacb..f03815fdaa16 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -3106,6 +3106,14 @@ void ScExternalRefManager::setFilterData(sal_uInt16 nFileId, const OUString& rFi
void ScExternalRefManager::clear()
{
+ for (auto& rEntry : maLinkListeners)
+ {
+ for (auto& it : rEntry.second)
+ {
+ it->notify(0, OH_NO_WE_ARE_GOING_TO_DIE);
+ }
+ }
+
for (auto& rEntry : maDocShells)
rEntry.second.maShell->DoClose();
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 447e3b2ae6d0..adc244bacc78 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2916,6 +2916,9 @@ void ScChart2DataSequence::ExternalRefListener::notify(sal_uInt16 nFileId, ScExt
case ScExternalRefManager::LINK_BROKEN:
maFileIds.erase(nFileId);
break;
+ case ScExternalRefManager::OH_NO_WE_ARE_GOING_TO_DIE:
+ mpDoc = nullptr;
+ break;
}
}