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 INCLUDED_SCRIPTING_SOURCE_DLGPROV_DLGEVTATT_HXX
21 : #define INCLUDED_SCRIPTING_SOURCE_DLGPROV_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 <unordered_map>
36 :
37 : namespace dlgprov
38 : {
39 : // class DialogEventsAttacherImpl
40 : typedef std::unordered_map< OUString,
41 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >,
42 : OUStringHash,
43 : std::equal_to< OUString > > ListenerHash;
44 :
45 : typedef ::cppu::WeakImplHelper1<
46 : ::com::sun::star::script::XScriptEventsAttacher > DialogEventsAttacherImpl_BASE;
47 :
48 :
49 : class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE
50 : {
51 : private:
52 : bool mbUseFakeVBAEvents;
53 : ListenerHash listernersForTypes;
54 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
55 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher;
56 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException );
57 : ::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 );
58 : 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 );
59 : void 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 );
60 : public:
61 : DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
62 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel,
63 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& xControl,
64 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler,
65 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess >& xIntrospect,
66 : bool bProviderMode,
67 : const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& xRTLListener ,const OUString& sDialogLibName );
68 : virtual ~DialogEventsAttacherImpl();
69 :
70 : // XScriptEventsAttacher
71 : virtual void SAL_CALL attachEvents( const ::com::sun::star::uno::Sequence<
72 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects,
73 : const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener>&,
74 : const ::com::sun::star::uno::Any& Helper )
75 : throw (::com::sun::star::lang::IllegalArgumentException,
76 : ::com::sun::star::beans::IntrospectionException,
77 : ::com::sun::star::script::CannotCreateAdapterException,
78 : ::com::sun::star::lang::ServiceNotRegisteredException,
79 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 : };
81 :
82 :
83 :
84 : // class DialogAllListenerImpl
85 :
86 :
87 : typedef ::cppu::WeakImplHelper1<
88 : ::com::sun::star::script::XAllListener > DialogAllListenerImpl_BASE;
89 :
90 :
91 : class DialogAllListenerImpl : public DialogAllListenerImpl_BASE
92 : {
93 : private:
94 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > m_xScriptListener;
95 : OUString m_sScriptType;
96 : OUString m_sScriptCode;
97 :
98 : void firing_impl( const ::com::sun::star::script::AllEventObject& Event, ::com::sun::star::uno::Any* pRet );
99 :
100 : public:
101 : DialogAllListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener >& rxListener,
102 : const OUString& rScriptType, const OUString& rScriptCode );
103 : virtual ~DialogAllListenerImpl();
104 :
105 : // XEventListener
106 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
107 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 :
109 : // XAllListener
110 : virtual void SAL_CALL firing( const ::com::sun::star::script::AllEventObject& Event )
111 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::AllEventObject& Event )
113 : throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : };
115 :
116 :
117 :
118 : // class DialogScriptListenerImpl
119 :
120 :
121 : typedef ::cppu::WeakImplHelper1<
122 : ::com::sun::star::script::XScriptListener > DialogScriptListenerImpl_BASE;
123 :
124 :
125 : class DialogScriptListenerImpl : public DialogScriptListenerImpl_BASE
126 : {
127 : protected:
128 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
129 : virtual void firing_impl( const ::com::sun::star::script::ScriptEvent& aScriptEvent, ::com::sun::star::uno::Any* pRet ) = 0;
130 : public:
131 8 : DialogScriptListenerImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) : m_xContext( rxContext ) {}
132 : virtual ~DialogScriptListenerImpl();
133 :
134 : // XEventListener
135 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
136 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 :
138 : // XScriptListener
139 : virtual void SAL_CALL firing( const ::com::sun::star::script::ScriptEvent& aScriptEvent )
140 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual ::com::sun::star::uno::Any SAL_CALL approveFiring( const ::com::sun::star::script::ScriptEvent& aScriptEvent )
142 : throw (::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 : };
144 :
145 :
146 :
147 : } // namespace dlgprov
148 :
149 :
150 : #endif // SCRIPTING_DLGEVT_HXX
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|