lotuswordpro/Library_lwpft.mk                 |    1 
 lotuswordpro/inc/xfilter/xfcell.hxx           |    2 +
 lotuswordpro/source/filter/lwptablelayout.cxx |    2 -
 lotuswordpro/source/filter/lwptablelayout.hxx |   30 +++++++++++++++++++++++++-
 4 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit e40d28d65222ba462c20ede17da5ef54751932e3
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Nov 6 10:35:31 2020 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Nov 6 15:01:21 2020 +0100

    ofz#27012 detect deletion of XFCell
    
    Change-Id: I22aabfcbb43c09ab174176a2a2898b4bf0b55afc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105395
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/lotuswordpro/Library_lwpft.mk b/lotuswordpro/Library_lwpft.mk
index e7536e9f7a64..5965b385e1bc 100644
--- a/lotuswordpro/Library_lwpft.mk
+++ b/lotuswordpro/Library_lwpft.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_Library_use_libraries,lwpft,\
        i18nlangtag \
     sfx \
     sot \
+    svl \
     svt \
     svxcore \
     tl \
diff --git a/lotuswordpro/inc/xfilter/xfcell.hxx 
b/lotuswordpro/inc/xfilter/xfcell.hxx
index 81ab8aa59028..1e75107019de 100644
--- a/lotuswordpro/inc/xfilter/xfcell.hxx
+++ b/lotuswordpro/inc/xfilter/xfcell.hxx
@@ -63,6 +63,7 @@
 
 #include <xfilter/xfcontent.hxx>
 #include <xfilter/xfcontentcontainer.hxx>
+#include <svl/SfxBroadcaster.hxx>
 
 class XFTable;
 class XFRow;
@@ -71,6 +72,7 @@ class XFRow;
  * @descr   Table cell object.
  */
 class XFCell : public XFContentContainer
+             , public SfxBroadcaster
 {
 public:
     XFCell();
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx 
b/lotuswordpro/source/filter/lwptablelayout.cxx
index b6a61d9198ce..f49c3f01dc68 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -1433,7 +1433,7 @@ XFCell* LwpTableLayout::GetCellsMap(sal_uInt16 nRow, 
sal_uInt8 nCol)
     if (results.begin() == results.end())
        return nullptr;
     // return the last thing inserted for this position
-    return *std::prev(results.end());
+    return std::prev(results.end())->GetCell();
 }
 /**
  * @descr   Get row layout by row id
diff --git a/lotuswordpro/source/filter/lwptablelayout.hxx 
b/lotuswordpro/source/filter/lwptablelayout.hxx
index fe8312414587..ca4d46812e55 100644
--- a/lotuswordpro/source/filter/lwptablelayout.hxx
+++ b/lotuswordpro/source/filter/lwptablelayout.hxx
@@ -63,6 +63,8 @@
 
 #include "lwplayout.hxx"
 #include <xfilter/xftable.hxx>
+#include <svl/hint.hxx>
+#include <svl/lstner.hxx>
 
 #include <mdds/rtree.hpp>
 
@@ -96,6 +98,31 @@ struct TableConvertAttempt
     }
 };
 
+class XFCellListener : public SfxListener
+{
+public:
+    XFCellListener(XFCell* pCell)
+        : m_pCell(pCell)
+    {
+        if (m_pCell)
+            StartListening(*m_pCell);
+    }
+
+    XFCell* GetCell()
+    {
+        return m_pCell;
+    }
+
+private:
+    XFCell* m_pCell;
+
+    virtual void Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) override
+    {
+        if (rHint.GetId() == SfxHintId::Dying)
+            m_pCell = nullptr;
+    }
+};
+
 /**
  * @brief
  * VO_TABLELAYOUT object and functions for registering styles and converting 
tables
@@ -167,11 +194,12 @@ private:
     rtl::Reference<XFTable> m_pXFTable;
     bool m_bConverted;
 
-    using rt_type = mdds::rtree<int, XFCell*>;
+    using rt_type = mdds::rtree<int, XFCellListener>;
     rt_type m_CellsMap;
 
     void PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID);
 };
+
 /**
  * @brief
  * VO_SUPERTABLELAYOUT object
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to