summaryrefslogtreecommitdiff
path: root/scripting/source/dlgprov
diff options
context:
space:
mode:
authorAndreas Bregas <ab@openoffice.org>2009-06-17 13:32:41 +0000
committerAndreas Bregas <ab@openoffice.org>2009-06-17 13:32:41 +0000
commit00ef2d5056e1f679402bd71f80a0daa80702f9bb (patch)
treee17259da7913ed38da0805b54095ea100a271c19 /scripting/source/dlgprov
parent4dc94a51c18e7b3fb3e4498029fa39b8821b8d77 (diff)
#i102261# OLE control event handler support
Diffstat (limited to 'scripting/source/dlgprov')
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx26
-rw-r--r--scripting/source/dlgprov/dlgevtatt.hxx5
2 files changed, 25 insertions, 6 deletions
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 6a6b6dbbbb4a..39e1f8008f75 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -121,18 +121,20 @@ namespace dlgprov
DialogVBAScriptListenerImpl::DialogVBAScriptListenerImpl( const Reference< XComponentContext >& rxContext, const Reference< awt::XControl >& rxControl, const Reference< frame::XModel >& xModel ) : DialogScriptListenerImpl( rxContext )
{
Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
+ Sequence< Any > args(1);
if ( xSMgr.is() )
{
- Sequence< Any > args(1);
args[0] <<= xModel;
mxListener = Reference< XScriptListener >( xSMgr->createInstanceWithArgumentsAndContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.EventListener" ) ), args, m_xContext ), UNO_QUERY );
}
if ( rxControl.is() )
{
- Reference< XPropertySet > xProps( rxControl->getModel(), UNO_QUERY );
try
{
+ Reference< XPropertySet > xProps( rxControl->getModel(), UNO_QUERY_THROW );
xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= msDialogCodeName;
+ xProps.set( mxListener, UNO_QUERY_THROW );
+ xProps->setPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ), args[ 0 ] );
}
catch ( Exception& ) {}
}
@@ -193,7 +195,7 @@ namespace dlgprov
return it->second;
}
#ifdef FAKE_VBA_EVENT_SUPPORT
- Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl )
+ Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl, rtl::OUString& sControlName )
{
Reference< XScriptEventsSupplier > xEventsSupplier;
Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
@@ -201,7 +203,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 );
+ xEventsSupplier.set( xVBAToOOEvtDesc->getEventSupplier( xControl, sControlName ), UNO_QUERY );
}
return xEventsSupplier;
@@ -324,6 +326,20 @@ 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() )
+ {
+ Reference< XPropertySet > xProps( xDlgControl->getModel(), UNO_QUERY );
+ try
+ {
+ xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sDialogCodeName;
+ }
+ catch( Exception& ){}
+ }
+#endif
+
for ( sal_Int32 i = 0; i < nObjCount; ++i )
{
// We know that we have to do with instances of XControl.
@@ -338,7 +354,7 @@ namespace dlgprov
Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY );
attachEventsToControl( xControl, xEventsSupplier, Helper );
#ifdef FAKE_VBA_EVENT_SUPPORT
- xEventsSupplier.set( getFakeVbaEventsSupplier( xControl ) );
+ xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) );
attachEventsToControl( xControl, xEventsSupplier, Helper );
#endif
}
diff --git a/scripting/source/dlgprov/dlgevtatt.hxx b/scripting/source/dlgprov/dlgevtatt.hxx
index b52cb41b9dd7..efb7dd29e7f0 100644
--- a/scripting/source/dlgprov/dlgevtatt.hxx
+++ b/scripting/source/dlgprov/dlgevtatt.hxx
@@ -46,6 +46,9 @@
#include <com/sun/star/script/XScriptEventsSupplier.hpp>
#include <hash_map>
+
+#define FAKE_VBA_EVENT_SUPPORT 1
+
//.........................................................................
namespace dlgprov
{
@@ -71,7 +74,7 @@ namespace dlgprov
::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 );
+ ::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: