Bump for 3.6-28
[LibreOffice.git] / extensions / source / propctrlr / eventhandler.hxx
blob228d3cf44634bc9a3d6ae9845ccd4b97b4ea7726
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
30 #define EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
32 #include "pcrcomponentcontext.hxx"
33 #include "pcrcommontypes.hxx"
34 #include "pcrcommon.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/inspection/XPropertyHandler.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/frame/XFrame.hpp>
42 /** === end UNO includes === **/
43 #include <cppuhelper/compbase2.hxx>
44 #include <comphelper/listenernotification.hxx>
46 //........................................................................
47 namespace pcr
49 //........................................................................
51 //====================================================================
52 //= EventDescription
53 //====================================================================
54 typedef sal_Int32 EventId;
55 struct EventDescription
57 public:
58 ::rtl::OUString sDisplayName;
59 ::rtl::OUString sListenerClassName;
60 ::rtl::OUString sListenerMethodName;
61 ::rtl::OString sHelpId;
62 ::rtl::OString sUniqueBrowseId;
63 EventId nId;
65 EventDescription()
66 :nId( 0 )
70 EventDescription(
71 EventId _nId,
72 const sal_Char* _pListenerNamespaceAscii,
73 const sal_Char* _pListenerClassAsciiName,
74 const sal_Char* _pListenerMethodAsciiName,
75 sal_uInt16 _nDisplayNameResId,
76 const rtl::OString& _sHelpId,
77 const rtl::OString& _sUniqueBrowseId );
80 typedef ::boost::unordered_map< ::rtl::OUString, EventDescription, ::rtl::OUStringHash > EventMap;
82 //====================================================================
83 //= EventHandler
84 //====================================================================
85 typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
86 , ::com::sun::star::lang::XServiceInfo
87 > EventHandler_Base;
88 class EventHandler : public EventHandler_Base
90 private:
91 mutable ::osl::Mutex m_aMutex;
93 /// the context in which the instance was created
94 ComponentContext m_aContext;
95 /// the properties of the object we're handling
96 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
97 /// our XPropertyChangeListener(s)
98 PropertyChangeListeners m_aPropertyListeners;
99 /// cache of the events we found at our introspectee
100 EventMap m_aEvents;
101 /// has m_aEvents been initialized?
102 bool m_bEventsMapInitialized;
103 /// is our introspectee a dialog element?
104 bool m_bIsDialogElement;
105 // TODO: move different handling into different derived classes?
106 /// (FormComponent) type of the grid column being inspected, or -1 if we're not inspecting a grid column
107 sal_Int16 m_nGridColumnType;
109 public:
110 // XServiceInfo - static versions
111 static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
112 static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
113 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
115 protected:
116 EventHandler(
117 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
120 ~EventHandler();
122 protected:
123 // XPropertyHandler overridables
124 virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
125 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
126 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
127 virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
128 virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
129 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
130 virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
131 virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
132 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
133 SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
134 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
135 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
136 virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
137 virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
138 virtual ::com::sun::star::inspection::InteractiveSelectionResult
139 SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
140 virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
141 virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
143 // XComponent
144 DECLARE_XCOMPONENT()
145 virtual void SAL_CALL disposing();
147 // XServiceInfo
148 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
149 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
150 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
152 private:
153 /** returns the script events associated with our introspectee
154 @param _out_rEvents
155 Takes, upon successfull return, the events currently associated with the introspectee
156 @precond
157 Our introspectee is a form component
159 void impl_getFormComponentScriptEvents_nothrow(
160 ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
161 ) const;
163 /** returns the script events associated with our introspectee
164 @param _out_rEvents
165 Takes, upon successfull return, the events currently associated with the introspectee
166 @precond
167 Our introspectee is a dialog element
169 void impl_getDialogElementScriptEvents_nothrow(
170 ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
171 ) const;
173 /** returns the script events associated with our introspectee
174 @param _out_rEvents
175 Takes, the events currently associated with the introspectee
177 inline void impl_getComponentScriptEvents_nothrow(
178 ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
179 ) const
181 if ( m_bIsDialogElement )
182 impl_getDialogElementScriptEvents_nothrow( _out_rEvents );
183 else
184 impl_getFormComponentScriptEvents_nothrow( _out_rEvents );
187 /** returns the types of the listeners which can be registered at our introspectee
188 @param _out_rTypes
189 Takes, upon successfull return, the types of possible listeners at the introspectee
191 void impl_getCopmonentListenerTypes_nothrow(
192 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _out_rTypes
193 ) const;
195 /** returns a secondary component to be used for event inspection
197 In the UI, we want to mix events for the control model with events for the control.
198 Since our introspectee is a model, this method creates a control for it (if possible).
200 @return
201 the secondary component whose events should be mixed with the introspectee's events
202 The caller takes the ownership of the component (if not <NULL/>).
204 @throws
205 if an unexpected error occurs during creation of the secondary component.
206 A <NULL/> component to be returned is not unexpected, but allowed
208 @precond
209 ->m_xComponent is not <NULL/>
211 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
212 impl_getSecondaryComponentForEventInspection_throw( ) const;
214 /** returns the event description for the given (programmatic) property name
215 @param _rPropertyName
216 the name whose event description should be looked up
217 @return
218 the event description for the property name
219 @throws ::com::sun::star::beans::UnknownPropertyException
220 if our introspectee does not have an event with the given logical name (see ->getSupportedProperties)
222 const EventDescription&
223 impl_getEventForName_throw( const ::rtl::OUString& _rPropertyName ) const;
225 /** returns the index of our component within its parent, if this parent can be
226 obtained (XChild::getParent) and supports an ->XIndexAccess interface
228 sal_Int32 impl_getComponentIndexInParent_throw() const;
230 /** sets a given script event as event handler at a form component
232 @param _rScriptEvent
233 the script event to set
235 void impl_setFormComponentScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
237 /** sets a given script event as event handler at a dialog component
239 @param _rScriptEvent
240 the script event to set
242 void impl_setDialogElementScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
244 /** returns the frame associated with our context document
246 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
247 impl_getContextFrame_nothrow() const;
249 /** approves or denies a certain method to be included in the UI
250 @return
251 <TRUE/> if and only if the given method is allowed.
253 bool impl_filterMethod_nothrow( const EventDescription& _rEvent ) const;
255 private:
256 EventHandler(); // never implemented
257 EventHandler( const EventHandler& ); // never implemented
258 EventHandler& operator=( const EventHandler& ); // never implemented
261 //........................................................................
262 } // namespace pcr
263 //........................................................................
265 #endif // EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */