svx/source/table/tabledesign.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+)
New commits: commit 1a25000f91cae9f4275ec4a5c1d390fe7e52a86d Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Fri Oct 7 01:40:26 2022 +0300 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Fri Oct 7 10:24:24 2022 +0200 svx: Destroy unused table styles Loading sd document with a table, replaces the built in table style with the one loaded from the document. But the old one used to not be destroyed, because it set as a listener of its cell styles. Change-Id: I8ae0a553207df20233886656307bb4ad371993f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141043 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx index 03b16250f03e..e2f629a2cb87 100644 --- a/svx/source/table/tabledesign.cxx +++ b/svx/source/table/tabledesign.cxx @@ -377,7 +377,12 @@ void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any& void TableDesignStyle::disposing(std::unique_lock<std::mutex>&) { for(Reference<XStyle> & rCellStyle : maCellStyles) + { + Reference<XModifyBroadcaster> xBroadcaster(rCellStyle, UNO_QUERY); + if (xBroadcaster) + xBroadcaster->removeModifyListener(this); rCellStyle.clear(); + } } @@ -569,6 +574,9 @@ void SAL_CALL TableDesignFamily::removeByName( const OUString& rName ) [&rName](const Reference<XStyle>& rpStyle) { return rpStyle->getName() == rName; }); if (iter != maDesigns.end()) { + Reference<XComponent> xComponent(*iter, UNO_QUERY); + if (xComponent) + xComponent->dispose(); maDesigns.erase( iter ); return; } @@ -592,6 +600,9 @@ void SAL_CALL TableDesignFamily::replaceByName( const OUString& rName, const Any [&rName](const Reference<XStyle>& rpStyle) { return rpStyle->getName() == rName; }); if (iter != maDesigns.end()) { + Reference<XComponent> xComponent(*iter, UNO_QUERY); + if (xComponent) + xComponent->dispose(); (*iter) = xStyle; xStyle->setName( rName ); return;