diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-08-11 11:45:59 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-08-16 21:22:40 -0400 |
commit | 5b55512e9ed418f8d22c800e58da0101ef243a12 (patch) | |
tree | 2f6e24eb734e00684edcc56c3dd5af5f25b63006 /eventattacher/source | |
parent | Extracted a method that will be called from another method. (diff) | |
download | core-5b55512e9ed418f8d22c800e58da0101ef243a12.tar.gz core-5b55512e9ed418f8d22c800e58da0101ef243a12.zip |
And use it from the multi-listener regstration code.
Diffstat (limited to 'eventattacher/source')
-rw-r--r-- | eventattacher/source/eventattacher.cxx | 104 |
1 files changed, 3 insertions, 101 deletions
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<XEventListener> > EventAttacherImpl::attachListeners( for (sal_Int32 i = 0; i < nCount; ++i) { - Reference<XEventListener> xRet = NULL; - - const Reference<XAllListener>& 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; |