Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SCRIPTING_DLGEVTATT_HXX
21 : #define SCRIPTING_DLGEVTATT_HXX
22 :
23 : #include <com/sun/star/frame/XModel.hpp>
24 : #include <com/sun/star/script/XAllListener.hpp>
25 : #include <com/sun/star/script/XEventAttacher.hpp>
26 : #include <com/sun/star/script/XScriptEventsAttacher.hpp>
27 : #include <com/sun/star/script/XScriptListener.hpp>
28 : #include <com/sun/star/uno/XComponentContext.hpp>
29 : #include <com/sun/star/awt/XControl.hpp>
30 : #include <com/sun/star/beans/XIntrospectionAccess.hpp>
31 : #include <cppuhelper/implbase1.hxx>
32 :
33 : #include <com/sun/star/script/XScriptEventsSupplier.hpp>
34 :
35 : #include <boost/unordered_map.hpp>
36 :
37 :
38 : namespace dlgprov
39 : {
40 :
41 :
42 :
43 : // class DialogEventsAttacherImpl
44 :
45 : typedef boost::unordered_map< OUString,
46 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >,
47 : OUStringHash,
48 : ::std::equal_to< OUString > > ListenerHash;
49 :
50 : typedef ::cppu::WeakImplHelper1<
51 : ::com::sun::star::script::XScriptEventsAttacher > DialogEventsAttacherImpl_BASE;
52 :
53 :
54 : class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE
55 : {
56 : private:
57 : bool mbUseFakeVBAEvents;
58 : ListenerHash listernersForTypes;
59 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
60 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher;
61 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException );
62 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, OUString& sCodeName );
63 : 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, OUString& sDialogCodeName );
64 : 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 );
65 : public:
66 : DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
67 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel,
68 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& xControl,
69 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler,
70 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess >& xIntrospect,
71 : bool bProviderMode,
72 : const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& xRTLListener ,const OUString& sDialogLibName );
73 : virtual ~DialogEventsAttacherImpl();
74 :
75 : // XScriptEventsAttacher
76 : virtual void SAL_CALL attachEvents( const ::com::sun::star::uno::Sequence<
77 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects,
78 : const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener>&,
79 : const ::com::sun::star::uno::Any& Helper )
80 : throw (::com::sun::star::lang::IllegalArgumentException,
81 : ::com::sun::star::beans::IntrospectionException,
82 : ::com::sun::star::script::CannotCreateAdapterException,
83 : ::com::sun::star::lang::ServiceNotRegisteredException,
84 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 : };
86 :
87 :
88 :
89 : // class DialogAllListenerImpl
90 :
91 :
92 : typedef ::cppu::WeakImplHelper1<
93 : ::com::sun::star::script::XAllListener > DialogAllListenerImpl_BASE;
94 :
95 :
96 : class DialogAllListenerImpl : public DialogAllListenerImpl_BASE
97 : {
98 : private:
99 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > m_xScriptListener;
100 : OUString m_sScriptType;
101 : OUString m_sScriptCode;
102 :
103 : virtual void firing_impl( const ::com::sun::star::script::AllEventObject& Event, ::com::sun::star::uno::Any* pRet );
104 :
105 : public:
106 : DialogAllListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& rxListener,
107 : const OUString& rScriptType, const OUString& rScriptCode );
108 : virtual ~DialogAllListenerImpl();
109 :
110 : // XEventListener
111 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
112 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 :
114 : // XAllListener
115 : virtual void SAL_CALL firing( const ::com::sun::star::script::AllEventObject& Event )
116 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 : virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::AllEventObject& Event )
118 : throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 : };
120 :
121 :
122 :
123 : // class DialogScriptListenerImpl
124 :
125 :
126 : typedef ::cppu::WeakImplHelper1<
127 : ::com::sun::star::script::XScriptListener > DialogScriptListenerImpl_BASE;
128 :
129 :
130 : class DialogScriptListenerImpl : public DialogScriptListenerImpl_BASE
131 : {
132 : protected:
133 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
134 : virtual void firing_impl( const ::com::sun::star::script::ScriptEvent& aScriptEvent, ::com::sun::star::uno::Any* pRet ) = 0;
135 : public:
136 0 : DialogScriptListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) : m_xContext( rxContext ) {}
137 : virtual ~DialogScriptListenerImpl();
138 :
139 : // XEventListener
140 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
141 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 :
143 : // XScriptListener
144 : virtual void SAL_CALL firing( const ::com::sun::star::script::ScriptEvent& aScriptEvent )
145 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::ScriptEvent& aScriptEvent )
147 : throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 : };
149 :
150 :
151 :
152 : } // namespace dlgprov
153 :
154 :
155 : #endif // SCRIPTING_DLGEVT_HXX
156 :
157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|