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 SCRIPTING_DLGEVTATT_HXX
21 #define SCRIPTING_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 <boost/unordered_map.hpp>
37 //.........................................................................
40 //.........................................................................
42 // =============================================================================
43 // class DialogEventsAttacherImpl
44 // =============================================================================
45 typedef boost::unordered_map
< OUString
,
46 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>,
48 ::std::equal_to
< OUString
> > ListenerHash
;
50 typedef ::cppu::WeakImplHelper1
<
51 ::com::sun::star::script::XScriptEventsAttacher
> DialogEventsAttacherImpl_BASE
;
54 class DialogEventsAttacherImpl
: public DialogEventsAttacherImpl_BASE
57 bool mbUseFakeVBAEvents
;
58 ListenerHash listernersForTypes
;
59 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
60 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XEventAttacher
> m_xEventAttacher
;
61 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
> getScriptListenerForKey( const OUString
& sScriptName
) throw ( ::com::sun::star::uno::RuntimeException
);
62 ::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
);
63 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
);
64 void SAL_CALL
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
);
66 DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
,
67 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModel
,
68 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& xControl
,
69 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xHandler
,
70 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XIntrospectionAccess
>& xIntrospect
,
72 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>& xRTLListener
,const OUString
& sDialogLibName
);
73 virtual ~DialogEventsAttacherImpl();
75 // XScriptEventsAttacher
76 virtual void SAL_CALL
attachEvents( const ::com::sun::star::uno::Sequence
<
77 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& Objects
,
78 const com::sun::star::uno::Reference
<com::sun::star::script::XScriptListener
>&,
79 const ::com::sun::star::uno::Any
& Helper
)
80 throw (::com::sun::star::lang::IllegalArgumentException
,
81 ::com::sun::star::beans::IntrospectionException
,
82 ::com::sun::star::script::CannotCreateAdapterException
,
83 ::com::sun::star::lang::ServiceNotRegisteredException
,
84 ::com::sun::star::uno::RuntimeException
);
88 // =============================================================================
89 // class DialogAllListenerImpl
90 // =============================================================================
92 typedef ::cppu::WeakImplHelper1
<
93 ::com::sun::star::script::XAllListener
> DialogAllListenerImpl_BASE
;
96 class DialogAllListenerImpl
: public DialogAllListenerImpl_BASE
99 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
> m_xScriptListener
;
100 OUString m_sScriptType
;
101 OUString m_sScriptCode
;
103 virtual void firing_impl( const ::com::sun::star::script::AllEventObject
& Event
, ::com::sun::star::uno::Any
* pRet
);
106 DialogAllListenerImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>& rxListener
,
107 const OUString
& rScriptType
, const OUString
& rScriptCode
);
108 virtual ~DialogAllListenerImpl();
111 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
112 throw (::com::sun::star::uno::RuntimeException
);
115 virtual void SAL_CALL
firing( const ::com::sun::star::script::AllEventObject
& Event
)
116 throw (::com::sun::star::uno::RuntimeException
);
117 virtual ::com::sun::star::uno::Any SAL_CALL
approveFiring( const ::com::sun::star::script::AllEventObject
& Event
)
118 throw (::com::sun::star::reflection::InvocationTargetException
, ::com::sun::star::uno::RuntimeException
);
122 // =============================================================================
123 // class DialogScriptListenerImpl
124 // =============================================================================
126 typedef ::cppu::WeakImplHelper1
<
127 ::com::sun::star::script::XScriptListener
> DialogScriptListenerImpl_BASE
;
130 class DialogScriptListenerImpl
: public DialogScriptListenerImpl_BASE
133 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
134 virtual void firing_impl( const ::com::sun::star::script::ScriptEvent
& aScriptEvent
, ::com::sun::star::uno::Any
* pRet
) = 0;
136 DialogScriptListenerImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
) : m_xContext( rxContext
) {}
137 virtual ~DialogScriptListenerImpl();
140 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
141 throw (::com::sun::star::uno::RuntimeException
);
144 virtual void SAL_CALL
firing( const ::com::sun::star::script::ScriptEvent
& aScriptEvent
)
145 throw (::com::sun::star::uno::RuntimeException
);
146 virtual ::com::sun::star::uno::Any SAL_CALL
approveFiring( const ::com::sun::star::script::ScriptEvent
& aScriptEvent
)
147 throw (::com::sun::star::reflection::InvocationTargetException
, ::com::sun::star::uno::RuntimeException
);
151 //.........................................................................
152 } // namespace dlgprov
153 //.........................................................................
155 #endif // SCRIPTING_DLGEVT_HXX
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */