diff options
author | Caolán McNamara <cmc@openoffice.org> | 2010-05-20 13:11:17 +0100 |
---|---|---|
committer | Caolán McNamara <cmc@openoffice.org> | 2010-05-20 13:11:17 +0100 |
commit | dec4aed0fc56b80333a0755e8c1cae17f1762fe7 (patch) | |
tree | c40890dda9c35d69d1aa36b70cad1538c959ecf3 /scripting | |
parent | 470b4aebe45519035088301bb8ed9783de493ad4 (diff) | |
parent | ff494dca2e13bfb2cc35b7d65a178e6093af9842 (diff) |
cmcfixes75: merge with DEV300 m78
Diffstat (limited to 'scripting')
-rwxr-xr-x[-rw-r--r--] | scripting/prj/build.lst | 2 | ||||
-rw-r--r-- | scripting/source/dlgprov/dlgevtatt.cxx | 40 | ||||
-rw-r--r-- | scripting/source/dlgprov/dlgevtatt.hxx | 5 | ||||
-rw-r--r-- | scripting/source/dlgprov/makefile.mk | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | scripting/source/vbaevents/eventhelper.cxx | 13 |
5 files changed, 35 insertions, 26 deletions
diff --git a/scripting/prj/build.lst b/scripting/prj/build.lst index fc332384e0..7d5162173e 100644..100755 --- a/scripting/prj/build.lst +++ b/scripting/prj/build.lst @@ -1,4 +1,4 @@ -tc scripting : oovbaapi bridges rdbmaker vcl xmlscript basic sfx2 rhino BSH:beanshell javaunohelper NULL +tc scripting : oovbaapi vbahelper bridges rdbmaker vcl xmlscript basic sfx2 rhino BSH:beanshell javaunohelper NULL tc scripting usr1 - all tc1_mkout NULL tc scripting\inc nmake - all tc1_inc NULL tc scripting\source\provider nmake - all tc1_scriptingprovider tc1_inc NULL diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index 992e670e8d..11a101454e 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -50,9 +50,9 @@ #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 +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <vbahelper/vbaaccesshelper.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::awt; @@ -104,7 +104,6 @@ namespace dlgprov }; -#ifdef FAKE_VBA_EVENT_SUPPORT class DialogVBAScriptListenerImpl : public DialogScriptListenerImpl { protected: @@ -157,7 +156,6 @@ namespace dlgprov } } } -#endif //......................................................................... @@ -166,7 +164,7 @@ namespace dlgprov // ============================================================================= DialogEventsAttacherImpl::DialogEventsAttacherImpl( const Reference< XComponentContext >& rxContext, const Reference< frame::XModel >& rxModel, const Reference< awt::XControl >& rxControl, const Reference< XInterface >& rxHandler, const Reference< beans::XIntrospectionAccess >& rxIntrospect, bool bProviderMode, const Reference< script::XScriptListener >& rxRTLListener ) - :m_xContext( rxContext ) + :mbUseFakeVBAEvents( false ), m_xContext( rxContext ) { // key listeners by protocol when ScriptType = 'Script' // otherwise key is the ScriptType e.g. StarBasic @@ -177,9 +175,22 @@ namespace dlgprov // handler for Script & ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" ) listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.UNO") ] = new DialogUnoScriptListenerImpl( rxContext, rxModel, rxControl, rxHandler, rxIntrospect, bProviderMode ); listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.script") ] = new DialogSFScriptListenerImpl( rxContext, rxModel ); -#ifdef FAKE_VBA_EVENT_SUPPORT - listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel ); -#endif + // Note: in a future cws ( npower13_ObjectModule ) it will be possible + // to determine the vba mode from the basiclibrary container, the tunnel hack + // below can then be replaced + SfxObjectShell* pFoundShell = NULL; + if ( rxModel.is() ) + { + uno::Reference< lang::XUnoTunnel > xObjShellTunnel( rxModel, uno::UNO_QUERY ); + if ( xObjShellTunnel.is() ) + { + pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); + if ( pFoundShell ) + mbUseFakeVBAEvents = ooo::vba::isAlienExcelDoc( *pFoundShell ); + } + } + if ( mbUseFakeVBAEvents ) + listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel ); } // ----------------------------------------------------------------------------- @@ -197,7 +208,6 @@ namespace dlgprov throw RuntimeException(); // more text info here please return it->second; } -#ifdef FAKE_VBA_EVENT_SUPPORT Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl, rtl::OUString& sControlName ) { Reference< XScriptEventsSupplier > xEventsSupplier; @@ -210,7 +220,6 @@ namespace dlgprov } return xEventsSupplier; } -#endif // ----------------------------------------------------------------------------- void SAL_CALL DialogEventsAttacherImpl::attachEventsToControl( const Reference< XControl>& xControl, const Reference< XScriptEventsSupplier >& xEventsSupplier, const Any& Helper ) @@ -312,7 +321,6 @@ namespace dlgprov // go over all objects const Reference< XInterface >* pObjects = Objects.getConstArray(); sal_Int32 nObjCount = Objects.getLength(); -#ifdef FAKE_VBA_EVENT_SUPPORT Reference< awt::XControl > xDlgControl( Objects[ nObjCount - 1 ], uno::UNO_QUERY ); // last object is the dialog rtl::OUString sDialogCodeName; if ( xDlgControl.is() ) @@ -324,7 +332,6 @@ namespace dlgprov } catch( Exception& ){} } -#endif for ( sal_Int32 i = 0; i < nObjCount; ++i ) { @@ -339,10 +346,11 @@ namespace dlgprov Reference< XControlModel > xControlModel = xControl->getModel(); Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY ); attachEventsToControl( xControl, xEventsSupplier, Helper ); -#ifdef FAKE_VBA_EVENT_SUPPORT - xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); - attachEventsToControl( xControl, xEventsSupplier, Helper ); -#endif + if ( mbUseFakeVBAEvents ) + { + xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); + attachEventsToControl( xControl, xEventsSupplier, Helper ); + } } } diff --git a/scripting/source/dlgprov/dlgevtatt.hxx b/scripting/source/dlgprov/dlgevtatt.hxx index 7e7e23f747..c76ee093da 100644 --- a/scripting/source/dlgprov/dlgevtatt.hxx +++ b/scripting/source/dlgprov/dlgevtatt.hxx @@ -44,8 +44,6 @@ #include <hash_map> -#define FAKE_VBA_EVENT_SUPPORT 1 - //......................................................................... namespace dlgprov { @@ -66,13 +64,12 @@ namespace dlgprov class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE { private: + bool mbUseFakeVBAEvents; ListenerHash listernersForTypes; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher; ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const rtl::OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException ); -#ifdef FAKE_VBA_EVENT_SUPPORT ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, rtl::OUString& sCodeName ); -#endif void SAL_CALL attachEventsToControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier >& events, const ::com::sun::star::uno::Any& Helper ); public: DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, diff --git a/scripting/source/dlgprov/makefile.mk b/scripting/source/dlgprov/makefile.mk index 4554234127..6c8ec298c7 100644 --- a/scripting/source/dlgprov/makefile.mk +++ b/scripting/source/dlgprov/makefile.mk @@ -59,6 +59,7 @@ SHL1STDLIBS= \ $(COMPHELPERLIB) \ $(UCBHELPERLIB) \ $(CPPULIB) \ + $(BASICLIB) \ $(SALLIB) SHL1DEPN= diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index 589aec94c2..6975fba08e 100755..100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -349,8 +349,8 @@ static TranslatePropMap aTranslatePropMap_Impl[] = { MAP_CHAR_LEN("mouseDragged"), { MAP_CHAR_LEN("_MouseMove"), ooMouseEvtToVBAMouseEvt, DenyMouseDrag, NULL } }, //liuchen, add to support VBA MouseMove event when the "Shift" key is pressed // keyPressed ooo event - { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyDown"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } }, - { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyPress"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } } + { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyDown"), ooKeyPressedToVBAKeyPressed, ApproveAll, NULL } }, + { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyPress"), ooKeyPressedToVBAKeyPressed, ApproveAll, NULL } } }; EventInfoHash& getEventTransInfo() @@ -929,9 +929,12 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* /*pRet*/ ) throw(Runtime Sequence< Any > aOutArgs; try { - uno::Reference< script::provider::XScript > xScript = xScriptProvider->getScript( url ); - if ( xScript.is() ) - xScript->invoke( aArguments, aOutArgsIndex, aOutArgs ); + if ( mpShell ) + { + uno::Any aRet; + mpShell->CallXScript( url, + aArguments, aRet, aOutArgsIndex, aOutArgs, false ); + } } catch ( uno::Exception& e ) { |