diff options
author | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-15 09:16:51 +0100 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-15 09:16:51 +0100 |
commit | 81de889004df64af38ce0ab87abb0727f60be58c (patch) | |
tree | 49cbb99bfc0db55aa8d16dac8a70026959be9ffd /scripting | |
parent | 64d9903a647efe5cb689fc6ff84175a911b69cfd (diff) | |
parent | 01da86c29a23c3260f54774929b11897784cef0a (diff) |
dba33b: merge m69
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/dlgprov/dlgevtatt.cxx | 142 |
1 files changed, 62 insertions, 80 deletions
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index 2284884e36..60d53d1562 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -32,14 +32,13 @@ #include "precompiled_scripting.hxx" #include "dlgevtatt.hxx" -#ifndef SCRIPTING_DLGPROV_HXX #include "dlgprov.hxx" -#endif + #include <sfx2/sfx.hrc> #include <sfx2/app.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif +#include <tools/diagnose_ex.h> + #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XDialogEventHandler.hpp> #include <com/sun/star/awt/XContainerWindowEventHandler.hpp> @@ -53,6 +52,7 @@ #include <com/sun/star/reflection/XIdlMethod.hpp> #include <com/sun/star/beans/MethodConcept.hpp> #include <com/sun/star/beans/XMaterialHolder.hpp> + #ifdef FAKE_VBA_EVENT_SUPPORT #include <ooo/vba/XVBAToOOEventDescGen.hpp> #endif @@ -98,7 +98,7 @@ namespace dlgprov virtual void firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* pRet ); public: - DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext, + DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext, const Reference< frame::XModel >& rxModel, const Reference< awt::XControl >& rxControl, const Reference< XInterface >& rxHandler, @@ -133,10 +133,13 @@ namespace dlgprov try { xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= msDialogCodeName; - } - catch ( Exception& ) {} + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } - + } void DialogVBAScriptListenerImpl::firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* ) @@ -149,7 +152,10 @@ namespace dlgprov { mxListener->firing( aScriptEventCopy ); } - catch( Exception& ) {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } #endif @@ -184,13 +190,13 @@ namespace dlgprov } // ----------------------------------------------------------------------------- - Reference< script::XScriptListener > + Reference< script::XScriptListener > DialogEventsAttacherImpl::getScriptListenerForKey( const rtl::OUString& sKey ) throw ( RuntimeException ) { ListenerHash::iterator it = listernersForTypes.find( sKey ); if ( it == listernersForTypes.end() ) throw RuntimeException(); // more text info here please - return it->second; + return it->second; } #ifdef FAKE_VBA_EVENT_SUPPORT Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl ) @@ -202,7 +208,7 @@ namespace dlgprov Reference< ooo::vba::XVBAToOOEventDescGen > xVBAToOOEvtDesc( xSMgr->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAToOOEventDesc" ) ), m_xContext ), UNO_QUERY ); if ( xVBAToOOEvtDesc.is() ) xEventsSupplier.set( xVBAToOOEvtDesc->getEventSupplier( xControl ), UNO_QUERY ); - + } return xEventsSupplier; } @@ -221,46 +227,38 @@ namespace dlgprov Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames(); const ::rtl::OUString* pNames = aNames.getConstArray(); sal_Int32 nNameCount = aNames.getLength(); - + for ( sal_Int32 j = 0; j < nNameCount; ++j ) { ScriptEventDescriptor aDesc; - + Any aElement = xEventCont->getByName( pNames[ j ] ); aElement >>= aDesc; rtl::OUString sKey = aDesc.ScriptType; if ( aDesc.ScriptType.equals( rtl::OUString::createFromAscii("Script" ) ) || aDesc.ScriptType.equals( rtl::OUString::createFromAscii("UNO" ) ) ) { sal_Int32 nIndex = aDesc.ScriptCode.indexOf( ':' ); - sKey = aDesc.ScriptCode.copy( 0, nIndex ); + sKey = aDesc.ScriptCode.copy( 0, nIndex ); } Reference< XAllListener > xAllListener = new DialogAllListenerImpl( getScriptListenerForKey( sKey ), aDesc.ScriptType, aDesc.ScriptCode ); - + // try first to attach event to the ControlModel bool bSuccess = false; try { - Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener( - xControlModel, xAllListener, Helper, aDesc.ListenerType, + Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener( + xControlModel, xAllListener, Helper, aDesc.ListenerType, aDesc.AddListenerParam, aDesc.EventMethod ); - + if ( xListener_.is() ) bSuccess = true; } - catch ( IllegalArgumentException& ) - { - } - catch ( IntrospectionException& ) - { - } - catch ( CannotCreateAdapterException& ) + catch ( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } - catch ( ServiceNotRegisteredException& ) - { - } - + try { // if we had no success, try to attach to the control @@ -271,17 +269,9 @@ namespace dlgprov aDesc.AddListenerParam, aDesc.EventMethod ); } } - catch( IllegalArgumentException& ) - { - } - catch( IntrospectionException& ) - { - } - catch( CannotCreateAdapterException& ) - { - } - catch( ServiceNotRegisteredException& ) + catch ( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } } @@ -294,8 +284,8 @@ namespace dlgprov void SAL_CALL DialogEventsAttacherImpl::attachEvents( const Sequence< Reference< XInterface > >& Objects, const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener>&, - const Any& Helper ) - throw (IllegalArgumentException, IntrospectionException, CannotCreateAdapterException, + const Any& Helper ) + throw (IllegalArgumentException, IntrospectionException, CannotCreateAdapterException, ServiceNotRegisteredException, RuntimeException) { // get EventAttacher @@ -349,7 +339,7 @@ namespace dlgprov // DialogAllListenerImpl // ============================================================================= - DialogAllListenerImpl::DialogAllListenerImpl( const Reference< XScriptListener >& rxListener, + DialogAllListenerImpl::DialogAllListenerImpl( const Reference< XScriptListener >& rxListener, const ::rtl::OUString& rScriptType, const ::rtl::OUString& rScriptCode ) :m_xScriptListener( rxListener ) ,m_sScriptType( rScriptType ) @@ -406,7 +396,7 @@ namespace dlgprov // ----------------------------------------------------------------------------- - Any DialogAllListenerImpl::approveFiring( const AllEventObject& Event ) + Any DialogAllListenerImpl::approveFiring( const AllEventObject& Event ) throw ( reflection::InvocationTargetException, RuntimeException ) { ::osl::MutexGuard aGuard( getMutex() ); @@ -421,7 +411,7 @@ namespace dlgprov // DialogScriptListenerImpl // ============================================================================= - DialogUnoScriptListenerImpl::DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext, + DialogUnoScriptListenerImpl::DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext, const Reference< ::com::sun::star::frame::XModel >& rxModel, const Reference< ::com::sun::star::awt::XControl >& rxControl, const Reference< ::com::sun::star::uno::XInterface >& rxHandler, @@ -443,7 +433,7 @@ namespace dlgprov // ----------------------------------------------------------------------------- void DialogSFScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet ) - { + { try { Reference< provider::XScriptProvider > xScriptProvider; @@ -461,7 +451,7 @@ namespace dlgprov { Reference< provider::XScriptProviderFactory > xFactory( m_xContext->getValueByName( - ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory" ) ), + ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory" ) ), UNO_QUERY ); OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" ); if ( xFactory.is() ) @@ -476,7 +466,7 @@ namespace dlgprov OSL_ENSURE( xScriptProvider.is(), "DialogScriptListenerImpl::firing_impl: failed to get script provider" ); if ( xScriptProvider.is() ) - { + { Reference< provider::XScript > xScript = xScriptProvider->getScript( aScriptEvent.ScriptCode ); OSL_ENSURE( xScript.is(), "DialogScriptListenerImpl::firing_impl: failed to get script" ); @@ -487,7 +477,7 @@ namespace dlgprov Sequence< Any > aOutParams; // get arguments for script - aInParams = aScriptEvent.Arguments; + aInParams = aScriptEvent.Arguments; Any aResult = xScript->invoke( aInParams, aOutParamsIndex, aOutParams ); if ( pRet ) @@ -495,38 +485,32 @@ namespace dlgprov } } } - catch ( RuntimeException& e ) - { - OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught RuntimeException reason %s", - ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - } - catch ( Exception& e ) + catch ( const Exception& ) { - OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught Exception reason %s", - ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); + DBG_UNHANDLED_EXCEPTION(); } } void DialogLegacyScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet ) - { + { ::rtl::OUString sScriptURL; ::rtl::OUString sScriptCode( aScriptEvent.ScriptCode ); - if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) - { - // StarBasic script: convert ScriptCode to scriptURL - sal_Int32 nIndex = sScriptCode.indexOf( ':' ); - if ( nIndex >= 0 && nIndex < sScriptCode.getLength() ) + if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) { - sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); - sScriptURL += sScriptCode.copy( nIndex + 1 ); - sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" ); - sScriptURL += sScriptCode.copy( 0, nIndex ); + // StarBasic script: convert ScriptCode to scriptURL + sal_Int32 nIndex = sScriptCode.indexOf( ':' ); + if ( nIndex >= 0 && nIndex < sScriptCode.getLength() ) + { + sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); + sScriptURL += sScriptCode.copy( nIndex + 1 ); + sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" ); + sScriptURL += sScriptCode.copy( 0, nIndex ); + } + ScriptEvent aSFScriptEvent( aScriptEvent ); + aSFScriptEvent.ScriptCode = sScriptURL; + DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet ); } - ScriptEvent aSFScriptEvent( aScriptEvent ); - aSFScriptEvent.ScriptCode = sScriptURL; - DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet ); - } } void DialogUnoScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet ) @@ -603,12 +587,10 @@ namespace dlgprov bHandled = true; } } - catch( com::sun::star::lang::IllegalArgumentException& ) - {} - catch( com::sun::star::lang::NoSuchMethodException& ) - {} - catch( com::sun::star::reflection::InvocationTargetException& ) - {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } if( bHandled ) @@ -634,7 +616,7 @@ namespace dlgprov aOUFinal += aQuoteChar; aOUFinal += aOURes.copy( nIndex + 2 ); - ErrorBox( NULL, WinBits( WB_OK ), aOUFinal ).Execute(); + ErrorBox( NULL, WinBits( WB_OK ), aOUFinal ).Execute(); } } } @@ -660,7 +642,7 @@ namespace dlgprov // ----------------------------------------------------------------------------- - Any DialogScriptListenerImpl::approveFiring( const ScriptEvent& aScriptEvent ) + Any DialogScriptListenerImpl::approveFiring( const ScriptEvent& aScriptEvent ) throw ( reflection::InvocationTargetException, RuntimeException ) { ::osl::MutexGuard aGuard( getMutex() ); |