From 35e43ce1b1f32acab5bba15425fa86fa0edd6c52 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 3 Feb 2020 21:16:27 +0000 Subject: ofz#20507 infinite table conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I779ab29d93491a296156fcc14557755754c2afdf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87924 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- lotuswordpro/source/filter/lwptablelayout.cxx | 24 +++++++++++++++++++++++- lotuswordpro/source/filter/lwptablelayout.hxx | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'lotuswordpro/source') diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx index 0698b1b56a7e..6cf91d345506 100644 --- a/lotuswordpro/source/filter/lwptablelayout.cxx +++ b/lotuswordpro/source/filter/lwptablelayout.cxx @@ -81,10 +81,12 @@ #include #include "lwpframelayout.hxx" #include -#include #include #include +#include +#include + LwpSuperTableLayout::LwpSuperTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm) : LwpPlacableLayout(objHdr, pStrm) { @@ -1057,6 +1059,14 @@ bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, sal_uInt8* pCellMark, return bFindFlag; } +static bool operator==(const TableConvertAttempt& a, const TableConvertAttempt& b) +{ + return a.mnStartRow == b.mnStartRow && + a.mnEndRow == b.mnEndRow && + a.mnStartCol== b.mnStartCol && + a.mnEndCol == b.mnEndCol; +} + /** * @short convert word pro table to SODC table * @param pXFTable - pointer of table @@ -1068,6 +1078,16 @@ bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, sal_uInt8* pCellMark, void LwpTableLayout::ConvertTable(rtl::Reference const & pXFTable, sal_uInt16 nStartRow, sal_uInt16 nEndRow,sal_uInt8 nStartCol,sal_uInt8 nEndCol) { + TableConvertAttempt aConversionAttempt(nStartRow, nEndRow, nStartCol, nEndCol); + auto itr = std::find(m_aConvertingStack.begin(), m_aConvertingStack.end(), aConversionAttempt); + if (itr != m_aConvertingStack.end()) + { + SAL_WARN("lwp", "already trying to convert this range"); + return; + } + + m_aConvertingStack.push_back(aConversionAttempt); + //out put column info TO BE CHANGED ConvertColumn(pXFTable,nStartCol,nEndCol); @@ -1096,6 +1116,8 @@ void LwpTableLayout::ConvertTable(rtl::Reference const & pXFTable, sal_ } } } + + m_aConvertingStack.pop_back(); } /** diff --git a/lotuswordpro/source/filter/lwptablelayout.hxx b/lotuswordpro/source/filter/lwptablelayout.hxx index 5e232dba73b4..9cc0c885aa49 100644 --- a/lotuswordpro/source/filter/lwptablelayout.hxx +++ b/lotuswordpro/source/filter/lwptablelayout.hxx @@ -81,6 +81,19 @@ class LwpRowHeadingLayout; class LwpConnectedCellLayout; class LwpColumnLayout; +struct TableConvertAttempt +{ + sal_uInt16 mnStartRow; + sal_uInt16 mnEndRow; + sal_uInt8 mnStartCol; + sal_uInt8 mnEndCol; + + TableConvertAttempt(sal_uInt16 nStartRow, sal_uInt16 nEndRow, sal_uInt8 nStartCol, sal_uInt8 nEndCol) + : mnStartRow(nStartRow), mnEndRow(nEndRow), mnStartCol(nStartCol), mnEndCol(nEndCol) + { + } +}; + /** * @brief * VO_TABLELAYOUT object and functions for registering styles and converting tables @@ -115,6 +128,8 @@ protected: sal_uInt16 m_nRows; sal_uInt16 m_nCols; + std::vector m_aConvertingStack; + private: //CColumnLayoutHead cColumnLayout; LwpObjectID m_ColumnLayout; -- cgit