1*6998d047SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6998d047SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6998d047SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6998d047SAndrew Rist * distributed with this work for additional information 6*6998d047SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6998d047SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6998d047SAndrew Rist * "License"); you may not use this file except in compliance 9*6998d047SAndrew Rist * with the License. You may obtain a copy of the License at 10*6998d047SAndrew Rist * 11*6998d047SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6998d047SAndrew Rist * 13*6998d047SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6998d047SAndrew Rist * software distributed under the License is distributed on an 15*6998d047SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6998d047SAndrew Rist * KIND, either express or implied. See the License for the 17*6998d047SAndrew Rist * specific language governing permissions and limitations 18*6998d047SAndrew Rist * under the License. 19*6998d047SAndrew Rist * 20*6998d047SAndrew Rist *************************************************************/ 21*6998d047SAndrew Rist 22*6998d047SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SCRIPTING_DLGEVTATT_HXX 25cdf0e10cSrcweir #define SCRIPTING_DLGEVTATT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 28cdf0e10cSrcweir #include <com/sun/star/script/XAllListener.hpp> 29cdf0e10cSrcweir #include <com/sun/star/script/XEventAttacher.hpp> 30cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsAttacher.hpp> 31cdf0e10cSrcweir #include <com/sun/star/script/XScriptListener.hpp> 32cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 33cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp> 34cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XINTROSPECTION_HPP_ 35cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospectionAccess.hpp> 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsSupplier.hpp> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <hash_map> 42cdf0e10cSrcweir 43cdf0e10cSrcweir //......................................................................... 44cdf0e10cSrcweir namespace dlgprov 45cdf0e10cSrcweir { 46cdf0e10cSrcweir //......................................................................... 47cdf0e10cSrcweir 48cdf0e10cSrcweir // ============================================================================= 49cdf0e10cSrcweir // class DialogEventsAttacherImpl 50cdf0e10cSrcweir // ============================================================================= 51cdf0e10cSrcweir typedef std::hash_map< rtl::OUString, 52cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >, 53cdf0e10cSrcweir ::rtl::OUStringHash, 54cdf0e10cSrcweir ::std::equal_to< ::rtl::OUString > > ListenerHash; 55cdf0e10cSrcweir 56cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< 57cdf0e10cSrcweir ::com::sun::star::script::XScriptEventsAttacher > DialogEventsAttacherImpl_BASE; 58cdf0e10cSrcweir 59cdf0e10cSrcweir 60cdf0e10cSrcweir class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE 61cdf0e10cSrcweir { 62cdf0e10cSrcweir private: 63cdf0e10cSrcweir bool mbUseFakeVBAEvents; 64cdf0e10cSrcweir ListenerHash listernersForTypes; 65cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 66cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher; 67cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const rtl::OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException ); 68cdf0e10cSrcweir ::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 ); 69cdf0e10cSrcweir 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 ); 70cdf0e10cSrcweir public: 71cdf0e10cSrcweir DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, 72cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel, 73cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& xControl, 74cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler, 75cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess >& xIntrospect, 76cdf0e10cSrcweir bool bProviderMode, 77cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& xRTLListener ); 78cdf0e10cSrcweir virtual ~DialogEventsAttacherImpl(); 79cdf0e10cSrcweir 80cdf0e10cSrcweir // XScriptEventsAttacher 81cdf0e10cSrcweir virtual void SAL_CALL attachEvents( const ::com::sun::star::uno::Sequence< 82cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects, 83cdf0e10cSrcweir const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener>&, 84cdf0e10cSrcweir const ::com::sun::star::uno::Any& Helper ) 85cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, 86cdf0e10cSrcweir ::com::sun::star::beans::IntrospectionException, 87cdf0e10cSrcweir ::com::sun::star::script::CannotCreateAdapterException, 88cdf0e10cSrcweir ::com::sun::star::lang::ServiceNotRegisteredException, 89cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 90cdf0e10cSrcweir }; 91cdf0e10cSrcweir 92cdf0e10cSrcweir 93cdf0e10cSrcweir // ============================================================================= 94cdf0e10cSrcweir // class DialogAllListenerImpl 95cdf0e10cSrcweir // ============================================================================= 96cdf0e10cSrcweir 97cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< 98cdf0e10cSrcweir ::com::sun::star::script::XAllListener > DialogAllListenerImpl_BASE; 99cdf0e10cSrcweir 100cdf0e10cSrcweir 101cdf0e10cSrcweir class DialogAllListenerImpl : public DialogAllListenerImpl_BASE 102cdf0e10cSrcweir { 103cdf0e10cSrcweir private: 104cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > m_xScriptListener; 105cdf0e10cSrcweir ::rtl::OUString m_sScriptType; 106cdf0e10cSrcweir ::rtl::OUString m_sScriptCode; 107cdf0e10cSrcweir 108cdf0e10cSrcweir virtual void firing_impl( const ::com::sun::star::script::AllEventObject& Event, ::com::sun::star::uno::Any* pRet ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir public: 111cdf0e10cSrcweir DialogAllListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& rxListener, 112cdf0e10cSrcweir const ::rtl::OUString& rScriptType, const ::rtl::OUString& rScriptCode ); 113cdf0e10cSrcweir virtual ~DialogAllListenerImpl(); 114cdf0e10cSrcweir 115cdf0e10cSrcweir // XEventListener 116cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 117cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 118cdf0e10cSrcweir 119cdf0e10cSrcweir // XAllListener 120cdf0e10cSrcweir virtual void SAL_CALL firing( const ::com::sun::star::script::AllEventObject& Event ) 121cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 122cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::AllEventObject& Event ) 123cdf0e10cSrcweir throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); 124cdf0e10cSrcweir }; 125cdf0e10cSrcweir 126cdf0e10cSrcweir 127cdf0e10cSrcweir // ============================================================================= 128cdf0e10cSrcweir // class DialogScriptListenerImpl 129cdf0e10cSrcweir // ============================================================================= 130cdf0e10cSrcweir 131cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< 132cdf0e10cSrcweir ::com::sun::star::script::XScriptListener > DialogScriptListenerImpl_BASE; 133cdf0e10cSrcweir 134cdf0e10cSrcweir 135cdf0e10cSrcweir class DialogScriptListenerImpl : public DialogScriptListenerImpl_BASE 136cdf0e10cSrcweir { 137cdf0e10cSrcweir protected: 138cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 139cdf0e10cSrcweir virtual void firing_impl( const ::com::sun::star::script::ScriptEvent& aScriptEvent, ::com::sun::star::uno::Any* pRet ) = 0; 140cdf0e10cSrcweir public: DialogScriptListenerImpl(const::com::sun::star::uno::Reference<::com::sun::star::uno::XComponentContext> & rxContext)141cdf0e10cSrcweir DialogScriptListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) : m_xContext( rxContext ) {} 142cdf0e10cSrcweir virtual ~DialogScriptListenerImpl(); 143cdf0e10cSrcweir 144cdf0e10cSrcweir // XEventListener 145cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 146cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 147cdf0e10cSrcweir 148cdf0e10cSrcweir // XScriptListener 149cdf0e10cSrcweir virtual void SAL_CALL firing( const ::com::sun::star::script::ScriptEvent& aScriptEvent ) 150cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 151cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::ScriptEvent& aScriptEvent ) 152cdf0e10cSrcweir throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); 153cdf0e10cSrcweir }; 154cdf0e10cSrcweir 155cdf0e10cSrcweir 156cdf0e10cSrcweir //......................................................................... 157cdf0e10cSrcweir } // namespace dlgprov 158cdf0e10cSrcweir //......................................................................... 159cdf0e10cSrcweir 160cdf0e10cSrcweir #endif // SCRIPTING_DLGEVT_HXX 161