chart2/source/controller/chartapiwrapper/AreaWrapper.cxx            |   11 -
 chart2/source/controller/chartapiwrapper/AreaWrapper.hxx            |    4 
 chart2/source/controller/chartapiwrapper/AxisWrapper.cxx            |   10 -
 chart2/source/controller/chartapiwrapper/AxisWrapper.hxx            |    4 
 chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx |   11 -
 chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx |    4 
 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx         |   12 -
 chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx         |    4 
 chart2/source/controller/chartapiwrapper/GridWrapper.cxx            |   10 -
 chart2/source/controller/chartapiwrapper/GridWrapper.hxx            |    4 
 chart2/source/controller/chartapiwrapper/LegendWrapper.cxx          |   11 -
 chart2/source/controller/chartapiwrapper/LegendWrapper.hxx          |    4 
 chart2/source/controller/chartapiwrapper/TitleWrapper.cxx           |   11 -
 chart2/source/controller/chartapiwrapper/TitleWrapper.hxx           |    4 
 chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx       |   11 -
 chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx       |    4 
 chart2/source/inc/WrappedPropertySet.hxx                            |    7 -
 svx/source/unodraw/unoshcol.cxx                                     |   62 
+++++-----
 18 files changed, 102 insertions(+), 86 deletions(-)

New commits:
commit bf9f9f1fbda73ea65d455d520954e2d38bbccb1d
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Feb 20 18:26:08 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Tue Feb 21 08:57:40 2023 +0000

    BaseMutex->std::mutex in chart::WrappedPropertySet
    
    Change-Id: Iaf3a31542d09426ced9e15dab1abd9aa3e04a8ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147375
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
index 68f449b91005..5c384c3ce134 100644
--- a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
@@ -73,7 +73,6 @@ namespace chart::wrapper
 
 AreaWrapper::AreaWrapper(std::shared_ptr<Chart2ModelContact> 
spChart2ModelContact)
     : m_spChart2ModelContact(std::move(spChart2ModelContact))
-    , m_aEventListenerContainer(m_aMutex)
 {
 }
 
@@ -110,23 +109,25 @@ OUString SAL_CALL AreaWrapper::getShapeType()
 // ____ XComponent ____
 void SAL_CALL AreaWrapper::dispose()
 {
+    std::unique_lock g(m_aMutex);
     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) 
);
 
-    MutexGuard aGuard( m_aMutex);
     clearWrappedPropertySet();
 }
 
 void SAL_CALL AreaWrapper::addEventListener(
     const Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL AreaWrapper::removeEventListener(
     const Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 // WrappedPropertySet
diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx
index 4216d728cbed..c150d5bbfcef 100644
--- a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx
@@ -20,7 +20,7 @@
 
 #include <WrappedPropertySet.hxx>
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/drawing/XShape.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -72,7 +72,7 @@ protected:
 
 private:
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 };
 
 } //  namespace chart::wrapper
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
index 1f71abeaff07..e49d674732a4 100644
--- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
@@ -372,7 +372,6 @@ namespace chart::wrapper
 AxisWrapper::AxisWrapper(
     tAxisType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) 
:
         m_spChart2ModelContact(std::move( spChart2ModelContact )),
-        m_aEventListenerContainer( m_aMutex ),
         m_eType( eType )
 {
 }
@@ -526,8 +525,9 @@ void AxisWrapper::getDimensionAndMainAxisBool( tAxisType 
eType, sal_Int32& rnDim
 // ____ XComponent ____
 void SAL_CALL AxisWrapper::dispose()
 {
+    std::unique_lock g(m_aMutex);
     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) 
);
 
     DisposeHelper::DisposeAndClear( m_xAxisTitle );
     DisposeHelper::DisposeAndClear( m_xMajorGrid );
