tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / scripting / source / dlgprov / dlgevtatt.hxx
blob73e15ebb456675432f5a0b832f0e54cd459af0d7
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>
35 #include <utility>
37 namespace dlgprov
39 typedef std::unordered_map< OUString,
40 css::uno::Reference< css::script::XScriptListener > > ListenerHash;
42 typedef ::cppu::WeakImplHelper<
43 css::script::XScriptEventsAttacher > DialogEventsAttacherImpl_BASE;
46 class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE
48 private:
49 bool mbUseFakeVBAEvents;
50 ListenerHash listenersForTypes;
51 css::uno::Reference< css::uno::XComponentContext > m_xContext;
52 css::uno::Reference< css::script::XEventAttacher > m_xEventAttacher;
53 /// @throws css::uno::RuntimeException
54 css::uno::Reference< css::script::XScriptListener > const & getScriptListenerForKey( const OUString& sScriptName );
55 css::uno::Reference< css::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const css::uno::Reference< css::awt::XControl>& xControl, OUString const & sCodeName );
56 void nestedAttachEvents( const css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >& Objects, const css::uno::Any& Helper, OUString& sDialogCodeName );
57 void nestedAttachEvents( const css::uno::Reference< css::awt::XControl >& xControl, 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 );
59 public:
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,
65 bool bProviderMode,
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;
79 typedef ::cppu::WeakImplHelper<
80 css::script::XAllListener > DialogAllListenerImpl_BASE;
83 class DialogAllListenerImpl : public DialogAllListenerImpl_BASE
85 private:
86 css::uno::Reference< css::script::XScriptListener > m_xScriptListener;
87 OUString m_sScriptType;
88 OUString m_sScriptCode;
90 void firing_impl( const css::script::AllEventObject& Event, css::uno::Any* pRet );
92 public:
93 DialogAllListenerImpl( const css::uno::Reference< css::script::XScriptListener >& rxListener,
94 OUString sScriptType, OUString sScriptCode );
95 virtual ~DialogAllListenerImpl() override;
97 // XEventListener
98 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
100 // XAllListener
101 virtual void SAL_CALL firing( const css::script::AllEventObject& Event ) override;
102 virtual css::uno::Any SAL_CALL approveFiring( const css::script::AllEventObject& Event ) override;
108 typedef ::cppu::WeakImplHelper<
109 css::script::XScriptListener > DialogScriptListenerImpl_BASE;
112 class DialogScriptListenerImpl : public DialogScriptListenerImpl_BASE
114 protected:
115 css::uno::Reference< css::uno::XComponentContext > m_xContext;
116 virtual void firing_impl( const css::script::ScriptEvent& aScriptEvent, css::uno::Any* pRet ) = 0;
117 public:
118 explicit DialogScriptListenerImpl( css::uno::Reference< css::uno::XComponentContext > xContext ) : m_xContext(std::move( xContext )) {}
119 virtual ~DialogScriptListenerImpl() override;
121 // XEventListener
122 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
124 // XScriptListener
125 virtual void SAL_CALL firing( const css::script::ScriptEvent& aScriptEvent ) override;
126 virtual css::uno::Any SAL_CALL approveFiring( const css::script::ScriptEvent& aScriptEvent ) override;
130 } // namespace dlgprov
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */