xref: /AOO41X/main/scripting/source/dlgprov/dlgevtatt.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SCRIPTING_DLGEVTATT_HXX
29*cdf0e10cSrcweir #define SCRIPTING_DLGEVTATT_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/script/XAllListener.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/script/XEventAttacher.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsAttacher.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/script/XScriptListener.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp>
38*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XINTROSPECTION_HPP_
39*cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospectionAccess.hpp>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsSupplier.hpp>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <hash_map>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir //.........................................................................
48*cdf0e10cSrcweir namespace dlgprov
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir //.........................................................................
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir     // =============================================================================
53*cdf0e10cSrcweir     // class DialogEventsAttacherImpl
54*cdf0e10cSrcweir     // =============================================================================
55*cdf0e10cSrcweir     typedef std::hash_map< rtl::OUString,
56*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >,
57*cdf0e10cSrcweir         ::rtl::OUStringHash,
58*cdf0e10cSrcweir         ::std::equal_to< ::rtl::OUString > > ListenerHash;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir     typedef ::cppu::WeakImplHelper1<
61*cdf0e10cSrcweir         ::com::sun::star::script::XScriptEventsAttacher > DialogEventsAttacherImpl_BASE;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE
65*cdf0e10cSrcweir     {
66*cdf0e10cSrcweir     private:
67*cdf0e10cSrcweir         bool mbUseFakeVBAEvents;
68*cdf0e10cSrcweir         ListenerHash listernersForTypes;
69*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
70*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher;
71*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const rtl::OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException );
72*cdf0e10cSrcweir         ::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 );
73*cdf0e10cSrcweir         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  );
74*cdf0e10cSrcweir     public:
75*cdf0e10cSrcweir         DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
76*cdf0e10cSrcweir         	 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel,
77*cdf0e10cSrcweir         	 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& xControl,
78*cdf0e10cSrcweir         	 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler,
79*cdf0e10cSrcweir         	 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess >& xIntrospect,
80*cdf0e10cSrcweir              bool bProviderMode,
81*cdf0e10cSrcweir         	 const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& xRTLListener );
82*cdf0e10cSrcweir         virtual ~DialogEventsAttacherImpl();
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir         // XScriptEventsAttacher
85*cdf0e10cSrcweir         virtual void SAL_CALL attachEvents( const ::com::sun::star::uno::Sequence<
86*cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects,
87*cdf0e10cSrcweir 			const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener>&,
88*cdf0e10cSrcweir             const ::com::sun::star::uno::Any& Helper )
89*cdf0e10cSrcweir             throw (::com::sun::star::lang::IllegalArgumentException,
90*cdf0e10cSrcweir                    ::com::sun::star::beans::IntrospectionException,
91*cdf0e10cSrcweir                    ::com::sun::star::script::CannotCreateAdapterException,
92*cdf0e10cSrcweir                    ::com::sun::star::lang::ServiceNotRegisteredException,
93*cdf0e10cSrcweir                    ::com::sun::star::uno::RuntimeException);
94*cdf0e10cSrcweir     };
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     // =============================================================================
98*cdf0e10cSrcweir     // class DialogAllListenerImpl
99*cdf0e10cSrcweir     // =============================================================================
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     typedef ::cppu::WeakImplHelper1<
102*cdf0e10cSrcweir         ::com::sun::star::script::XAllListener > DialogAllListenerImpl_BASE;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     class DialogAllListenerImpl : public DialogAllListenerImpl_BASE
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir     private:
108*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > m_xScriptListener;
109*cdf0e10cSrcweir         ::rtl::OUString m_sScriptType;
110*cdf0e10cSrcweir         ::rtl::OUString m_sScriptCode;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir         virtual void firing_impl( const ::com::sun::star::script::AllEventObject& Event, ::com::sun::star::uno::Any* pRet );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     public:
115*cdf0e10cSrcweir         DialogAllListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& rxListener,
116*cdf0e10cSrcweir             const ::rtl::OUString& rScriptType, const ::rtl::OUString& rScriptCode );
117*cdf0e10cSrcweir         virtual ~DialogAllListenerImpl();
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir         // XEventListener
120*cdf0e10cSrcweir         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
121*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir         // XAllListener
124*cdf0e10cSrcweir         virtual void SAL_CALL firing( const ::com::sun::star::script::AllEventObject& Event )
125*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
126*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::AllEventObject& Event )
127*cdf0e10cSrcweir             throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
128*cdf0e10cSrcweir     };
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     // =============================================================================
132*cdf0e10cSrcweir     // class DialogScriptListenerImpl
133*cdf0e10cSrcweir     // =============================================================================
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     typedef ::cppu::WeakImplHelper1<
136*cdf0e10cSrcweir         ::com::sun::star::script::XScriptListener > DialogScriptListenerImpl_BASE;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     class DialogScriptListenerImpl : public DialogScriptListenerImpl_BASE
140*cdf0e10cSrcweir     {
141*cdf0e10cSrcweir     protected:
142*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
143*cdf0e10cSrcweir         virtual void firing_impl( const ::com::sun::star::script::ScriptEvent& aScriptEvent, ::com::sun::star::uno::Any* pRet ) = 0;
144*cdf0e10cSrcweir     public:
145*cdf0e10cSrcweir         DialogScriptListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) : m_xContext( rxContext ) {}
146*cdf0e10cSrcweir         virtual ~DialogScriptListenerImpl();
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir         // XEventListener
149*cdf0e10cSrcweir         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
150*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         // XScriptListener
153*cdf0e10cSrcweir         virtual void SAL_CALL firing( const ::com::sun::star::script::ScriptEvent& aScriptEvent )
154*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
155*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::ScriptEvent& aScriptEvent )
156*cdf0e10cSrcweir             throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
157*cdf0e10cSrcweir     };
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir //.........................................................................
161*cdf0e10cSrcweir }	// namespace dlgprov
162*cdf0e10cSrcweir //.........................................................................
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir #endif // SCRIPTING_DLGEVT_HXX
165