nss: upgrade to release 3.73
[LibreOffice.git] / scripting / source / dlgprov / dlgevtatt.hxx
blob239cb653040a0b08cdf00f05f6ed4471b7bd64cb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/script/XAllListener.hpp>
24 #include <com/sun/star/script/XEventAttacher.hpp>
25 #include <com/sun/star/script/XScriptEventsAttacher.hpp>
26 #include <com/sun/star/script/XScriptListener.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <com/sun/star/awt/XControl.hpp>
29 #include <com/sun/star/beans/XIntrospectionAccess.hpp>
30 #include <cppuhelper/implbase.hxx>
32 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
34 #include <unordered_map>
36 namespace dlgprov
38 typedef std::unordered_map< OUString,
39 css::uno::Reference< css::script::XScriptListener > > ListenerHash;
41 typedef ::cppu::WeakImplHelper<
42 css::script::XScriptEventsAttacher > DialogEventsAttacherImpl_BASE;
45 class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE
47 private:
48 bool mbUseFakeVBAEvents;
49 ListenerHash listenersForTypes;
50 css::uno::Reference< css::uno::XComponentContext > m_xContext;
51 css::uno::Reference< css::script::XEventAttacher > m_xEventAttacher;
52 /// @throws css::uno::RuntimeException
53 css::uno::Reference< css::script::XScriptListener > const & getScriptListenerForKey( const OUString& sScriptName );
54 css::uno::Reference< css::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const css::uno::Reference< css::awt::XControl>& xControl, OUString const & sCodeName );
55 void nestedAttachEvents( const css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >& Objects, const css::uno::Any& Helper, OUString& sDialogCodeName );
56 void attachEventsToControl( const css::uno::Reference< css::awt::XControl>& xControl, const css::uno::Reference< css::script::XScriptEventsSupplier >& events, const css::uno::Any& Helper );
57 public:
58 DialogEventsAttacherImpl( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
59 const css::uno::Reference< css::frame::XModel >& xModel,
60 const css::uno::Reference< css::awt::XControl >& xControl,
61 const css::uno::Reference< css::uno::XInterface >& xHandler,
62 const css::uno::Reference< css::beans::XIntrospectionAccess >& xIntrospect,
63 bool bProviderMode,
64 const css::uno::Reference< css::script::XScriptListener >& xRTLListener ,const OUString& sDialogLibName );
65 virtual ~DialogEventsAttacherImpl() override;
67 // XScriptEventsAttacher
68 virtual void SAL_CALL attachEvents( const css::uno::Sequence<
69 css::uno::Reference< css::uno::XInterface > >& Objects,
70 const css::uno::Reference<css::script::XScriptListener>&,
71 const css::uno::Any& Helper ) override;
77 typedef ::cppu::WeakImplHelper<
78 css::script::XAllListener > DialogAllListenerImpl_BASE;
81 class DialogAllListenerImpl : public DialogAllListenerImpl_BASE
83 private:
84 css::uno::Reference< css::script::XScriptListener > m_xScriptListener;
85 OUString m_sScriptType;
86 OUString m_sScriptCode;
88 void firing_impl( const css::script::AllEventObject& Event, css::uno::Any* pRet );
90 public:
91 DialogAllListenerImpl( const css::uno::Reference< css::script::XScriptListener >& rxListener,
92 const OUString& rScriptType, const OUString& rScriptCode );
93 virtual ~DialogAllListenerImpl() override;
95 // XEventListener
96 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
98 // XAllListener
99 virtual void SAL_CALL firing( const css::script::AllEventObject& Event ) override;
100 virtual css::uno::Any SAL_CALL approveFiring( const css::script::AllEventObject& Event ) override;
106 typedef ::cppu::WeakImplHelper<
107 css::script::XScriptListener > DialogScriptListenerImpl_BASE;
110 class DialogScriptListenerImpl : public DialogScriptListenerImpl_BASE
112 protected:
113 css::uno::Reference< css::uno::XComponentContext > m_xContext;
114 virtual void firing_impl( const css::script::ScriptEvent& aScriptEvent, css::uno::Any* pRet ) = 0;
115 public:
116 explicit DialogScriptListenerImpl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) : m_xContext( rxContext ) {}
117 virtual ~DialogScriptListenerImpl() override;
119 // XEventListener
120 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
122 // XScriptListener
123 virtual void SAL_CALL firing( const css::script::ScriptEvent& aScriptEvent ) override;
124 virtual css::uno::Any SAL_CALL approveFiring( const css::script::ScriptEvent& aScriptEvent ) override;
128 } // namespace dlgprov
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */