lotuswordpro/Library_lwpft.mk | 1 + lotuswordpro/source/filter/lwprowlayout.cxx | 7 ++----- lotuswordpro/source/filter/lwptablelayout.cxx | 19 ++++++++++--------- lotuswordpro/source/filter/lwptablelayout.hxx | 10 ++++++---- 4 files changed, 19 insertions(+), 18 deletions(-)
New commits: commit 473c1b05f7a7a5500a2e15b911263b546792b013 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sat Oct 17 16:40:28 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Oct 18 20:07:48 2020 +0200 ofz#26357 Timeout in lwpfuzzer, 12s -> 1.3s Change-Id: I1f1e2f1727b698d761adaf0d388d731fc80e280f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104467 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/lotuswordpro/Library_lwpft.mk b/lotuswordpro/Library_lwpft.mk index f35568d3647b..e7536e9f7a64 100644 --- a/lotuswordpro/Library_lwpft.mk +++ b/lotuswordpro/Library_lwpft.mk @@ -37,6 +37,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/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 5ea2d42db9a4..2494501ff3d9 100644 --- a/lotuswordpro/source/filter/lwptablelayout.cxx +++ b/lotuswordpro/source/filter/lwptablelayout.cxx @@ -1402,16 +1402,17 @@ void LwpTableLayout::ConvertDefaultRow(rtl::Reference<XFTable> const & pXFTable, pXFTable->AddRow(xRow); } + /** * @short set cell map info * @param pXFCell - pointer to xfcell * @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); } /** @@ -1422,17 +1423,17 @@ 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()); } /** * @descr Get row layout by row id * @param nRow - row id */ - LwpRowLayout* LwpTableLayout::GetRowLayout(sal_uInt16 nRow) +LwpRowLayout* LwpTableLayout::GetRowLayout(sal_uInt16 nRow) { LwpObjectID *pRowID = &GetChildHead(); LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get()); diff --git a/lotuswordpro/source/filter/lwptablelayout.hxx b/lotuswordpro/source/filter/lwptablelayout.hxx index 21ab84ec1c67..fe8312414587 100644 --- a/lotuswordpro/source/filter/lwptablelayout.hxx +++ b/lotuswordpro/source/filter/lwptablelayout.hxx @@ -64,10 +64,11 @@ #include "lwplayout.hxx" #include <xfilter/xftable.hxx> +#include <mdds/rtree.hpp> + #include <vector> #include <map> #include <memory> -#include <unordered_map> class XFTableStyle; class XFTable; @@ -148,7 +149,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,8 +166,9 @@ 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, XFCell*>; + rt_type m_CellsMap; void PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID); }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits