summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-14 19:05:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-15 07:25:55 +0000
commit95f69903640f8b6d3c0c5798b74339d0ae62bd05 (patch)
tree7961d3899d2b065a16061ad0614691d6849048a1 /svx
parenta3a151ccfbb7560f7e96523efa350b174888f359 (diff)
osl::Mutex->std::mutex in SvxShape
Change-Id: I4b2d13dcd87f49cb73e7239102498629239005d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147036 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdobj.cxx16
-rw-r--r--svx/source/unodraw/shapepropertynotifier.cxx25
-rw-r--r--svx/source/unodraw/unoshape.cxx40
3 files changed, 42 insertions, 39 deletions
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index f9e061d59e17..e733c2d83871 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -2960,25 +2960,23 @@ css::uno::Reference< css::drawing::XShape > SdrObject::getUnoShape()
return xShape;
}
-svx::PropertyChangeNotifier& SdrObject::getShapePropertyChangeNotifier()
+void SdrObject::notifyShapePropertyChange( const svx::ShapePropertyProviderId _eProperty ) const
{
DBG_TESTSOLARMUTEX();
- SvxShape* pSvxShape = getSvxShape();
- ENSURE_OR_THROW( pSvxShape, "no SvxShape, yet!" );
- return pSvxShape->getShapePropertyChangeNotifier();
+ SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape();
+ if ( pSvxShape )
+ return pSvxShape->notifyPropertyChange( _eProperty );
}
-void SdrObject::notifyShapePropertyChange( const svx::ShapePropertyProviderId _eProperty ) const
+void SdrObject::registerProvider( const svx::ShapePropertyProviderId _eProperty, std::unique_ptr<svx::PropertyValueProvider> provider )
{
DBG_TESTSOLARMUTEX();
- SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape();
- if ( pSvxShape )
- return pSvxShape->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty );
+ SvxShape* pSvxShape = getSvxShape();
+ return pSvxShape->registerProvider( _eProperty, std::move(provider) );
}
-
// transformation interface for StarOfficeAPI. This implements support for
// homogeneous 3x3 matrices containing the transformation of the SdrObject. At the
// moment it contains a shearX, rotation and translation, but for setting all linear
diff --git a/svx/source/unodraw/shapepropertynotifier.cxx b/svx/source/unodraw/shapepropertynotifier.cxx
index 1ffb6cf6f678..a1b1ad07a626 100644
--- a/svx/source/unodraw/shapepropertynotifier.cxx
+++ b/svx/source/unodraw/shapepropertynotifier.cxx
@@ -63,9 +63,8 @@ namespace svx
_out_rValue = xContextProps->getPropertyValue( getPropertyName() );
}
- PropertyChangeNotifier::PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex )
+ PropertyChangeNotifier::PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner )
:m_rContext( _rOwner )
- ,m_aPropertyChangeListeners( _rMutex )
{
}
@@ -83,7 +82,7 @@ namespace svx
m_aProviders[ _eProperty ] = std::move(_rProvider);
}
- void PropertyChangeNotifier::notifyPropertyChange( const ShapePropertyProviderId _eProperty ) const
+ void PropertyChangeNotifier::notifyPropertyChange( std::unique_lock<std::mutex>& rGuard, const ShapePropertyProviderId _eProperty ) const
{
auto & provPos = m_aProviders[ _eProperty ];
OSL_ENSURE( provPos, "PropertyChangeNotifier::notifyPropertyChange: no factory!" );
@@ -92,8 +91,8 @@ namespace svx
const OUString & sPropertyName( provPos->getPropertyName() );
- ::comphelper::OInterfaceContainerHelper3<XPropertyChangeListener>* pPropListeners = m_aPropertyChangeListeners.getContainer( sPropertyName );
- ::comphelper::OInterfaceContainerHelper3<XPropertyChangeListener>* pAllListeners = m_aPropertyChangeListeners.getContainer( OUString() );
+ ::comphelper::OInterfaceContainerHelper4<XPropertyChangeListener>* pPropListeners = m_aPropertyChangeListeners.getContainer( rGuard, sPropertyName );
+ ::comphelper::OInterfaceContainerHelper4<XPropertyChangeListener>* pAllListeners = m_aPropertyChangeListeners.getContainer( rGuard, OUString() );
if ( !pPropListeners && !pAllListeners )
return;
@@ -106,9 +105,9 @@ namespace svx
provPos->getCurrentValue( aEvent.NewValue );
if ( pPropListeners )
- pPropListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent );
+ pPropListeners->notifyEach( rGuard, &XPropertyChangeListener::propertyChange, aEvent );
if ( pAllListeners )
- pAllListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent );
+ pAllListeners->notifyEach( rGuard, &XPropertyChangeListener::propertyChange, aEvent );
}
catch( const Exception& )
{
@@ -117,23 +116,23 @@ namespace svx
}
- void PropertyChangeNotifier::addPropertyChangeListener( const OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener )
+ void PropertyChangeNotifier::addPropertyChangeListener( std::unique_lock<std::mutex>& rGuard, const OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener )
{
- m_aPropertyChangeListeners.addInterface( _rPropertyName, _rxListener );
+ m_aPropertyChangeListeners.addInterface( rGuard, _rPropertyName, _rxListener );
}
- void PropertyChangeNotifier::removePropertyChangeListener( const OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener )
+ void PropertyChangeNotifier::removePropertyChangeListener( std::unique_lock<std::mutex>& rGuard, const OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener )
{
- m_aPropertyChangeListeners.removeInterface( _rPropertyName, _rxListener );
+ m_aPropertyChangeListeners.removeInterface( rGuard, _rPropertyName, _rxListener );
}
- void PropertyChangeNotifier::disposing()
+ void PropertyChangeNotifier::disposing(std::unique_lock<std::mutex>& rGuard)
{
EventObject aEvent;
aEvent.Source = m_rContext;
- m_aPropertyChangeListeners.disposeAndClear( aEvent );
+ m_aPropertyChangeListeners.disposeAndClear( rGuard, aEvent );
}
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index d5859fa3ca55..4ee178c5e58a 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -125,15 +125,14 @@ struct SvxShapeImpl
::unotools::WeakReference< SdrObject > mxCreatedObj;
// for xComponent
- ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> maDisposeListeners;
+ ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> maDisposeListeners;
svx::PropertyChangeNotifier maPropertyNotifier;
- SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex )
+ SvxShapeImpl( SvxShape& _rAntiImpl )
:mnObjId( SdrObjKind::NONE )
,mpMaster( nullptr )
,mbDisposing( false )
- ,maDisposeListeners( _rMutex )
- ,maPropertyNotifier( _rAntiImpl, _rMutex )
+ ,maPropertyNotifier( _rAntiImpl )
{
}
};
@@ -195,7 +194,7 @@ sal_Int16 GetTextFitToSizeScale(SdrObject* pObject)
SvxShape::SvxShape( SdrObject* pObject )
: maSize(100,100)
-, mpImpl( new SvxShapeImpl( *this, m_aMutex ) )
+, mpImpl( new SvxShapeImpl( *this ) )
, mbIsMultiPropertyCall(false)
, mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
, maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
@@ -208,7 +207,7 @@ SvxShape::SvxShape( SdrObject* pObject )
SvxShape::SvxShape( SdrObject* pObject, o3tl::span<const SfxItemPropertyMapEntry> pEntries, const SvxItemPropertySet* pPropertySet )
: maSize(100,100)
-, mpImpl( new SvxShapeImpl( *this, m_aMutex ) )
+, mpImpl( new SvxShapeImpl( *this ) )
, mbIsMultiPropertyCall(false)
, mpPropSet(pPropertySet)
, maPropMapEntries(pEntries)
@@ -290,11 +289,16 @@ sal_Int64 SAL_CALL SvxShape::getSomething( const css::uno::Sequence< sal_Int8 >&
}
-svx::PropertyChangeNotifier& SvxShape::getShapePropertyChangeNotifier()
+void SvxShape::notifyPropertyChange(svx::ShapePropertyProviderId eProp)
{
- return mpImpl->maPropertyNotifier;
+ std::unique_lock g(m_aMutex);
+ mpImpl->maPropertyNotifier.notifyPropertyChange(g, eProp);
}
+void SvxShape::registerProvider(svx::ShapePropertyProviderId eProp, std::unique_ptr<svx::PropertyValueProvider> provider)
+{
+ mpImpl->maPropertyNotifier.registerProvider(eProp, std::move(provider));
+}
void SvxShape::impl_construct()
{
@@ -1195,7 +1199,7 @@ OUString SAL_CALL SvxShape::getShapeType()
void SAL_CALL SvxShape::dispose()
{
- ::SolarMutexGuard aGuard;
+ std::unique_lock g(m_aMutex);
if( mpImpl->mbDisposing )
return; // caught a recursion
@@ -1204,8 +1208,8 @@ void SAL_CALL SvxShape::dispose()
lang::EventObject aEvt;
aEvt.Source = *static_cast<OWeakAggObject*>(this);
- mpImpl->maDisposeListeners.disposeAndClear(aEvt);
- mpImpl->maPropertyNotifier.disposing();
+ mpImpl->maDisposeListeners.disposeAndClear(g, aEvt);
+ mpImpl->maPropertyNotifier.disposing(g);
rtl::Reference<SdrObject> pObject = mxSdrObject;
if (!pObject)
@@ -1235,13 +1239,15 @@ void SAL_CALL SvxShape::dispose()
void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener )
{
- mpImpl->maDisposeListeners.addInterface(xListener);
+ std::unique_lock g(m_aMutex);
+ mpImpl->maDisposeListeners.addInterface(g, xListener);
}
void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener )
{
- mpImpl->maDisposeListeners.removeInterface(aListener);
+ std::unique_lock g(m_aMutex);
+ mpImpl->maDisposeListeners.removeInterface(g, aListener);
}
// XPropertySet
@@ -1269,15 +1275,15 @@ Reference< beans::XPropertySetInfo > const &
void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener )
{
- ::osl::MutexGuard aGuard( m_aMutex );
- mpImpl->maPropertyNotifier.addPropertyChangeListener( _propertyName, _listener );
+ std::unique_lock g(m_aMutex);
+ mpImpl->maPropertyNotifier.addPropertyChangeListener( g, _propertyName, _listener );
}
void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener )
{
- ::osl::MutexGuard aGuard( m_aMutex );
- mpImpl->maPropertyNotifier.removePropertyChangeListener( _propertyName, _listener );
+ std::unique_lock g(m_aMutex);
+ mpImpl->maPropertyNotifier.removePropertyChangeListener( g, _propertyName, _listener );
}