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 <momonasmon@gmail.com>
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 7764f35..c605bb8 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 e2f629a..ec31697 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);