summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-05-01 12:05:22 +0100
committerNoel Power <noel.power@suse.com>2013-05-07 09:56:21 +0100
commitbabd0f159728cd1e02a5fa0d3cc9765e798b2424 (patch)
treea931e14c3e806664a1fca7c3a3f75059ddcccadd
parentc95803f9fcba5a7f57b76345cb2c75507a2d3b49 (diff)
tweak vba Control implementation to aritificially fire events from api
Previouslly there were some internal methods to allow event handlers to be triggered. To test some functionality from the unit tests we now expose some of that functionality via uno. Change-Id: I11022226260d3dacd82f42ce89413102ce34cc13
-rw-r--r--oovbaapi/ooo/vba/msforms/XControl.idl5
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx7
-rw-r--r--vbahelper/source/msforms/vbacontrol.hxx2
3 files changed, 10 insertions, 4 deletions
diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl
index 319ff721c80f..b70315415b3b 100644
--- a/oovbaapi/ooo/vba/msforms/XControl.idl
+++ b/oovbaapi/ooo/vba/msforms/XControl.idl
@@ -19,6 +19,7 @@
#define __ooo_vba_msforms_XControl_idl__
#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/script/ScriptEvent.idl>
#include <ooo/vba/XHelperInterface.idl>
module ooo { module vba { module msforms {
@@ -29,7 +30,9 @@ interface XControl
interface ::ooo::vba::XHelperInterface;
void SetFocus();
void Move( [in] double Left, [in] double Top, [in] any Width, [in] any Height );
-
+ // support for unit test harness ( and possibly internal clients )
+ // to generate events that will call appropriate event handlers
+ void fireEvent( [in] com::sun::star::script::ScriptEvent evt );
[attribute, readonly ] com::sun::star::uno::XInterface Object;
[attribute] string ControlSource;
[attribute] string RowSource;
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 516cfa69247a..ae0cc588cf17 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -519,8 +519,9 @@ ScVbaControl::setMousePointer( ::sal_Int32 _mousepointer ) throw (::com::sun::st
}
}
-void ScVbaControl::fireEvent( script::ScriptEvent& evt )
+void SAL_CALL ScVbaControl::fireEvent( const script::ScriptEvent& rEvt ) throw (uno::RuntimeException)
{
+ script::ScriptEvent evt( rEvt );
uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
uno::Reference< script::XScriptListener > xScriptListener( xServiceManager->createInstanceWithContext( "ooo.vba.EventListener" , mxContext ), uno::UNO_QUERY_THROW );
@@ -546,7 +547,9 @@ void ScVbaControl::fireEvent( script::ScriptEvent& evt )
uno::Reference< document::XCodeNameQuery > xNameQuery( xDocFac->createInstance( "ooo.vba.VBACodeNameProvider" ), uno::UNO_QUERY_THROW );
uno::Reference< uno::XInterface > xIf( xControlShape->getControl(), uno::UNO_QUERY_THROW );
evt.ScriptCode = xNameQuery->getCodeNameForObject( xIf );
- evt.Arguments[ 0 ] = uno::makeAny( aEvt );
+ // handle if we passed in our own arguments
+ if ( !rEvt.Arguments.getLength() )
+ evt.Arguments[ 0 ] = uno::makeAny( aEvt );
xScriptListener->firing( evt );
}
else
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index bf6b8a308fcf..7644b56515f8 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -57,7 +57,6 @@ protected:
virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException);
void fireChangeEvent();
void fireClickEvent();
- void fireEvent( css::script::ScriptEvent& evt );
public:
ScVbaControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pHelper );
@@ -84,6 +83,7 @@ public:
virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException);
virtual void SAL_CALL SetFocus( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Move( double Left, double Top, const ::com::sun::star::uno::Any& Width, const ::com::sun::star::uno::Any& Height ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL fireEvent( const css::script::ScriptEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException);
virtual OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException);