1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SCRIPTING_SOURCE_DLGPROV_DLGEVTATT_HXX
21 #define INCLUDED_SCRIPTING_SOURCE_DLGPROV_DLGEVTATT_HXX
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>
33 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
35 #include <unordered_map>
39 // class DialogEventsAttacherImpl
40 typedef std::unordered_map
< OUString
,
41 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>,
43 std::equal_to
< OUString
> > ListenerHash
;
45 typedef ::cppu::WeakImplHelper1
<
46 ::com::sun::star::script::XScriptEventsAttacher
> DialogEventsAttacherImpl_BASE
;
49 class DialogEventsAttacherImpl
: public DialogEventsAttacherImpl_BASE
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
);
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
,
67 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>& xRTLListener
,const OUString
& sDialogLibName
);
68 virtual ~DialogEventsAttacherImpl();
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
;
84 // class DialogAllListenerImpl
87 typedef ::cppu::WeakImplHelper1
<
88 ::com::sun::star::script::XAllListener
> DialogAllListenerImpl_BASE
;
91 class DialogAllListenerImpl
: public DialogAllListenerImpl_BASE
94 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
> m_xScriptListener
;
95 OUString m_sScriptType
;
96 OUString m_sScriptCode
;
98 void firing_impl( const ::com::sun::star::script::AllEventObject
& Event
, ::com::sun::star::uno::Any
* pRet
);
101 DialogAllListenerImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>& rxListener
,
102 const OUString
& rScriptType
, const OUString
& rScriptCode
);
103 virtual ~DialogAllListenerImpl();
106 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
107 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
;
118 // class DialogScriptListenerImpl
121 typedef ::cppu::WeakImplHelper1
<
122 ::com::sun::star::script::XScriptListener
> DialogScriptListenerImpl_BASE
;
125 class DialogScriptListenerImpl
: public DialogScriptListenerImpl_BASE
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;
131 DialogScriptListenerImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
) : m_xContext( rxContext
) {}
132 virtual ~DialogScriptListenerImpl();
135 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
136 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
;
147 } // namespace dlgprov
150 #endif // SCRIPTING_DLGEVT_HXX
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */