1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgevtatt.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SCRIPTING_DLGEVTATT_HXX
32 #define SCRIPTING_DLGEVTATT_HXX
34 #include <com/sun/star/frame/XModel.hpp>
35 #include <com/sun/star/script/XAllListener.hpp>
36 #include <com/sun/star/script/XEventAttacher.hpp>
37 #include <com/sun/star/script/XScriptEventsAttacher.hpp>
38 #include <com/sun/star/script/XScriptListener.hpp>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <com/sun/star/awt/XControl.hpp>
41 #ifndef _COM_SUN_STAR_BEANS_XINTROSPECTION_HPP_
42 #include <com/sun/star/beans/XIntrospectionAccess.hpp>
44 #include <cppuhelper/implbase1.hxx>
46 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
50 #define FAKE_VBA_EVENT_SUPPORT 1
52 //.........................................................................
55 //.........................................................................
57 // =============================================================================
58 // class DialogEventsAttacherImpl
59 // =============================================================================
60 typedef std::hash_map
< rtl::OUString
,
61 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>,
63 ::std::equal_to
< ::rtl::OUString
> > ListenerHash
;
65 typedef ::cppu::WeakImplHelper1
<
66 ::com::sun::star::script::XScriptEventsAttacher
> DialogEventsAttacherImpl_BASE
;
69 class DialogEventsAttacherImpl
: public DialogEventsAttacherImpl_BASE
72 ListenerHash listernersForTypes
;
73 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
74 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XEventAttacher
> m_xEventAttacher
;
75 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
> getScriptListenerForKey( const rtl::OUString
& sScriptName
) throw ( ::com::sun::star::uno::RuntimeException
);
76 #ifdef FAKE_VBA_EVENT_SUPPORT
77 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptEventsSupplier
> getFakeVbaEventsSupplier( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& xControl
, rtl::OUString
& sCodeName
);
79 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
);
81 DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
,
82 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModel
,
83 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& xControl
,
84 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xHandler
,
85 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XIntrospectionAccess
>& xIntrospect
,
87 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>& xRTLListener
,const rtl::OUString
& sDialogLibName
);
88 virtual ~DialogEventsAttacherImpl();
90 // XScriptEventsAttacher
91 virtual void SAL_CALL
attachEvents( const ::com::sun::star::uno::Sequence
<
92 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& Objects
,
93 const com::sun::star::uno::Reference
<com::sun::star::script::XScriptListener
>&,
94 const ::com::sun::star::uno::Any
& Helper
)
95 throw (::com::sun::star::lang::IllegalArgumentException
,
96 ::com::sun::star::beans::IntrospectionException
,
97 ::com::sun::star::script::CannotCreateAdapterException
,
98 ::com::sun::star::lang::ServiceNotRegisteredException
,
99 ::com::sun::star::uno::RuntimeException
);
103 // =============================================================================
104 // class DialogAllListenerImpl
105 // =============================================================================
107 typedef ::cppu::WeakImplHelper1
<
108 ::com::sun::star::script::XAllListener
> DialogAllListenerImpl_BASE
;
111 class DialogAllListenerImpl
: public DialogAllListenerImpl_BASE
114 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
> m_xScriptListener
;
115 ::rtl::OUString m_sScriptType
;
116 ::rtl::OUString m_sScriptCode
;
118 virtual void firing_impl( const ::com::sun::star::script::AllEventObject
& Event
, ::com::sun::star::uno::Any
* pRet
);
121 DialogAllListenerImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XScriptListener
>& rxListener
,
122 const ::rtl::OUString
& rScriptType
, const ::rtl::OUString
& rScriptCode
);
123 virtual ~DialogAllListenerImpl();
126 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
127 throw (::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
firing( const ::com::sun::star::script::AllEventObject
& Event
)
131 throw (::com::sun::star::uno::RuntimeException
);
132 virtual ::com::sun::star::uno::Any SAL_CALL
approveFiring( const ::com::sun::star::script::AllEventObject
& Event
)
133 throw (::com::sun::star::reflection::InvocationTargetException
, ::com::sun::star::uno::RuntimeException
);
137 // =============================================================================
138 // class DialogScriptListenerImpl
139 // =============================================================================
141 typedef ::cppu::WeakImplHelper1
<
142 ::com::sun::star::script::XScriptListener
> DialogScriptListenerImpl_BASE
;
145 class DialogScriptListenerImpl
: public DialogScriptListenerImpl_BASE
148 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
149 virtual void firing_impl( const ::com::sun::star::script::ScriptEvent
& aScriptEvent
, ::com::sun::star::uno::Any
* pRet
) = 0;
151 DialogScriptListenerImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
) : m_xContext( rxContext
) {}
152 virtual ~DialogScriptListenerImpl();
155 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
156 throw (::com::sun::star::uno::RuntimeException
);
159 virtual void SAL_CALL
firing( const ::com::sun::star::script::ScriptEvent
& aScriptEvent
)
160 throw (::com::sun::star::uno::RuntimeException
);
161 virtual ::com::sun::star::uno::Any SAL_CALL
approveFiring( const ::com::sun::star::script::ScriptEvent
& aScriptEvent
)
162 throw (::com::sun::star::reflection::InvocationTargetException
, ::com::sun::star::uno::RuntimeException
);
166 //.........................................................................
167 } // namespace dlgprov
168 //.........................................................................
170 #endif // SCRIPTING_DLGEVT_HXX