@@ -539,13 +539,15 @@ void SAL_CALL AxisWrapper::dispose()
 void SAL_CALL AxisWrapper::addEventListener(
     const Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL AxisWrapper::removeEventListener(
     const Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 //ReferenceSizePropertyProvider
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
index 5bbb2646b17e..e70c85b23ff8 100644
--- a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
@@ -21,7 +21,7 @@
 #include <WrappedPropertySet.hxx>
 #include "ReferenceSizePropertyProvider.hxx"
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/chart/XAxis.hpp>
 #include <com/sun/star/drawing/XShape.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
@@ -109,7 +109,7 @@ private: //methods
 
 private: //member
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 
     tAxisType           m_eType;
 
diff --git 
a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
index 5db206f97528..83f4bd16843d 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -460,7 +460,6 @@ namespace chart::wrapper
 
 DataSeriesPointWrapper::DataSeriesPointWrapper( 
std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
     : m_spChart2ModelContact( std::move(spChart2ModelContact) )
-    , m_aEventListenerContainer( m_aMutex )
     , m_eType( DATA_SERIES )
     , m_nSeriesIndexInNewAPI( -1 )
     , m_nPointIndex( -1 )
@@ -503,7 +502,6 @@ DataSeriesPointWrapper::DataSeriesPointWrapper(eType _eType,
                                                sal_Int32 nPointIndex, 
//ignored for series
                                                
std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
     : m_spChart2ModelContact( std::move(spChart2ModelContact) )
-    , m_aEventListenerContainer( m_aMutex )
     , m_eType( _eType )
     , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI )
     , m_nPointIndex( (_eType == DATA_POINT) ? nPointIndex : -1 )
@@ -518,8 +516,9 @@ DataSeriesPointWrapper::~DataSeriesPointWrapper()
 // ____ XComponent ____
 void SAL_CALL DataSeriesPointWrapper::dispose()
 {
+    std::unique_lock g(m_aMutex);
     uno::Reference< uno::XInterface > xSource( static_cast< 
::cppu::OWeakObject* >( this ) );
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) 
);
 
     m_xDataSeries.clear();
     clearWrappedPropertySet();
@@ -528,13 +527,15 @@ void SAL_CALL DataSeriesPointWrapper::dispose()
 void SAL_CALL DataSeriesPointWrapper::addEventListener(
     const uno::Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL DataSeriesPointWrapper::removeEventListener(
     const uno::Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 // ____ XEventListener ____
diff --git 
a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
index f3fcf62c4e26..4c79bb25e9bb 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
@@ -21,7 +21,7 @@
 #include <WrappedPropertySet.hxx>
 #include "ReferenceSizePropertyProvider.hxx"
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XEventListener.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -105,7 +105,7 @@ private:
     css::uno::Reference< css::beans::XPropertySet > getDataPointProperties();
 
     std::shared_ptr< Chart2ModelContact >         m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 
     eType               m_eType;
     sal_Int32           m_nSeriesIndexInNewAPI;
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index d5ede5c7b5a0..332c018d786b 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -560,7 +560,6 @@ namespace chart::wrapper
 
 DiagramWrapper::DiagramWrapper(std::shared_ptr<Chart2ModelContact> 
spChart2ModelContact)
     : m_spChart2ModelContact(std::move(spChart2ModelContact))
-    , m_aEventListenerContainer(m_aMutex)
 {
 }
 
@@ -1052,9 +1051,8 @@ void SAL_CALL DiagramWrapper::setDefaultIllumination()
 // ____ XComponent ____
 void SAL_CALL DiagramWrapper::dispose()
 {
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< 
::cppu::OWeakObject* >( this )));
-
-    MutexGuard aGuard( m_aMutex);
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( 
static_cast< ::cppu::OWeakObject* >( this )));
 
     DisposeHelper::DisposeAndClear( m_xXAxis );
     DisposeHelper::DisposeAndClear( m_xYAxis );
@@ -1073,13 +1071,15 @@ void SAL_CALL DiagramWrapper::dispose()
 void SAL_CALL DiagramWrapper::addEventListener(
     const Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL DiagramWrapper::removeEventListener(
     const Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 namespace {
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
index 58cd8884b29c..3a3a8383de05 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
@@ -20,7 +20,7 @@
 
 #include <WrappedPropertySet.hxx>
 
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/chart/XDiagramPositioning.hpp>
 #include <com/sun/star/chart2/XDiagramProvider.hpp>
 #include <com/sun/star/chart/XDiagram.hpp>
@@ -186,7 +186,7 @@ protected:
 
 private:
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 
     css::uno::Reference<
         css::chart::XAxis >        m_xXAxis;
diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx
index c519398bb811..87653f67f1b7 100644
--- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx
@@ -75,7 +75,6 @@ namespace chart::wrapper
 
 GridWrapper::GridWrapper(tGridType eType, std::shared_ptr<Chart2ModelContact> 
spChart2ModelContact)
     : m_spChart2ModelContact(std::move(spChart2ModelContact))
-    , m_aEventListenerContainer(m_aMutex)
     , m_eType(eType)
 {
 }
@@ -108,8 +107,9 @@ void GridWrapper::getDimensionAndSubGridBool( tGridType 
eType, sal_Int32& rnDime
 // ____ XComponent ____
 void SAL_CALL GridWrapper::dispose()
 {
+    std::unique_lock g(m_aMutex);
     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) 
);
 
     clearWrappedPropertySet();
 }
@@ -117,13 +117,15 @@ void SAL_CALL GridWrapper::dispose()
 void SAL_CALL GridWrapper::addEventListener(
     const Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL GridWrapper::removeEventListener(
     const Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 // WrappedPropertySet
diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx
index a4a00a567353..c978f3bb8d83 100644
--- a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx
@@ -20,7 +20,7 @@
 
 #include <WrappedPropertySet.hxx>
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 
@@ -71,7 +71,7 @@ protected:
 
 private:
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 
     tGridType           m_eType;
 };
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
index 0c95f11f9565..1cea91eb5eea 100644
--- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
@@ -263,7 +263,6 @@ namespace chart::wrapper
 
 LegendWrapper::LegendWrapper(std::shared_ptr<Chart2ModelContact> 
spChart2ModelContact)
     : m_spChart2ModelContact(std::move(spChart2ModelContact))
-    , m_aEventListenerContainer(m_aMutex)
 {
 }
 
@@ -322,23 +321,25 @@ OUString SAL_CALL LegendWrapper::getShapeType()
 // ____ XComponent ____
 void SAL_CALL LegendWrapper::dispose()
 {
+    std::unique_lock g(m_aMutex);
     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) 
);
 
-    MutexGuard aGuard( m_aMutex);
     clearWrappedPropertySet();
 }
 
 void SAL_CALL LegendWrapper::addEventListener(
     const Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL LegendWrapper::removeEventListener(
     const Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 //ReferenceSizePropertyProvider
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx
index 311e71534bdf..5b4deac2a1f9 100644
--- a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx
@@ -21,7 +21,7 @@
 #include <WrappedPropertySet.hxx>
 #include "ReferenceSizePropertyProvider.hxx"
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/drawing/XShape.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -79,7 +79,7 @@ protected:
 
 private:
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 };
 
 } //  namespace chart::wrapper
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
index 9442253341ab..3a59015d9e67 100644
--- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
@@ -192,7 +192,6 @@ namespace chart::wrapper
 TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType,
     std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) :
         m_spChart2ModelContact(std::move( spChart2ModelContact )),
-        m_aEventListenerContainer( m_aMutex ),
         m_eTitleType(eTitleType)
 {
     ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
@@ -244,23 +243,25 @@ OUString SAL_CALL TitleWrapper::getShapeType()
 // ____ XComponent ____
 void SAL_CALL TitleWrapper::dispose()
 {
+    std::unique_lock g(m_aMutex);
     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) 
);
 
-    MutexGuard aGuard( m_aMutex);
     clearWrappedPropertySet();
 }
 
 void SAL_CALL TitleWrapper::addEventListener(
     const Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL TitleWrapper::removeEventListener(
     const Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 Reference< beans::XPropertySet > TitleWrapper::getFirstCharacterPropertySet()
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
index 6f61da8fc263..aecf5f304231 100644
--- a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
@@ -22,7 +22,7 @@
 #include "ReferenceSizePropertyProvider.hxx"
 #include <TitleHelper.hxx>
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/drawing/XShape.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -100,7 +100,7 @@ private:
     css::uno::Reference< css::chart2::XTitle > getTitleObject();
 
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 
     ::chart::TitleHelper::eTitleType        m_eTitleType;
 };
diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx
index 9b4333547e5d..c50edb623070 100644
--- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx
@@ -76,7 +76,6 @@ namespace chart::wrapper
 WallFloorWrapper::WallFloorWrapper( bool bWall,
     std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) :
         m_spChart2ModelContact(std::move( spChart2ModelContact )),
-        m_aEventListenerContainer( m_aMutex ),
         m_bWall( bWall )
 
 {
@@ -89,23 +88,25 @@ WallFloorWrapper::~WallFloorWrapper()
 // ____ XComponent ____
 void SAL_CALL WallFloorWrapper::dispose()
 {
+    std::unique_lock g(m_aMutex);
     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
-    m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+    m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) 
);
 
-    MutexGuard aGuard( m_aMutex);
     clearWrappedPropertySet();
 }
 
 void SAL_CALL WallFloorWrapper::addEventListener(
     const Reference< lang::XEventListener >& xListener )
 {
-    m_aEventListenerContainer.addInterface( xListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.addInterface( g, xListener );
 }
 
 void SAL_CALL WallFloorWrapper::removeEventListener(
     const Reference< lang::XEventListener >& aListener )
 {
-    m_aEventListenerContainer.removeInterface( aListener );
+    std::unique_lock g(m_aMutex);
+    m_aEventListenerContainer.removeInterface( g, aListener );
 }
 
 // WrappedPropertySet
diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx
index 7ad33bbf6248..4a85bd8d5b37 100644
--- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx
@@ -20,7 +20,7 @@
 
 #include <WrappedPropertySet.hxx>
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 
@@ -59,7 +59,7 @@ protected:
 
 private:
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
-    ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> 
m_aEventListenerContainer;
+    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 
     bool m_bWall;
 };
diff --git a/chart2/source/inc/WrappedPropertySet.hxx 
b/chart2/source/inc/WrappedPropertySet.hxx
index 3dc6e6a82dc3..ec3d43632c26 100644
--- a/chart2/source/inc/WrappedPropertySet.hxx
+++ b/chart2/source/inc/WrappedPropertySet.hxx
@@ -24,10 +24,10 @@
 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
-#include <cppuhelper/basemutex.hxx>
 #include <cppuhelper/implbase.hxx>
 
 #include <memory>
+#include <mutex>
 #include <vector>
 
 namespace cppu { class IPropertyArrayHelper; }
@@ -37,8 +37,7 @@ namespace chart
 {
 
 class OOO_DLLPUBLIC_CHARTTOOLS WrappedPropertySet :
-                           public cppu::BaseMutex
-                         , public ::cppu::WeakImplHelper
+                         public ::cppu::WeakImplHelper
                          < css::beans::XPropertySet
                          , css::beans::XMultiPropertySet
                          , css::beans::XPropertyState
@@ -103,6 +102,8 @@ protected: //methods
     const WrappedProperty*          getWrappedProperty( const OUString& 
rOuterName );
     const WrappedProperty*          getWrappedProperty( sal_Int32 nHandle );
 
+    std::mutex m_aMutex;
+
 private:
     css::uno::Reference< css::beans::XPropertySetInfo >     m_xInfo;//outer 
PropertySetInfo
 
commit bc1755038a6cb293748114cd5d40c03aa44124bb
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Feb 20 18:02:50 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Tue Feb 21 08:57:30 2023 +0000

    osl::Mutex->std::mutex in SvxShapeCollection
    
    Change-Id: I246c44b9e7ccf9eeadd4516eed9f6e4866d15736
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147374
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx
index 105ca6523b51..2c1a75a14a66 100644
--- a/svx/source/unodraw/unoshcol.cxx
+++ b/svx/source/unodraw/unoshcol.cxx
@@ -24,12 +24,11 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
-#include <cppuhelper/basemutex.hxx>
 #include <cppuhelper/implbase3.hxx>
-#include <cppuhelper/interfacecontainer.hxx>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <cppuhelper/supportsservice.hxx>
-#include <osl/mutex.hxx>
+#include <mutex>
+#include <osl/diagnose.h>
 #include <sal/log.hxx>
 
 using namespace ::com::sun::star;
@@ -38,13 +37,14 @@ using namespace ::com::sun::star::uno;
 namespace {
 
 class SvxShapeCollection :
-    public cppu::BaseMutex,
     public cppu::WeakAggImplHelper3<drawing::XShapes, lang::XServiceInfo, 
lang::XComponent>
 {
 private:
-    comphelper::OInterfaceContainerHelper3<drawing::XShape> maShapeContainer;
-
-    cppu::OBroadcastHelper mrBHelper;
+    std::mutex m_aMutex;
+    std::vector<uno::Reference<drawing::XShape>> maShapeContainer;
+    comphelper::OInterfaceContainerHelper4<lang::XEventListener> 
maEventListeners;
+    bool bDisposed = false;
+    bool bInDispose = false;
 
 public:
     SvxShapeCollection() noexcept;
@@ -76,7 +76,6 @@ public:
 };
 
 SvxShapeCollection::SvxShapeCollection() noexcept
-: maShapeContainer( m_aMutex ), mrBHelper( m_aMutex )
 {
 }
 
@@ -88,7 +87,7 @@ void SvxShapeCollection::release() noexcept
     {
         if (osl_atomic_decrement( &m_refCount ) == 0)
         {
-            if (! mrBHelper.bDisposed)
+            if (! bDisposed)
             {
                 uno::Reference< uno::XInterface > xHoldAlive( 
static_cast<uno::XWeak*>(this) );
                 // First dispose
@@ -125,13 +124,13 @@ void SvxShapeCollection::dispose()
     // Remark: It is an error to call dispose more than once
     bool bDoDispose = false;
     {
-    osl::MutexGuard aGuard( mrBHelper.rMutex );
-    if( !mrBHelper.bDisposed && !mrBHelper.bInDispose )
-    {
-        // only one call go into this section
-        mrBHelper.bInDispose = true;
-        bDoDispose = true;
-    }
+        std::unique_lock aGuard( m_aMutex );
+        if( !bDisposed && !bInDispose )
+        {
+            // only one call go into this section
+            bInDispose = true;
+            bDoDispose = true;
+        }
     }
 
     // Do not hold the mutex because we are broadcasting
@@ -145,7 +144,8 @@ void SvxShapeCollection::dispose()
             aEvt.Source = xSource;
             // inform all listeners to release this object
             // The listener container are automatically cleared
-            mrBHelper.aLC.disposeAndClear( aEvt );
+            std::unique_lock g(m_aMutex);
+            maEventListeners.disposeAndClear( g, aEvt );
             maShapeContainer.clear();
         }
         catch(const css::uno::Exception&)
@@ -153,15 +153,15 @@ void SvxShapeCollection::dispose()
             // catch exception and throw again but signal that
             // the object was disposed. Dispose should be called
             // only once.
-            mrBHelper.bDisposed = true;
-            mrBHelper.bInDispose = false;
+            bDisposed = true;
+            bInDispose = false;
             throw;
         }
 
         // the values bDispose and bInDisposing must set in this order.
         // No multithread call overcome the "!rBHelper.bDisposed && 
!rBHelper.bInDispose" guard.
-        mrBHelper.bDisposed = true;
-        mrBHelper.bInDispose = false;
+        bDisposed = true;
+        bInDispose = false;
     }
     else
     {
@@ -174,32 +174,37 @@ void SvxShapeCollection::dispose()
 // XComponent
 void SAL_CALL SvxShapeCollection::addEventListener( const css::uno::Reference< 
css::lang::XEventListener >& aListener )
 {
-    mrBHelper.addListener( cppu::UnoType<decltype(aListener)>::get() , 
aListener );
+    std::unique_lock g(m_aMutex);
+    maEventListeners.addInterface( g, aListener );
 }
 
 // XComponent
 void SAL_CALL SvxShapeCollection::removeEventListener( const 
css::uno::Reference< css::lang::XEventListener >& aListener )
 {
-    mrBHelper.removeListener( cppu::UnoType<decltype(aListener)>::get() , 
aListener );
+    std::unique_lock g(m_aMutex);
+    maEventListeners.removeInterface( g, aListener );
 }
 
 // XShapes
 
 void SAL_CALL SvxShapeCollection::add( const Reference< drawing::XShape >& 
xShape )
 {
-    maShapeContainer.addInterface( xShape );
+    std::unique_lock g(m_aMutex);
+    maShapeContainer.push_back( xShape );
 }
 
 
 void SAL_CALL SvxShapeCollection::remove( const uno::Reference< 
drawing::XShape >& xShape )
 {
-    maShapeContainer.removeInterface( xShape );
+    std::unique_lock g(m_aMutex);
+    maShapeContainer.erase(std::remove(maShapeContainer.begin(), 
maShapeContainer.end(), xShape), maShapeContainer.end());
 }
 
 
 sal_Int32 SAL_CALL SvxShapeCollection::getCount()
 {
-    return maShapeContainer.getLength();
+    std::unique_lock g(m_aMutex);
+    return maShapeContainer.size();
 }
 
 
@@ -208,7 +213,8 @@ uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 
Index )
     if( Index < 0 || Index >= getCount() )
         throw lang::IndexOutOfBoundsException();
 
-    Reference<drawing::XShape> xShape = maShapeContainer.getInterface(Index);
+    std::unique_lock g(m_aMutex);
+    Reference<drawing::XShape> xShape = maShapeContainer[Index];
     return uno::Any( xShape );
 }
 

Reply via email to