summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-11-11 17:07:35 +0000
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-11 16:17:30 -0500
commit7e2677c02997ad7bf38641b46fd1e7ac2c643cd2 (patch)
tree35b1c07ed12f72bfcc5150dc199399ed72ab9d06
parent01ea75c0f08e07c8243aafc8628612a9210add26 (diff)
Accelerate checking for VBA macros that are not there.
-rw-r--r--offapi/com/sun/star/script/vba/XVBAEventProcessor.idl5
-rw-r--r--vbahelper/source/vbahelper/vbaeventshelperbase.cxx19
2 files changed, 11 insertions, 13 deletions
diff --git a/offapi/com/sun/star/script/vba/XVBAEventProcessor.idl b/offapi/com/sun/star/script/vba/XVBAEventProcessor.idl
index 750cc4d22bb3..1fbf75d65fb0 100644
--- a/offapi/com/sun/star/script/vba/XVBAEventProcessor.idl
+++ b/offapi/com/sun/star/script/vba/XVBAEventProcessor.idl
@@ -44,10 +44,7 @@ interface XVBAEventProcessor
@return
`TRUE`, if the VBA event handler exists.
-
- @throws ::com::sun::star::lang::IllegalArgumentException
- if the passed event identifier is not supported, or if the passed
- specifier is required but invalid.
+ `FALSE`, for all other cases.
**/
boolean hasVbaEventHandler( [in] long nEventId, [in] sequence< any > aArgs )
raises (::com::sun::star::lang::IllegalArgumentException);
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index b6a7e7a2923c..69b558425e48 100644
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -51,15 +51,6 @@ VbaEventsHelperBase::~VbaEventsHelperBase()
SAL_WARN_IF( !mbDisposed, "vbahelper", "VbaEventsHelperBase::~VbaEventsHelperBase - missing disposing notification" );
}
-sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
- throw (lang::IllegalArgumentException, uno::RuntimeException)
-{
- // getEventHandlerInfo() throws, if unknown event dentifier has been passed
- const EventHandlerInfo& rInfo = getEventHandlerInfo( nEventId );
- // getEventHandlerPath() searches for the macro in the document
- return !getEventHandlerPath( rInfo, rArgs ).isEmpty();
-}
-
sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
throw (lang::IllegalArgumentException, util::VetoException, uno::RuntimeException)
{
@@ -241,6 +232,16 @@ void VbaEventsHelperBase::stopListening()
mbDisposed = true;
}
+sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ EventHandlerInfoMap::const_iterator aIt = maEventInfos.find( nEventId );
+ if( aIt == maEventInfos.end() )
+ return sal_False; // throwing a lot of exceptions is slow.
+ else // getEventHandlerPath() searches for the macro in the document
+ return !getEventHandlerPath( aIt->second, rArgs ).isEmpty();
+}
+
const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo(
sal_Int32 nEventId ) const throw (lang::IllegalArgumentException)
{