diff options
author | Noel Power <noel.power@novell.com> | 2010-11-02 16:22:07 +0000 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2010-11-02 19:52:04 +0000 |
commit | 928159ff71d19a3910d1fd1e472a11ef1c89415b (patch) | |
tree | 25f0500b8985d8c5eb2aad05acd3302efc9845b6 /scripting | |
parent | 919a8118197dbcce6aa363124cde1707f9d797e9 (diff) |
initial import of latest cws container_controls
Diffstat (limited to 'scripting')
-rwxr-xr-x | scripting/prj/build.lst | 2 | ||||
-rw-r--r-- | scripting/source/dlgprov/dlgevtatt.cxx | 76 | ||||
-rw-r--r-- | scripting/source/dlgprov/dlgevtatt.hxx | 1 | ||||
-rw-r--r-- | scripting/source/vbaevents/eventhelper.cxx | 66 |
4 files changed, 90 insertions, 55 deletions
diff --git a/scripting/prj/build.lst b/scripting/prj/build.lst index 7d5162173eae..28fcdbc2e6f7 100755 --- a/scripting/prj/build.lst +++ b/scripting/prj/build.lst @@ -1,4 +1,4 @@ -tc scripting : oovbaapi vbahelper bridges rdbmaker vcl xmlscript basic sfx2 rhino BSH:beanshell javaunohelper NULL +tc scripting : filter 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 836d723a14c1..d3bb20db13aa 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -38,6 +38,7 @@ #include <tools/diagnose_ex.h> #include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/awt/XDialogEventHandler.hpp> #include <com/sun/star/awt/XContainerWindowEventHandler.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -232,6 +233,9 @@ namespace dlgprov Reference< container::XNameContainer > xEventCont = xEventsSupplier->getEvents(); Reference< XControlModel > xControlModel = xControl->getModel(); + Reference< XPropertySet > xProps( xControlModel, uno::UNO_QUERY ); + rtl::OUString sName; + xProps->getPropertyValue( rtl::OUString::createFromAscii("Name") ) >>= sName; if ( xEventCont.is() ) { Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames(); @@ -288,6 +292,51 @@ namespace dlgprov } } + + void DialogEventsAttacherImpl::nestedAttachEvents( const Sequence< Reference< XInterface > >& Objects, const Any& Helper, rtl::OUString& sDialogCodeName ) + { + const Reference< XInterface >* pObjects = Objects.getConstArray(); + sal_Int32 nObjCount = Objects.getLength(); + + for ( sal_Int32 i = 0; i < nObjCount; ++i ) + { + // We know that we have to do with instances of XControl. + // Otherwise this is not the right implementation for + // XScriptEventsAttacher and we have to give up. + Reference< XControl > xControl( pObjects[ i ], UNO_QUERY ); + Reference< XControlContainer > xControlContainer( xControl, UNO_QUERY ); + Reference< XDialog > xDialog( xControl, UNO_QUERY ); + if ( !xControl.is() ) + throw IllegalArgumentException(); + + // get XEventsSupplier from control model + Reference< XControlModel > xControlModel = xControl->getModel(); + Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY ); + attachEventsToControl( xControl, xEventsSupplier, Helper ); + if ( mbUseFakeVBAEvents ) + { + xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); + Any newHelper(xControl ); + attachEventsToControl( xControl, xEventsSupplier, newHelper ); + } + if ( xControlContainer.is() && !xDialog.is() ) + { + Sequence< Reference< XControl > > aControls = xControlContainer->getControls(); + sal_Int32 nControlCount = aControls.getLength(); + + Sequence< Reference< XInterface > > aObjects( nControlCount ); + Reference< XInterface >* pObjectsModify = aObjects.getArray(); + const Reference< XControl >* pControls = aControls.getConstArray(); + + for ( sal_Int32 j = 0; j < nControlCount; ++j ) + { + pObjectsModify[j] = Reference< XInterface >( pControls[j], UNO_QUERY ); + } + nestedAttachEvents( aObjects, Helper, sDialogCodeName ); + } + } + } + // ----------------------------------------------------------------------------- // XScriptEventsAttacher // ----------------------------------------------------------------------------- @@ -320,12 +369,9 @@ namespace dlgprov } } - - // go over all objects - const Reference< XInterface >* pObjects = Objects.getConstArray(); + rtl::OUString sDialogCodeName; sal_Int32 nObjCount = Objects.getLength(); 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 ); @@ -335,26 +381,8 @@ namespace dlgprov } catch( Exception& ){} } - - for ( sal_Int32 i = 0; i < nObjCount; ++i ) - { - // We know that we have to do with instances of XControl. - // Otherwise this is not the right implementation for - // XScriptEventsAttacher and we have to give up. - Reference< XControl > xControl( pObjects[ i ], UNO_QUERY ); - if ( !xControl.is() ) - throw IllegalArgumentException(); - - // get XEventsSupplier from control model - Reference< XControlModel > xControlModel = xControl->getModel(); - Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY ); - attachEventsToControl( xControl, xEventsSupplier, Helper ); - if ( mbUseFakeVBAEvents ) - { - xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); - attachEventsToControl( xControl, xEventsSupplier, Helper ); - } - } + // go over all objects + nestedAttachEvents( Objects, Helper, sDialogCodeName ); } diff --git a/scripting/source/dlgprov/dlgevtatt.hxx b/scripting/source/dlgprov/dlgevtatt.hxx index 437abc668838..dc24f1410a2f 100644 --- a/scripting/source/dlgprov/dlgevtatt.hxx +++ b/scripting/source/dlgprov/dlgevtatt.hxx @@ -69,6 +69,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 ); ::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 ); + void nestedAttachEvents( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects, const ::com::sun::star::uno::Any& Helper, rtl::OUString& sDialogCodeName ); 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/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index cfd1dad6b6cc..165b5f86a045 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -56,6 +56,7 @@ #include <com/sun/star/script/XLibraryContainer.hpp> #include <com/sun/star/script/ScriptEventDescriptor.hpp> #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/container/XNamed.hpp> @@ -688,9 +689,9 @@ private: Reference< XComponentContext > m_xContext; Reference< frame::XModel > m_xModel; - SfxObjectShell* mpShell; sal_Bool m_bDocClosed; - + SfxObjectShell* mpShell; + rtl::OUString msProject; }; EventListener::EventListener( const Reference< XComponentContext >& rxContext ) : @@ -698,7 +699,7 @@ OPropertyContainer(GetBroadcastHelper()), m_xContext( rxContext ), m_bDocClosed( { registerProperty( EVENTLSTNR_PROPERTY_MODEL, EVENTLSTNR_PROPERTY_ID_MODEL, beans::PropertyAttribute::TRANSIENT, &m_xModel, ::getCppuType( &m_xModel ) ); - + msProject = rtl::OUString::createFromAscii("Standard"); } void @@ -716,6 +717,14 @@ EventListener::setShellFromModel() } pShell = SfxObjectShell::GetNext( *pShell ); } + // set ProjectName from model + try + { + uno::Reference< beans::XPropertySet > xProps( m_xModel, UNO_QUERY_THROW ); + uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW ); + msProject = xVBAMode->getProjectName(); + } + catch ( uno::Exception& ) {} } //XEventListener @@ -772,13 +781,13 @@ EventListener::approveFiring(const ScriptEvent& evt) throw(reflection::Invocatio // XCloseListener void SAL_CALL -EventListener::queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException) +EventListener::queryClosing( const lang::EventObject& /*Source*/, ::sal_Bool /*GetsOwnership*/ ) throw (util::CloseVetoException, uno::RuntimeException) { //Nothing to do } void SAL_CALL -EventListener::notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException) +EventListener::notifyClosing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) { m_bDocClosed = sal_True; uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xModel, uno::UNO_QUERY ); @@ -931,36 +940,34 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce uno::Reference< awt::XDialog > xDlg( aEvent.Source, uno::UNO_QUERY ); if ( !xDlg.is() ) { - OSL_TRACE("Getting Control"); + OSL_TRACE("Getting Control"); // evt.Source is // a) Dialog // b) xShapeControl ( from api (sheet control) ) // c) eventmanager ( I guess ) // d) vba control ( from api also ) - uno::Reference< drawing::XControlShape > xCntrlShape( evt.Source, uno::UNO_QUERY ); - uno::Reference< awt::XControl > xControl( aEvent.Source, uno::UNO_QUERY ); - if ( xCntrlShape.is() ) - { - // for sheet controls ( that fire from the api ) we don't - // have the real control ( thats only available from the view ) - // api code creates just a control instance that is transferred - // via aEvent.Arguments[ 0 ] that control though has no - // info like name etc. - uno::Reference< drawing::XControlShape > xCntrlShape( evt.Source, UNO_QUERY_THROW ); - OSL_TRACE("Got control shape"); - uno::Reference< container::XNamed > xName( xCntrlShape->getControl(), uno::UNO_QUERY_THROW ); - OSL_TRACE("Got xnamed "); - sName = xName->getName(); - } - else + uno::Reference< drawing::XControlShape > xCntrlShape( evt.Source, uno::UNO_QUERY ); + uno::Reference< awt::XControl > xControl( aEvent.Source, uno::UNO_QUERY ); + if ( xCntrlShape.is() ) { - // Userform control ( fired from the api or from event manager ) - uno::Reference< beans::XPropertySet > xProps; - OSL_TRACE("Getting properties"); - xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sName; - } - + // for sheet controls ( that fire from the api ) we don't + // have the real control ( thats only available from the view ) + // api code creates just a control instance that is transferred + // via aEvent.Arguments[ 0 ] that control though has no + // info like name etc. + OSL_TRACE("Got control shape"); + uno::Reference< container::XNamed > xName( xCntrlShape->getControl(), uno::UNO_QUERY_THROW ); + OSL_TRACE("Got xnamed "); + sName = xName->getName(); + } + else + { + // Userform control ( fired from the api or from event manager ) + uno::Reference< beans::XPropertySet > xProps; + OSL_TRACE("Getting properties"); + xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sName; + } } //dumpEvent( evt ); EventInfoHash& infos = getEventTransInfo(); @@ -984,7 +991,6 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce eventInfo_it->second.begin(); std::list< TranslateInfo >::const_iterator txInfo_end = eventInfo_it->second.end(); - StarBASIC* pBasic = mpShell->GetBasic(); BasicManager* pBasicManager = mpShell->GetBasicManager(); rtl::OUString sProject; rtl::OUString sScriptCode( evt.ScriptCode ); |