summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-01-02 20:22:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-01-02 22:57:41 +0100
commit73631b1bf52a2e6dd8a85d6fef36d754c15dcf82 (patch)
treea780193ba94d10ed9bbd2995e74a79647af6aa3c /sw/source
parentf6e02294ce8d71a03c8e440e041094d2dd0a9834 (diff)
ofz#43052 crash in WW8TabDesc::MergeCells
Change-Id: I4d7acc006458598ad43033fa8e35b2f422d76ff5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127876 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx45
1 files changed, 45 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index a50e0b1d280c..e5037535a824 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -2791,6 +2791,46 @@ void WW8TabDesc::MoveOutsideTable()
*m_pIo->m_pPaM->GetPoint() = *m_xTmpPos->GetPoint();
}
+namespace
+{
+ class SwTableNodeListener final : public SwClient
+ {
+ private:
+ SwModify* m_pModify;
+
+ virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override
+ {
+ if (rHint.GetId() != SfxHintId::SwLegacyModify)
+ return;
+ auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
+ if (pLegacy->GetWhich() == RES_OBJECTDYING)
+ {
+ m_pModify->Remove(this);
+ m_pModify = nullptr;
+ }
+ }
+
+ public:
+ SwTableNodeListener(SwModify* pModify)
+ : m_pModify(pModify)
+ {
+ m_pModify->Add(this);
+ }
+
+ bool WasDeleted() const
+ {
+ return !m_pModify;
+ }
+
+ virtual ~SwTableNodeListener() override
+ {
+ if (!m_pModify)
+ return;
+ m_pModify->Remove(this);
+ }
+ };
+}
+
void WW8TabDesc::FinishSwTable()
{
m_pIo->m_xRedlineStack->closeall(*m_pIo->m_pPaM->GetPoint());
@@ -2800,6 +2840,8 @@ void WW8TabDesc::FinishSwTable()
std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_pIo->m_pLastAnchorPos ? m_pIo->m_rDoc.CreateUnoCursor(*m_pIo->m_pLastAnchorPos) : nullptr);
m_pIo->m_pLastAnchorPos.reset();
+ SwTableNode* pTableNode = m_pTable->GetTableNode();
+ SwTableNodeListener aListener(pTableNode);
m_pIo->m_xRedlineStack = std::move(mxOldRedlineStack);
if (xLastAnchorCursor)
@@ -2818,6 +2860,9 @@ void WW8TabDesc::FinishSwTable()
m_pIo->m_aInsertedTables.InsertTable(*m_pTableNd, *m_pIo->m_pPaM);
+ if (aListener.WasDeleted())
+ return;
+
MergeCells();
// if needed group cells together that should be merged