svx/source/table/svdotable.cxx | 22 +++++++++++++++++----- svx/source/table/tabledesign.cxx | 6 ++++-- 2 files changed, 21 insertions(+), 7 deletions(-)
New commits: commit b257b4f247bc2a1fa4d469ec82e37bdbb268951b Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Sun Nov 13 11:07:40 2022 +0200 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Mon Nov 14 09:36:05 2022 +0100 svx: On table style removal, revert to the default style Change-Id: Ie299634c93640a89d9c98b2cd517c5cb83434ea7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142666 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 7764f35d1842..c605bb8c2e8c 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -749,12 +749,24 @@ void SdrTableObjImpl::dumpAsXml(xmlTextWriterPtr pWriter) const // XEventListener -void SAL_CALL SdrTableObjImpl::disposing( const css::lang::EventObject& /*Source*/ ) +void SAL_CALL SdrTableObjImpl::disposing( const css::lang::EventObject& Source ) { - mxActiveCell.clear(); - mxTable.clear(); - mpLayouter.reset(); - mpTableObj = nullptr; + assert(Source.Source == mxTableStyle); + (void)Source; + + Reference<XIndexAccess> xDefaultStyle; + try + { + Reference<XStyleFamiliesSupplier> xSupplier(mpTableObj->getSdrModelFromSdrObject().getUnoModel(), UNO_QUERY_THROW); + Reference<XNameAccess> xTableFamily(xSupplier->getStyleFamilies()->getByName("table"), UNO_QUERY_THROW); + xDefaultStyle.set(xTableFamily->getByName("default"), UNO_QUERY_THROW); + } + catch( Exception& ) + { + TOOLS_WARN_EXCEPTION("svx.table", ""); + } + + mpTableObj->setTableStyle(xDefaultStyle); } diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx index e2f629a2cb87..ec316972232d 100644 --- a/svx/source/table/tabledesign.cxx +++ b/svx/source/table/tabledesign.cxx @@ -109,7 +109,7 @@ public: void notifyModifyListener(); // this function is called upon disposing the component - virtual void disposing(std::unique_lock<std::mutex>&) override; + virtual void disposing(std::unique_lock<std::mutex>& aGuard) override; static const CellStyleNameMap& getCellStyleNameMap(); @@ -374,8 +374,10 @@ void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any& // XComponent -void TableDesignStyle::disposing(std::unique_lock<std::mutex>&) +void TableDesignStyle::disposing(std::unique_lock<std::mutex>& aGuard) { + maModifyListeners.disposeAndClear(aGuard, EventObject(Reference<XComponent>(this))); + for(Reference<XStyle> & rCellStyle : maCellStyles) { Reference<XModifyBroadcaster> xBroadcaster(rCellStyle, UNO_QUERY);