summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2022-11-13 11:07:40 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2022-11-14 09:36:05 +0100
commitb257b4f247bc2a1fa4d469ec82e37bdbb268951b (patch)
treea7da4dc74655149100edb4519a3ea4e17a99bcc6 /svx
parentf06353aadfc1a9329da0d5fe0cb5878d124b01aa (diff)
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>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/table/svdotable.cxx22
-rw-r--r--svx/source/table/tabledesign.cxx6
2 files changed, 21 insertions, 7 deletions
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);