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 .
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>
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
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 attachEventsToControl( const css::uno::Reference
< css::awt::XControl
>& xControl
, const css::uno::Reference
< css::script::XScriptEventsSupplier
>& events
, const css::uno::Any
& Helper
);
59 DialogEventsAttacherImpl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
60 const css::uno::Reference
< css::frame::XModel
>& xModel
,
61 const css::uno::Reference
< css::awt::XControl
>& xControl
,
62 const css::uno::Reference
< css::uno::XInterface
>& xHandler
,
63 const css::uno::Reference
< css::beans::XIntrospectionAccess
>& xIntrospect
,
65 const css::uno::Reference
< css::script::XScriptListener
>& xRTLListener
,const OUString
& sDialogLibName
);
66 virtual ~DialogEventsAttacherImpl() override
;
68 // XScriptEventsAttacher
69 virtual void SAL_CALL
attachEvents( const css::uno::Sequence
<
70 css::uno::Reference
< css::uno::XInterface
> >& Objects
,
71 const css::uno::Reference
<css::script::XScriptListener
>&,
72 const css::uno::Any
& Helper
) override
;
78 typedef ::cppu::WeakImplHelper
<
79 css::script::XAllListener
> DialogAllListenerImpl_BASE
;
82 class DialogAllListenerImpl
: public DialogAllListenerImpl_BASE
85 css::uno::Reference
< css::script::XScriptListener
> m_xScriptListener
;
86 OUString m_sScriptType
;
87 OUString m_sScriptCode
;
89 void firing_impl( const css::script::AllEventObject
& Event
, css::uno::Any
* pRet
);
92 DialogAllListenerImpl( const css::uno::Reference
< css::script::XScriptListener
>& rxListener
,
93 OUString sScriptType
, OUString sScriptCode
);
94 virtual ~DialogAllListenerImpl() override
;
97 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
100 virtual void SAL_CALL
firing( const css::script::AllEventObject
& Event
) override
;
101 virtual css::uno::Any SAL_CALL
approveFiring( const css::script::AllEventObject
& Event
) override
;
107 typedef ::cppu::WeakImplHelper
<
108 css::script::XScriptListener
> DialogScriptListenerImpl_BASE
;
111 class DialogScriptListenerImpl
: public DialogScriptListenerImpl_BASE
114 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
115 virtual void firing_impl( const css::script::ScriptEvent
& aScriptEvent
, css::uno::Any
* pRet
) = 0;
117 explicit DialogScriptListenerImpl( css::uno::Reference
< css::uno::XComponentContext
> xContext
) : m_xContext(std::move( xContext
)) {}
118 virtual ~DialogScriptListenerImpl() override
;
121 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
124 virtual void SAL_CALL
firing( const css::script::ScriptEvent
& aScriptEvent
) override
;
125 virtual css::uno::Any SAL_CALL
approveFiring( const css::script::ScriptEvent
& aScriptEvent
) override
;
129 } // namespace dlgprov
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */