Kaydet (Commit) 11880ef4 authored tarafından Noel Grandin's avatar Noel Grandin

use rtl::Reference in AttacherAllListener_Impl

no need to store a raw and a smart pointer field

Change-Id: Id9ce8365a413ee2dcac8e92b99768ccbb8bf7697
Reviewed-on: https://gerrit.libreoffice.org/33158Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d9884a62
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <comphelper/interfacecontainer2.hxx> #include <comphelper/interfacecontainer2.hxx>
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
#include <deque> #include <deque>
#include <algorithm> #include <algorithm>
...@@ -142,8 +143,7 @@ private: ...@@ -142,8 +143,7 @@ private:
// only passes individual events of the general AllListeners. // only passes individual events of the general AllListeners.
class AttacherAllListener_Impl : public WeakImplHelper< XAllListener > class AttacherAllListener_Impl : public WeakImplHelper< XAllListener >
{ {
ImplEventAttacherManager* mpManager; rtl::Reference<ImplEventAttacherManager> mxManager;
Reference< XEventAttacherManager > xManager;
OUString aScriptType; OUString aScriptType;
OUString aScriptCode; OUString aScriptCode;
...@@ -168,8 +168,7 @@ AttacherAllListener_Impl::AttacherAllListener_Impl ...@@ -168,8 +168,7 @@ AttacherAllListener_Impl::AttacherAllListener_Impl
const OUString & rScriptType_, const OUString & rScriptType_,
const OUString & rScriptCode_ const OUString & rScriptCode_
) )
: mpManager( pManager_ ) : mxManager( pManager_ )
, xManager( pManager_ )
, aScriptType( rScriptType_ ) , aScriptType( rScriptType_ )
, aScriptCode( rScriptCode_ ) , aScriptCode( rScriptCode_ )
{ {
...@@ -181,7 +180,7 @@ void SAL_CALL AttacherAllListener_Impl::firing(const AllEventObject& Event) ...@@ -181,7 +180,7 @@ void SAL_CALL AttacherAllListener_Impl::firing(const AllEventObject& Event)
throw( RuntimeException, std::exception ) throw( RuntimeException, std::exception )
{ {
ScriptEvent aScriptEvent; ScriptEvent aScriptEvent;
aScriptEvent.Source = static_cast<OWeakObject *>(mpManager); // get correct XInterface aScriptEvent.Source = static_cast<OWeakObject *>(mxManager.get()); // get correct XInterface
aScriptEvent.ListenerType = Event.ListenerType; aScriptEvent.ListenerType = Event.ListenerType;
aScriptEvent.MethodName = Event.MethodName; aScriptEvent.MethodName = Event.MethodName;
aScriptEvent.Arguments = Event.Arguments; aScriptEvent.Arguments = Event.Arguments;
...@@ -190,7 +189,7 @@ void SAL_CALL AttacherAllListener_Impl::firing(const AllEventObject& Event) ...@@ -190,7 +189,7 @@ void SAL_CALL AttacherAllListener_Impl::firing(const AllEventObject& Event)
aScriptEvent.ScriptCode = aScriptCode; aScriptEvent.ScriptCode = aScriptCode;
// Iterate over all listeners and pass events. // Iterate over all listeners and pass events.
OInterfaceIteratorHelper2 aIt( mpManager->aScriptListeners ); OInterfaceIteratorHelper2 aIt( mxManager->aScriptListeners );
while( aIt.hasMoreElements() ) while( aIt.hasMoreElements() )
static_cast<XScriptListener *>(aIt.next())->firing( aScriptEvent ); static_cast<XScriptListener *>(aIt.next())->firing( aScriptEvent );
} }
...@@ -234,8 +233,8 @@ void AttacherAllListener_Impl::convertToEventReturn( Any & rRet, const Type & rR ...@@ -234,8 +233,8 @@ void AttacherAllListener_Impl::convertToEventReturn( Any & rRet, const Type & rR
} }
else if( !rRet.getValueType().equals( rRetType ) ) else if( !rRet.getValueType().equals( rRetType ) )
{ {
if( mpManager->xConverter.is() ) if( mxManager->xConverter.is() )
rRet = mpManager->xConverter->convertTo( rRet, rRetType ); rRet = mxManager->xConverter->convertTo( rRet, rRetType );
else else
throw CannotConvertException(); throw CannotConvertException();
} }
...@@ -246,7 +245,7 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even ...@@ -246,7 +245,7 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even
throw( InvocationTargetException, RuntimeException, std::exception ) throw( InvocationTargetException, RuntimeException, std::exception )
{ {
ScriptEvent aScriptEvent; ScriptEvent aScriptEvent;
aScriptEvent.Source = static_cast<OWeakObject *>(mpManager); // get correct XInterface aScriptEvent.Source = static_cast<OWeakObject *>(mxManager.get()); // get correct XInterface
aScriptEvent.ListenerType = Event.ListenerType; aScriptEvent.ListenerType = Event.ListenerType;
aScriptEvent.MethodName = Event.MethodName; aScriptEvent.MethodName = Event.MethodName;
aScriptEvent.Arguments = Event.Arguments; aScriptEvent.Arguments = Event.Arguments;
...@@ -256,13 +255,13 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even ...@@ -256,13 +255,13 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even
Any aRet; Any aRet;
// Iterate over all listeners and pass events. // Iterate over all listeners and pass events.
OInterfaceIteratorHelper2 aIt( mpManager->aScriptListeners ); OInterfaceIteratorHelper2 aIt( mxManager->aScriptListeners );
while( aIt.hasMoreElements() ) while( aIt.hasMoreElements() )
{ {
aRet = static_cast<XScriptListener *>(aIt.next())->approveFiring( aScriptEvent ); aRet = static_cast<XScriptListener *>(aIt.next())->approveFiring( aScriptEvent );
try try
{ {
Reference< XIdlClass > xListenerType = mpManager->getReflection()-> Reference< XIdlClass > xListenerType = mxManager->getReflection()->
forName( Event.ListenerType.getTypeName() ); forName( Event.ListenerType.getTypeName() );
Reference< XIdlMethod > xMeth = xListenerType->getMethod( Event.MethodName ); Reference< XIdlMethod > xMeth = xListenerType->getMethod( Event.MethodName );
if( xMeth.is() ) if( xMeth.is() )
...@@ -313,7 +312,7 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even ...@@ -313,7 +312,7 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even
catch (const CannotConvertException&) catch (const CannotConvertException&)
{ {
// silent ignore conversions errors from a script call // silent ignore conversions errors from a script call
Reference< XIdlClass > xListenerType = mpManager->getReflection()-> Reference< XIdlClass > xListenerType = mxManager->getReflection()->
forName( Event.ListenerType.getTypeName() ); forName( Event.ListenerType.getTypeName() );
Reference< XIdlMethod > xMeth = xListenerType->getMethod( Event.MethodName ); Reference< XIdlMethod > xMeth = xListenerType->getMethod( Event.MethodName );
if( xMeth.is() ) if( xMeth.is() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment