From 5b55512e9ed418f8d22c800e58da0101ef243a12 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 11 Aug 2011 11:45:59 -0400 Subject: And use it from the multi-listener regstration code. --- eventattacher/source/eventattacher.cxx | 104 +-------------------------------- 1 file changed, 3 insertions(+), 101 deletions(-) (limited to 'eventattacher/source') diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx index 7c2bdf51cca5..8aaaacea1727 100644 --- a/eventattacher/source/eventattacher.cxx +++ b/eventattacher/source/eventattacher.cxx @@ -770,107 +770,9 @@ Sequence< Reference > EventAttacherImpl::attachListeners( for (sal_Int32 i = 0; i < nCount; ++i) { - Reference xRet = NULL; - - const Reference& AllListener = aListeners[i].AllListener; - const Any& Helper = aListeners[i].Helper; - const OUString& ListenerType = aListeners[i].ListenerType; - const OUString& AddListenerParam = aListeners[i].AddListenerParam; - - // Construct the name of the addListener-Method. - OUString aAddListenerName; - OUString aListenerName( ListenerType ); - sal_Int32 nIndex = aListenerName.lastIndexOf( '.' ); - // set index to the interface name without package name - if( nIndex == -1 ) - // not found - nIndex = 0; - else - nIndex++; - if( aListenerName[nIndex] == 'X' ) - // erase X from the interface name - aListenerName = aListenerName.copy( nIndex +1 ); - aAddListenerName = OUString( RTL_CONSTASCII_USTRINGPARAM( "add" ) ) + aListenerName; - - // Send Methods to the correct addListener-Method - Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods( MethodConcept::LISTENER ); - sal_uInt32 j, nLen = aMethodSeq.getLength(); - const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray(); - - for( j = 0 ; j < nLen ; j++ ) - { - const Reference< XIdlMethod >& rxMethod = pMethods[j]; - - // Is it the correct method? - OUString aMethName = rxMethod->getName(); - - if( aAddListenerName == aMethName ) - { - Sequence< Reference< XIdlClass > > params = rxMethod->getParameterTypes(); - sal_uInt32 nParamCount = params.getLength(); - - Reference< XIdlClass > xListenerType; - if( nParamCount == 1 ) - xListenerType = params.getConstArray()[0]; - else if( nParamCount == 2 ) - xListenerType = params.getConstArray()[1]; - - // Request Adapter for the actual Listener type - Reference< XInterface > xAdapter = createAllListenerAdapter - ( xInvocationAdapterFactory, xListenerType, AllListener, Helper ); - - if( !xAdapter.is() ) - throw CannotCreateAdapterException(); - xRet = Reference< XEventListener >( xAdapter, UNO_QUERY ); - - - // Just the Listener as parameter? - if( nParamCount == 1 ) - { - Sequence< Any > args( 1 ); - args.getArray()[0] <<= xAdapter; - try - { - rxMethod->invoke( aObjAny, args ); - } - catch( InvocationTargetException& ) - { - throw IntrospectionException(); - } - } - // Else, pass the other parameter now - else if( nParamCount == 2 ) - { - Sequence< Any > args( 2 ); - Any* pAnys = args.getArray(); - - // Check the type of the 1st parameter - Reference< XIdlClass > xParamClass = params.getConstArray()[0]; - if( xParamClass->getTypeClass() == TypeClass_STRING ) - { - pAnys[0] <<= AddListenerParam; - } - - // 2nd Parameter == Listener? TODO: Test! - pAnys[1] <<= xAdapter; - - // TODO: Convert String -> ? - // else - try - { - rxMethod->invoke( aObjAny, args ); - } - catch( InvocationTargetException& ) - { - throw IntrospectionException(); - } - } - break; - // else... - // Anything else is not supported - } - } - pArray[i] = xRet; + pArray[i] = attachListenerForTarget( + xAccess, xInvocationAdapterFactory, aListeners[i].AllListener, + aObjAny, aListeners[i].Helper, aListeners[i].ListenerType, aListeners[i].AddListenerParam); } return aRet; -- cgit