[Libreoffice-commits] core.git: lotuswordpro/inc lotuswordpro/Library_lwpft.mk lotuswordpro/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Apr 26 12:56:55 UTC 2021


 lotuswordpro/Library_lwpft.mk                 |    2 +
 lotuswordpro/inc/xfilter/xfcell.hxx           |    2 +
 lotuswordpro/source/filter/lwprowlayout.cxx   |    7 +---
 lotuswordpro/source/filter/lwptablelayout.cxx |   17 +++++------
 lotuswordpro/source/filter/lwptablelayout.hxx |   38 +++++++++++++++++++++++---
 5 files changed, 48 insertions(+), 18 deletions(-)

New commits:
commit 1388540fe16d0843de18a3d14bedbf2e0b6d8d49
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Apr 25 20:41:02 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Apr 26 14:56:21 2021 +0200

    Revert "ofz#27296 Out-of-memory and ofz#27384 Indirect-leak"
    
    This reverts commit c80c8ac4eb58812c1b72aa0b0cef01ebb5337359.
    
    it seems blameless after all
    
    Change-Id: If0f95da5ee7f91fde0b679c9314e3da07f7779f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114631
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/lotuswordpro/Library_lwpft.mk b/lotuswordpro/Library_lwpft.mk
index f35568d3647b..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 \
@@ -37,6 +38,7 @@ $(eval $(call gb_Library_use_libraries,lwpft,\
 
 $(eval $(call gb_Library_use_externals,lwpft,\
 	boost_headers \
+	mdds_headers \
     icui18n \
     icuuc \
     icu_headers \
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/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx
index 3321f294469e..9590e41d9670 100644
--- a/lotuswordpro/source/filter/lwprowlayout.cxx
+++ b/lotuswordpro/source/filter/lwprowlayout.cxx
@@ -238,9 +238,7 @@ void LwpRowLayout::ConvertRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt8
                 m_ConnCellList[nMarkConnCell]->GetColID());
 
             //set all cell in this merge cell to cellsmap
-            for (sal_uInt16 nRowLoop = crowid; nRowLoop < nRowMark; nRowLoop++)
-                for (sal_uInt16 nColLoop = i; nColLoop < nColID+1; nColLoop++)
-                    pTableLayout->SetCellsMap(nRowLoop,nColLoop, xXFCell.get());
+            pTableLayout->SetCellsMap(crowid, i, nRowMark - 1, nColID, xXFCell.get());
 
             i += m_ConnCellList[nMarkConnCell]->GetNumcols();
             nMarkConnCell = FindNextMarkConnCell(static_cast<sal_uInt16>(nMarkConnCell),nEndCol);
@@ -433,8 +431,7 @@ void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sa
         }
         xRow->AddCell(xCell);
 
-        for (sal_uInt8 j=nCellStartCol;j<=nCellEndCol;j++)
-            pTableLayout->SetCellsMap(crowid,j, xCell.get());//set to cellsmap
+        pTableLayout->SetCellsMap(crowid, nCellStartCol, crowid, nCellEndCol, xCell.get()); //set to cellsmap
     }
 
     pXFTable->AddRow(xRow);
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 1deb854f333c..4f2c4c8d30ca 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -1415,10 +1415,10 @@ void LwpTableLayout::ConvertDefaultRow(rtl::Reference<XFTable> const & pXFTable,
  * @param   nRow - row id
  * @param   nCol - column id
  */
-void LwpTableLayout::SetCellsMap(sal_uInt16 nRow, sal_uInt8 nCol, XFCell* pXFCell)
+void LwpTableLayout::SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1,
+                                 sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell* pXFCell)
 {
-    // combine the 16bit nRow and 8bit nCol into a single 32bit number
-    m_CellsMap.insert(std::make_pair((nRow << 8) | nCol, pXFCell));
+    m_CellsMap.insert({{nRow1, nCol1}, {nRow2, nCol2}}, pXFCell);
 }
 
 /**
@@ -1429,13 +1429,12 @@ void LwpTableLayout::SetCellsMap(sal_uInt16 nRow, sal_uInt8 nCol, XFCell* pXFCel
  */
 XFCell* LwpTableLayout::GetCellsMap(sal_uInt16 nRow, sal_uInt8 nCol)
 {
-    RowCol pos = (nRow << 8) | nCol;
-    auto iter =  m_CellsMap.find(pos);
-    if (iter == m_CellsMap.end())
-        return nullptr;
-    return iter->second;
+    auto results = m_CellsMap.search({{nRow, nCol}, {nRow, nCol}}, rt_type::search_type::overlap);
+    if (results.begin() == results.end())
+       return nullptr;
+    // return the last thing inserted for this position
+    return std::prev(results.end())->GetCell();
 }
-
 /**
  * @descr   Get row layout by row id
  * @param   nRow - row id
diff --git a/lotuswordpro/source/filter/lwptablelayout.hxx b/lotuswordpro/source/filter/lwptablelayout.hxx
index 21ab84ec1c67..ca4d46812e55 100644
--- a/lotuswordpro/source/filter/lwptablelayout.hxx
+++ b/lotuswordpro/source/filter/lwptablelayout.hxx
@@ -63,11 +63,14 @@
 
 #include "lwplayout.hxx"
 #include <xfilter/xftable.hxx>
+#include <svl/hint.hxx>
+#include <svl/lstner.hxx>
+
+#include <mdds/rtree.hpp>
 
 #include <vector>
 #include <map>
 #include <memory>
-#include <unordered_map>
 
 class XFTableStyle;
 class XFTable;
@@ -95,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
@@ -148,7 +176,7 @@ public:
     void ConvertTable(rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartRow,
                 sal_uInt16 nEndRow,sal_uInt8 nStartCol,sal_uInt8 nEndCol);
     const OUString& GetDefaultRowStyleName() const {return m_DefaultRowStyleName;}
-    void SetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol,XFCell* pXFCell);
+    void SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1, sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell* pXFCell);
     XFCell* GetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol);
    const  std::map<sal_uInt16,LwpRowLayout*>& GetRowsMap() const {return m_RowsMap;}
     LwpRowLayout* GetRowLayout(sal_uInt16 nRow);
@@ -165,11 +193,13 @@ private:
     void SplitConflictCells();
     rtl::Reference<XFTable> m_pXFTable;
     bool m_bConverted;
-    typedef sal_Int32 RowCol;
-    std::unordered_map<RowCol, XFCell*> m_CellsMap;
+
+    using rt_type = mdds::rtree<int, XFCellListener>;
+    rt_type m_CellsMap;
 
     void PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID);
 };
+
 /**
  * @brief
  * VO_SUPERTABLELAYOUT object


More information about the Libreoffice-commits mailing list