summaryrefslogtreecommitdiff
path: root/eventattacher/source/eventattacher.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'eventattacher/source/eventattacher.cxx')
-rw-r--r--eventattacher/source/eventattacher.cxx45
1 files changed, 23 insertions, 22 deletions
diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx
index 9dd229f32e0d..c47a933f061a 100644
--- a/eventattacher/source/eventattacher.cxx
+++ b/eventattacher/source/eventattacher.cxx
@@ -39,16 +39,17 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <mutex>
+#include <utility>
+
namespace com::sun::star::lang { class XMultiServiceFactory; }
using namespace com::sun::star::uno;
-using namespace com::sun::star::registry;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::script;
using namespace com::sun::star::reflection;
using namespace cppu;
-using namespace osl;
namespace comp_EventAttacher {
@@ -63,7 +64,7 @@ class InvocationToAllListenerMapper : public WeakImplHelper< XInvocation >
{
public:
InvocationToAllListenerMapper( const Reference< XIdlClass >& ListenerType,
- const Reference< XAllListener >& AllListener, const Any& Helper );
+ const Reference< XAllListener >& AllListener, Any Helper );
// XInvocation
virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() override;
@@ -96,8 +97,7 @@ static Reference< XInterface > createAllListenerAdapter
Reference< XInvocation > xInvocationToAllListenerMapper =
new InvocationToAllListenerMapper(xListenerType, xListener, Helper);
Type aListenerType( xListenerType->getTypeClass(), xListenerType->getName());
- Sequence<Type> arg2(1);
- arg2[0] = aListenerType;
+ Sequence<Type> arg2 { aListenerType };
xAdapter = xInvocationAdapterFactory->createAdapter( xInvocationToAllListenerMapper, arg2 );
}
return xAdapter;
@@ -106,10 +106,10 @@ static Reference< XInterface > createAllListenerAdapter
// InvocationToAllListenerMapper
InvocationToAllListenerMapper::InvocationToAllListenerMapper
- ( const Reference< XIdlClass >& ListenerType, const Reference< XAllListener >& AllListener, const Any& Helper )
+ ( const Reference< XIdlClass >& ListenerType, const Reference< XAllListener >& AllListener, Any Helper )
: m_xAllListener( AllListener )
, m_xListenerType( ListenerType )
- , m_Helper( Helper )
+ , m_Helper(std::move( Helper ))
{
}
@@ -156,7 +156,7 @@ Any SAL_CALL InvocationToAllListenerMapper::invoke(const OUString& FunctionName,
}
AllEventObject aAllEvent;
- aAllEvent.Source = static_cast<OWeakObject*>(this);
+ aAllEvent.Source = getXWeak();
aAllEvent.Helper = m_Helper;
aAllEvent.ListenerType = Type(m_xListenerType->getTypeClass(), m_xListenerType->getName());
aAllEvent.MethodName = FunctionName;
@@ -250,7 +250,7 @@ private:
const Sequence<css::script::EventListener>& aListeners );
private:
- Mutex m_aMutex;
+ std::mutex m_aMutex;
Reference< XComponentContext > m_xContext;
// Save Services
@@ -304,7 +304,7 @@ void SAL_CALL EventAttacherImpl::initialize(const Sequence< Any >& Arguments)
arg >>= xALAS;
if( xALAS.is() )
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
m_xInvocationAdapterFactory = xALAS;
}
// Introspection service ?
@@ -312,7 +312,7 @@ void SAL_CALL EventAttacherImpl::initialize(const Sequence< Any >& Arguments)
arg >>= xI;
if( xI.is() )
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
m_xIntrospection = xI;
}
// Reflection service ?
@@ -320,7 +320,7 @@ void SAL_CALL EventAttacherImpl::initialize(const Sequence< Any >& Arguments)
arg >>= xIdlR;
if( xIdlR.is() )
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
m_xReflection = xIdlR;
}
// Converter Service ?
@@ -328,7 +328,7 @@ void SAL_CALL EventAttacherImpl::initialize(const Sequence< Any >& Arguments)
arg >>= xC;
if( xC.is() )
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
m_xConverter = xC;
}
@@ -342,7 +342,7 @@ void SAL_CALL EventAttacherImpl::initialize(const Sequence< Any >& Arguments)
//*** Private helper methods ***
Reference< XIntrospection > EventAttacherImpl::getIntrospection()
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if( !m_xIntrospection.is() )
{
m_xIntrospection = theIntrospection::get( m_xContext );
@@ -354,7 +354,7 @@ Reference< XIntrospection > EventAttacherImpl::getIntrospection()
//*** Private helper methods ***
Reference< XIdlReflection > EventAttacherImpl::getReflection()
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if( !m_xReflection.is() )
{
m_xReflection = theCoreReflection::get(m_xContext);
@@ -366,7 +366,7 @@ Reference< XIdlReflection > EventAttacherImpl::getReflection()
//*** Private helper methods ***
Reference< XInvocationAdapterFactory2 > EventAttacherImpl::getInvocationAdapterService()
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if( !m_xInvocationAdapterFactory.is() )
{
m_xInvocationAdapterFactory = InvocationAdapterFactory::create(m_xContext);
@@ -378,7 +378,7 @@ Reference< XInvocationAdapterFactory2 > EventAttacherImpl::getInvocationAdapterS
//*** Private helper methods ***
Reference< XTypeConverter > EventAttacherImpl::getConverter()
{
- Guard< Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if( !m_xConverter.is() )
{
m_xConverter = Converter::create(m_xContext);
@@ -393,7 +393,7 @@ namespace {
class FilterAllListenerImpl : public WeakImplHelper< XAllListener >
{
public:
- FilterAllListenerImpl( EventAttacherImpl * pEA_, const OUString& EventMethod_,
+ FilterAllListenerImpl( EventAttacherImpl * pEA_, OUString EventMethod_,
const Reference< XAllListener >& AllListener_ );
// XAllListener
@@ -416,10 +416,10 @@ private:
}
-FilterAllListenerImpl::FilterAllListenerImpl( EventAttacherImpl * pEA_, const OUString& EventMethod_,
+FilterAllListenerImpl::FilterAllListenerImpl( EventAttacherImpl * pEA_, OUString EventMethod_,
const Reference< XAllListener >& AllListener_ )
: m_pEA( pEA_ )
- , m_EventMethod( EventMethod_ )
+ , m_EventMethod(std::move( EventMethod_ ))
, m_AllListener( AllListener_ )
{
}
@@ -825,9 +825,10 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachMultipleEventList
{
sal_Int32 nCount = aListeners.getLength();
Sequence< Reference<XAllListener> > aFilterListeners(nCount);
+ auto aFilterListenersRange = asNonConstRange(aFilterListeners);
for (sal_Int32 i = 0; i < nCount; ++i)
{
- aFilterListeners[i]
+ aFilterListenersRange[i]
= new FilterAllListenerImpl(this, aListeners[i].EventMethod, aListeners[i].AllListener);
}
@@ -840,7 +841,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
eventattacher_EventAttacher(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
{
- return cppu::acquire(static_cast<cppu::OWeakObject*>(new comp_EventAttacher::EventAttacherImpl(context)));
+ return cppu::acquire(new comp_EventAttacher::EventAttacherImpl(context));
}