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/implbase.hxx>
33 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
35 #include <unordered_map>
39 // class DialogEventsAttacherImpl
40 typedef std::unordered_map
< OUString
,
41 css::uno::Reference
< css::script::XScriptListener
> > ListenerHash
;
43 typedef ::cppu::WeakImplHelper
<
44 css::script::XScriptEventsAttacher
> DialogEventsAttacherImpl_BASE
;
47 class DialogEventsAttacherImpl
: public DialogEventsAttacherImpl_BASE
50 bool mbUseFakeVBAEvents
;
51 ListenerHash listenersForTypes
;
52 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
53 css::uno::Reference
< css::script::XEventAttacher
> m_xEventAttacher
;
54 /// @throws css::uno::RuntimeException
55 css::uno::Reference
< css::script::XScriptListener
> const & getScriptListenerForKey( const OUString
& sScriptName
);
56 css::uno::Reference
< css::script::XScriptEventsSupplier
> getFakeVbaEventsSupplier( const css::uno::Reference
< css::awt::XControl
>& xControl
, OUString
const & sCodeName
);
57 void nestedAttachEvents( const css::uno::Sequence
< css::uno::Reference
< css::uno::XInterface
> >& Objects
, const css::uno::Any
& Helper
, OUString
& sDialogCodeName
);
58 void attachEventsToControl( const css::uno::Reference
< css::awt::XControl
>& xControl
, const css::uno::Reference
< css::script::XScriptEventsSupplier
>& events
, const css::uno::Any
& Helper
);
60 DialogEventsAttacherImpl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
61 const css::uno::Reference
< css::frame::XModel
>& xModel
,
62 const css::uno::Reference
< css::awt::XControl
>& xControl
,
63 const css::uno::Reference
< css::uno::XInterface
>& xHandler
,
64 const css::uno::Reference
< css::beans::XIntrospectionAccess
>& xIntrospect
,
66 const css::uno::Reference
< css::script::XScriptListener
>& xRTLListener
,const OUString
& sDialogLibName
);
67 virtual ~DialogEventsAttacherImpl() override
;
69 // XScriptEventsAttacher
70 virtual void SAL_CALL
attachEvents( const css::uno::Sequence
<
71 css::uno::Reference
< css::uno::XInterface
> >& Objects
,
72 const css::uno::Reference
<css::script::XScriptListener
>&,
73 const css::uno::Any
& Helper
) override
;
77 // class DialogAllListenerImpl
80 typedef ::cppu::WeakImplHelper
<
81 css::script::XAllListener
> DialogAllListenerImpl_BASE
;
84 class DialogAllListenerImpl
: public DialogAllListenerImpl_BASE
87 css::uno::Reference
< css::script::XScriptListener
> m_xScriptListener
;
88 OUString
const m_sScriptType
;
89 OUString
const m_sScriptCode
;
91 void firing_impl( const css::script::AllEventObject
& Event
, css::uno::Any
* pRet
);
94 DialogAllListenerImpl( const css::uno::Reference
< css::script::XScriptListener
>& rxListener
,
95 const OUString
& rScriptType
, const OUString
& rScriptCode
);
96 virtual ~DialogAllListenerImpl() override
;
99 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
102 virtual void SAL_CALL
firing( const css::script::AllEventObject
& Event
) override
;
103 virtual css::uno::Any SAL_CALL
approveFiring( const css::script::AllEventObject
& Event
) override
;
107 // class DialogScriptListenerImpl
110 typedef ::cppu::WeakImplHelper
<
111 css::script::XScriptListener
> DialogScriptListenerImpl_BASE
;
114 class DialogScriptListenerImpl
: public DialogScriptListenerImpl_BASE
117 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
118 virtual void firing_impl( const css::script::ScriptEvent
& aScriptEvent
, css::uno::Any
* pRet
) = 0;
120 explicit DialogScriptListenerImpl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
) : m_xContext( rxContext
) {}
121 virtual ~DialogScriptListenerImpl() override
;
124 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
127 virtual void SAL_CALL
firing( const css::script::ScriptEvent
& aScriptEvent
) override
;
128 virtual css::uno::Any SAL_CALL
approveFiring( const css::script::ScriptEvent
& aScriptEvent
) override
;
132 } // namespace dlgprov
135 #endif // SCRIPTING_DLGEVT_HXX
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */