diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-01 17:34:23 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-17 17:48:14 +0100 |
commit | 0763b640cc6f36946b5046bc1a262c902680dbd2 (patch) | |
tree | 13ded445323801d70750124b0aba77ca57da15d2 | |
parent | e9fab2e6869f335abedd7a462a4b523cf1d6657f (diff) |
ofz#40593 remove Objects from m_xResizeDrawObjects if deleted during parse
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124563
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 2f01faaf88b6d172d7293f0c9e2a061d99b8ceb5)
fix misplaced line
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124630
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 4ed359093c991291216c39cffe14a60e607ec551)
Change-Id: I11fa665175ef067a36f4822676c02d4df1e1e250
-rw-r--r-- | sw/qa/core/data/html/pass/ofz40593-1.html | bin | 0 -> 5192 bytes | |||
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 32 |
2 files changed, 29 insertions, 3 deletions
diff --git a/sw/qa/core/data/html/pass/ofz40593-1.html b/sw/qa/core/data/html/pass/ofz40593-1.html Binary files differnew file mode 100644 index 000000000000..43510d5d00b2 --- /dev/null +++ b/sw/qa/core/data/html/pass/ofz40593-1.html diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index ce689df01b9d..670ed3ae7aeb 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -34,6 +34,7 @@ #include <svtools/htmlkywd.hxx> #include <svl/urihelper.hxx> #include <svl/listener.hxx> +#include <svx/sdrobjectuser.hxx> #include <sal/log.hxx> #include <dcontact.hxx> @@ -372,7 +373,7 @@ typedef std::vector<HTMLTableColumn> HTMLTableColumns; typedef std::vector<SdrObject *> SdrObjects; -class HTMLTable +class HTMLTable : public sdr::ObjectUser { OUString m_aId; OUString m_aStyle; @@ -520,6 +521,8 @@ private: sal_uInt16 GetBorderWidth( const SvxBorderLine& rBLine, bool bWithDistance=false ) const; + virtual void ObjectInDestruction(const SdrObject& rObject) override; + public: bool m_bFirstCell; // is there a cell created already? @@ -529,7 +532,7 @@ public: bool bHasToFly, const HTMLTableOptions& rOptions); - ~HTMLTable(); + virtual ~HTMLTable(); // Identifying of a cell const HTMLTableCell& GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const; @@ -1065,11 +1068,33 @@ bool SwHTMLParser::IsReqIF() const return m_bReqIF; } +// if any m_pResizeDrawObjects members are deleted during parse, remove them +// from m_pResizeDrawObjects and m_pDrawObjectPrcWidths +void HTMLTable::ObjectInDestruction(const SdrObject& rObject) +{ + auto it = std::find(m_pResizeDrawObjects->begin(), m_pResizeDrawObjects->end(), &rObject); + assert(it != m_pResizeDrawObjects->end()); + auto nIndex = std::distance(m_pResizeDrawObjects->begin(), it); + m_pResizeDrawObjects->erase(it); + auto otherit = m_pDrawObjectPrcWidths->begin() + nIndex * 3; + m_pDrawObjectPrcWidths->erase(otherit, otherit + 3); +} + HTMLTable::~HTMLTable() { m_pParser->DeregisterHTMLTable(this); - m_pResizeDrawObjects.reset(); + if (m_pResizeDrawObjects) + { + size_t nCount = m_pResizeDrawObjects->size(); + for (size_t i = 0; i < nCount; ++i) + { + SdrObject *pObj = (*m_pResizeDrawObjects)[i]; + pObj->RemoveObjectUser(*this); + } + m_pResizeDrawObjects.reset(); + } + m_pDrawObjectPrcWidths.reset(); m_pContext.reset(); @@ -2483,6 +2508,7 @@ void HTMLTable::RegisterDrawObject( SdrObject *pObj, sal_uInt8 nPrcWidth ) if( !m_pResizeDrawObjects ) m_pResizeDrawObjects.reset(new SdrObjects); m_pResizeDrawObjects->push_back( pObj ); + pObj->AddObjectUser(*this); if( !m_pDrawObjectPrcWidths ) m_pDrawObjectPrcWidths.reset(new std::vector<sal_uInt16>); |