diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-30 16:46:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-30 22:55:26 +0100 |
commit | 80fc91db239869b513f47866f45d8a43fb98fe16 (patch) | |
tree | 831e267c7afcbef4e853da3348419a45d381211e | |
parent | aab0322580c87864a4f0c0af1fed07282c8dccbb (diff) |
ofz#4753 Bad-cast, check all open tables
Change-Id: Ie6e2fb9f2e16e021a4719c418f52ce074c359904
Reviewed-on: https://gerrit.libreoffice.org/47199
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 29 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.hxx | 13 |
2 files changed, 32 insertions, 10 deletions
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index dba4c5242f6c..50bcffa1554a 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -1043,10 +1043,14 @@ HTMLTable::HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab, for( sal_uInt16 i=0; i<m_nCols; i++ ) m_pColumns->push_back(o3tl::make_unique<HTMLTableColumn>()); + + m_pParser->RegisterHTMLTable(this); } HTMLTable::~HTMLTable() { + m_pParser->DeregisterHTMLTable(this); + delete m_pResizeDrawObjects; delete m_pDrawObjectPrcWidths; @@ -5256,16 +5260,21 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust, bool SwHTMLParser::CurrentTableInPaM(SwPaM& rPam) const { - if (!m_xTable) - return false; - const SwTable *pTable = m_xTable->GetSwTable(); - if (!pTable) - return false; - const SwTableNode* pTableNode = pTable->GetTableNode(); - if (!pTableNode) - return false; - SwNodeIndex aTableNodeIndex(*pTableNode); - return (aTableNodeIndex >= rPam.Start()->nNode && aTableNodeIndex <= rPam.End()->nNode); + bool bRet = false; + for (const auto& a : m_aTables) + { + const SwTable *pTable = a->GetSwTable(); + if (!pTable) + continue; + const SwTableNode* pTableNode = pTable->GetTableNode(); + if (!pTableNode) + continue; + SwNodeIndex aTableNodeIndex(*pTableNode); + bRet = (aTableNodeIndex >= rPam.Start()->nNode && aTableNodeIndex <= rPam.End()->nNode); + if (bRet) + break; + } + return bRet; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 7ba0e42ace00..0048278e0756 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -413,6 +413,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient SwNodeIndex *m_pSttNdIdx; std::shared_ptr<HTMLTable> m_xTable; // current "outermost" table + std::vector<HTMLTable*> m_aTables; SwHTMLForm_Impl *m_pFormImpl; // current form SdrObject *m_pMarquee; // current marquee SwField *m_pField; // current field @@ -908,6 +909,18 @@ public: virtual bool ParseMetaOptions( const css::uno::Reference<css::document::XDocumentProperties>&, SvKeyValueIterator* ) override; + + + void RegisterHTMLTable(HTMLTable* pNew) + { + m_aTables.push_back(pNew); + } + + void DeregisterHTMLTable(HTMLTable* pOld) + { + m_aTables.erase(std::remove(m_aTables.begin(), m_aTables.end(), pOld)); + } + }; struct SwPendingStackData |