summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-04-02 15:45:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-04-02 19:28:57 +0200
commitc59a2c22e930d323b95f42089928baa1cad4224a (patch)
treec54b1b5b54d3b5e331d9478e48c8bb6a88fc0c63
parentb89c2909d48c9e4838d589085882e356439dcbbb (diff)
convert TableModel to comphelper::WeakComponentImplHelper
Change-Id: I548a33e93c14c40c6cd500e3306a8e4279e73f52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165678 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--svx/source/inc/tablemodel.hxx14
-rw-r--r--svx/source/table/tablemodel.cxx40
2 files changed, 24 insertions, 30 deletions
diff --git a/svx/source/inc/tablemodel.hxx b/svx/source/inc/tablemodel.hxx
index 7a2cf4851c7e..3446604bc722 100644
--- a/svx/source/inc/tablemodel.hxx
+++ b/svx/source/inc/tablemodel.hxx
@@ -23,8 +23,8 @@
#include <sal/types.h>
#include <com/sun/star/util/XBroadcaster.hpp>
#include <com/sun/star/table/XTable.hpp>
-#include <cppuhelper/compbase.hxx>
-#include <cppuhelper/basemutex.hxx>
+#include <comphelper/compbase.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include "celltypes.hxx"
struct _xmlTextWriter;
@@ -48,9 +48,9 @@ protected:
~ICellRange() {}
};
-typedef ::cppu::WeakComponentImplHelper< css::table::XTable, css::util::XBroadcaster > TableModelBase;
+typedef ::comphelper::WeakComponentImplHelper< css::table::XTable, css::util::XBroadcaster > TableModelBase;
-class TableModel final : public ::cppu::BaseMutex,
+class TableModel final :
public TableModelBase,
public ICellRange
{
@@ -99,7 +99,7 @@ public:
virtual ::sal_Int32 SAL_CALL getColumnCount() override;
// XComponent
- virtual void SAL_CALL dispose( ) override;
+// virtual void disposing(std::unique_lock<std::mutex>& rGuard) override;
// XModifiable
virtual sal_Bool SAL_CALL isModified( ) override;
@@ -158,7 +158,7 @@ private:
private:
/** this function is called upon disposing the component
*/
- virtual void SAL_CALL disposing() override;
+ virtual void disposing(std::unique_lock<std::mutex>& rGuard) override;
/// @throws css::lang::IndexOutOfBoundsException
TableRowRef const & getRow( sal_Int32 nRow ) const;
@@ -180,6 +180,8 @@ private:
bool mbNotifyPending;
sal_Int32 mnNotifyLock;
+
+ comphelper::OInterfaceContainerHelper4<css::util::XModifyListener> maModifyListeners;
};
class TableModelNotifyGuard
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index dc0f10e16109..c2d0af6444ef 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -94,8 +94,7 @@ template< class Vec, class Iter, class Entry > static sal_Int32 insert_range( Ve
TableModel::TableModel( SdrTableObj* pTableObj )
-: TableModelBase( m_aMutex )
-, mpTableObj( pTableObj )
+: mpTableObj( pTableObj )
, mbModified( false )
, mbNotifyPending( false )
, mnNotifyLock( 0 )
@@ -103,8 +102,7 @@ TableModel::TableModel( SdrTableObj* pTableObj )
}
TableModel::TableModel( SdrTableObj* pTableObj, const TableModelRef& xSourceTable )
-: TableModelBase( m_aMutex )
-, mpTableObj( pTableObj )
+: mpTableObj( pTableObj )
, mbModified( false )
, mbNotifyPending( false )
, mnNotifyLock( 0 )
@@ -311,15 +309,6 @@ std::vector<sal_Int32> TableModel::getColumnWidths()
return aRet;
}
-// XComponent
-
-
-void TableModel::dispose()
-{
- ::SolarMutexGuard aGuard;
- TableModelBase::dispose();
-}
-
// XModifiable
@@ -347,13 +336,15 @@ void SAL_CALL TableModel::setModified( sal_Bool bModified )
void SAL_CALL TableModel::addModifyListener( const uno::Reference<util::XModifyListener>& xListener )
{
- rBHelper.addListener( cppu::UnoType<util::XModifyListener>::get() , xListener );
+ std::unique_lock aGuard(m_aMutex);
+ maModifyListeners.addInterface( aGuard, xListener );
}
void SAL_CALL TableModel::removeModifyListener( const uno::Reference<util::XModifyListener>& xListener )
{
- rBHelper.removeListener( cppu::UnoType<util::XModifyListener>::get() , xListener );
+ std::unique_lock aGuard(m_aMutex);
+ maModifyListeners.removeInterface( aGuard, xListener );
}
@@ -486,8 +477,11 @@ sal_Int32 TableModel::getColumnCountImpl() const
}
-void TableModel::disposing()
+void TableModel::disposing(std::unique_lock<std::mutex>& rGuard)
{
+ rGuard.unlock(); // do not hold this while taking solar mutex
+ ::SolarMutexGuard aGuard;
+
if( !maRows.empty() )
{
for( auto& rpRow : maRows )
@@ -515,6 +509,8 @@ void TableModel::disposing()
}
mpTableObj = nullptr;
+
+ rGuard.lock();
}
@@ -543,18 +539,14 @@ void TableModel::unlockBroadcasts()
void TableModel::notifyModification()
{
- ::osl::MutexGuard guard( m_aMutex );
if( (mnNotifyLock == 0) && mpTableObj )
{
mbNotifyPending = false;
- ::cppu::OInterfaceContainerHelper * pModifyListeners = rBHelper.getContainer( cppu::UnoType<util::XModifyListener>::get() );
- if( pModifyListeners )
- {
- lang::EventObject aSource;
- aSource.Source = getXWeak();
- pModifyListeners->notifyEach(&util::XModifyListener::modified, aSource);
- }
+ lang::EventObject aSource;
+ aSource.Source = getXWeak();
+ std::unique_lock aGuard(m_aMutex);
+ maModifyListeners.notifyEach(aGuard, &util::XModifyListener::modified, aSource);
}
else
{