1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX 25*b1cdbd2cSJim Jagielski #define EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include "pcrcomponentcontext.hxx" 28*b1cdbd2cSJim Jagielski #include "pcrcommontypes.hxx" 29*b1cdbd2cSJim Jagielski #include "pcrcommon.hxx" 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski /** === begin UNO includes === **/ 32*b1cdbd2cSJim Jagielski #include <com/sun/star/script/ScriptEventDescriptor.hpp> 33*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XServiceInfo.hpp> 34*b1cdbd2cSJim Jagielski #include <com/sun/star/inspection/XPropertyHandler.hpp> 35*b1cdbd2cSJim Jagielski #include <com/sun/star/beans/XPropertySet.hpp> 36*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XFrame.hpp> 37*b1cdbd2cSJim Jagielski /** === end UNO includes === **/ 38*b1cdbd2cSJim Jagielski #include <cppuhelper/compbase2.hxx> 39*b1cdbd2cSJim Jagielski #include <comphelper/listenernotification.hxx> 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski //........................................................................ 42*b1cdbd2cSJim Jagielski namespace pcr 43*b1cdbd2cSJim Jagielski { 44*b1cdbd2cSJim Jagielski //........................................................................ 45*b1cdbd2cSJim Jagielski 46*b1cdbd2cSJim Jagielski //==================================================================== 47*b1cdbd2cSJim Jagielski //= EventDescription 48*b1cdbd2cSJim Jagielski //==================================================================== 49*b1cdbd2cSJim Jagielski typedef sal_Int32 EventId; 50*b1cdbd2cSJim Jagielski struct EventDescription 51*b1cdbd2cSJim Jagielski { 52*b1cdbd2cSJim Jagielski public: 53*b1cdbd2cSJim Jagielski ::rtl::OUString sDisplayName; 54*b1cdbd2cSJim Jagielski ::rtl::OUString sListenerClassName; 55*b1cdbd2cSJim Jagielski ::rtl::OUString sListenerMethodName; 56*b1cdbd2cSJim Jagielski ::rtl::OString sHelpId; 57*b1cdbd2cSJim Jagielski ::rtl::OString sUniqueBrowseId; 58*b1cdbd2cSJim Jagielski EventId nId; 59*b1cdbd2cSJim Jagielski EventDescriptionpcr::EventDescription60*b1cdbd2cSJim Jagielski EventDescription() 61*b1cdbd2cSJim Jagielski :nId( 0 ) 62*b1cdbd2cSJim Jagielski { 63*b1cdbd2cSJim Jagielski } 64*b1cdbd2cSJim Jagielski 65*b1cdbd2cSJim Jagielski EventDescription( 66*b1cdbd2cSJim Jagielski EventId _nId, 67*b1cdbd2cSJim Jagielski const sal_Char* _pListenerNamespaceAscii, 68*b1cdbd2cSJim Jagielski const sal_Char* _pListenerClassAsciiName, 69*b1cdbd2cSJim Jagielski const sal_Char* _pListenerMethodAsciiName, 70*b1cdbd2cSJim Jagielski sal_uInt16 _nDisplayNameResId, 71*b1cdbd2cSJim Jagielski const rtl::OString& _sHelpId, 72*b1cdbd2cSJim Jagielski const rtl::OString& _sUniqueBrowseId ); 73*b1cdbd2cSJim Jagielski }; 74*b1cdbd2cSJim Jagielski 75*b1cdbd2cSJim Jagielski typedef ::std::hash_map< ::rtl::OUString, EventDescription, ::rtl::OUStringHash > EventMap; 76*b1cdbd2cSJim Jagielski 77*b1cdbd2cSJim Jagielski //==================================================================== 78*b1cdbd2cSJim Jagielski //= EventHandler 79*b1cdbd2cSJim Jagielski //==================================================================== 80*b1cdbd2cSJim Jagielski typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler 81*b1cdbd2cSJim Jagielski , ::com::sun::star::lang::XServiceInfo 82*b1cdbd2cSJim Jagielski > EventHandler_Base; 83*b1cdbd2cSJim Jagielski class EventHandler : public EventHandler_Base 84*b1cdbd2cSJim Jagielski { 85*b1cdbd2cSJim Jagielski private: 86*b1cdbd2cSJim Jagielski mutable ::osl::Mutex m_aMutex; 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielski /// the context in which the instance was created 89*b1cdbd2cSJim Jagielski ComponentContext m_aContext; 90*b1cdbd2cSJim Jagielski /// the properties of the object we're handling 91*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent; 92*b1cdbd2cSJim Jagielski /// our XPropertyChangeListener(s) 93*b1cdbd2cSJim Jagielski PropertyChangeListeners m_aPropertyListeners; 94*b1cdbd2cSJim Jagielski /// cache of the events we found at our introspectee 95*b1cdbd2cSJim Jagielski EventMap m_aEvents; 96*b1cdbd2cSJim Jagielski /// has m_aEvents been initialized? 97*b1cdbd2cSJim Jagielski bool m_bEventsMapInitialized; 98*b1cdbd2cSJim Jagielski /// is our introspectee a dialog element? 99*b1cdbd2cSJim Jagielski bool m_bIsDialogElement; 100*b1cdbd2cSJim Jagielski // TODO: move different handling into different derived classes? 101*b1cdbd2cSJim Jagielski /// (FormComponent) type of the grid column being inspected, or -1 if we're not inspecting a grid column 102*b1cdbd2cSJim Jagielski sal_Int16 m_nGridColumnType; 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski public: 105*b1cdbd2cSJim Jagielski // XServiceInfo - static versions 106*b1cdbd2cSJim Jagielski static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException); 107*b1cdbd2cSJim Jagielski static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException); 108*b1cdbd2cSJim Jagielski static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ); 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski protected: 111*b1cdbd2cSJim Jagielski EventHandler( 112*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext 113*b1cdbd2cSJim Jagielski ); 114*b1cdbd2cSJim Jagielski 115*b1cdbd2cSJim Jagielski ~EventHandler(); 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski protected: 118*b1cdbd2cSJim Jagielski // XPropertyHandler overridables 119*b1cdbd2cSJim Jagielski 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); 120*b1cdbd2cSJim Jagielski virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 121*b1cdbd2cSJim Jagielski 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); 122*b1cdbd2cSJim Jagielski 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); 123*b1cdbd2cSJim Jagielski 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); 124*b1cdbd2cSJim Jagielski virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 125*b1cdbd2cSJim Jagielski virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 126*b1cdbd2cSJim Jagielski virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 127*b1cdbd2cSJim Jagielski virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > 128*b1cdbd2cSJim Jagielski SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException); 129*b1cdbd2cSJim Jagielski virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException); 130*b1cdbd2cSJim Jagielski virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException); 131*b1cdbd2cSJim Jagielski 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); 132*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 133*b1cdbd2cSJim Jagielski virtual ::com::sun::star::inspection::InteractiveSelectionResult 134*b1cdbd2cSJim Jagielski 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); 135*b1cdbd2cSJim Jagielski 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); 136*b1cdbd2cSJim Jagielski virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException); 137*b1cdbd2cSJim Jagielski 138*b1cdbd2cSJim Jagielski // XComponent 139*b1cdbd2cSJim Jagielski DECLARE_XCOMPONENT() 140*b1cdbd2cSJim Jagielski virtual void SAL_CALL disposing(); 141*b1cdbd2cSJim Jagielski 142*b1cdbd2cSJim Jagielski // XServiceInfo 143*b1cdbd2cSJim Jagielski virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 144*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 145*b1cdbd2cSJim Jagielski virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 146*b1cdbd2cSJim Jagielski 147*b1cdbd2cSJim Jagielski private: 148*b1cdbd2cSJim Jagielski /** returns the script events associated with our introspectee 149*b1cdbd2cSJim Jagielski @param _out_rEvents 150*b1cdbd2cSJim Jagielski Takes, upon successfull return, the events currently associated with the introspectee 151*b1cdbd2cSJim Jagielski @precond 152*b1cdbd2cSJim Jagielski Our introspectee is a form component 153*b1cdbd2cSJim Jagielski */ 154*b1cdbd2cSJim Jagielski void impl_getFormComponentScriptEvents_nothrow( 155*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents 156*b1cdbd2cSJim Jagielski ) const; 157*b1cdbd2cSJim Jagielski 158*b1cdbd2cSJim Jagielski /** returns the script events associated with our introspectee 159*b1cdbd2cSJim Jagielski @param _out_rEvents 160*b1cdbd2cSJim Jagielski Takes, upon successfull return, the events currently associated with the introspectee 161*b1cdbd2cSJim Jagielski @precond 162*b1cdbd2cSJim Jagielski Our introspectee is a dialog element 163*b1cdbd2cSJim Jagielski */ 164*b1cdbd2cSJim Jagielski void impl_getDialogElementScriptEvents_nothrow( 165*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents 166*b1cdbd2cSJim Jagielski ) const; 167*b1cdbd2cSJim Jagielski 168*b1cdbd2cSJim Jagielski /** returns the script events associated with our introspectee 169*b1cdbd2cSJim Jagielski @param _out_rEvents 170*b1cdbd2cSJim Jagielski Takes, the events currently associated with the introspectee 171*b1cdbd2cSJim Jagielski */ impl_getComponentScriptEvents_nothrow(::com::sun::star::uno::Sequence<::com::sun::star::script::ScriptEventDescriptor> & _out_rEvents) const172*b1cdbd2cSJim Jagielski inline void impl_getComponentScriptEvents_nothrow( 173*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents 174*b1cdbd2cSJim Jagielski ) const 175*b1cdbd2cSJim Jagielski { 176*b1cdbd2cSJim Jagielski if ( m_bIsDialogElement ) 177*b1cdbd2cSJim Jagielski impl_getDialogElementScriptEvents_nothrow( _out_rEvents ); 178*b1cdbd2cSJim Jagielski else 179*b1cdbd2cSJim Jagielski impl_getFormComponentScriptEvents_nothrow( _out_rEvents ); 180*b1cdbd2cSJim Jagielski } 181*b1cdbd2cSJim Jagielski 182*b1cdbd2cSJim Jagielski /** returns the types of the listeners which can be registered at our introspectee 183*b1cdbd2cSJim Jagielski @param _out_rTypes 184*b1cdbd2cSJim Jagielski Takes, upon successfull return, the types of possible listeners at the introspectee 185*b1cdbd2cSJim Jagielski */ 186*b1cdbd2cSJim Jagielski void impl_getCopmonentListenerTypes_nothrow( 187*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _out_rTypes 188*b1cdbd2cSJim Jagielski ) const; 189*b1cdbd2cSJim Jagielski 190*b1cdbd2cSJim Jagielski /** returns a secondary component to be used for event inspection 191*b1cdbd2cSJim Jagielski 192*b1cdbd2cSJim Jagielski In the UI, we want to mix events for the control model with events for the control. 193*b1cdbd2cSJim Jagielski Since our introspectee is a model, this method creates a control for it (if possible). 194*b1cdbd2cSJim Jagielski 195*b1cdbd2cSJim Jagielski @return 196*b1cdbd2cSJim Jagielski the secondary component whose events should be mixed with the introspectee's events 197*b1cdbd2cSJim Jagielski The caller takes the ownership of the component (if not <NULL/>). 198*b1cdbd2cSJim Jagielski 199*b1cdbd2cSJim Jagielski @throws 200*b1cdbd2cSJim Jagielski if an unexpected error occurs during creation of the secondary component. 201*b1cdbd2cSJim Jagielski A <NULL/> component to be returned is not unexpected, but allowed 202*b1cdbd2cSJim Jagielski 203*b1cdbd2cSJim Jagielski @precond 204*b1cdbd2cSJim Jagielski ->m_xComponent is not <NULL/> 205*b1cdbd2cSJim Jagielski */ 206*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 207*b1cdbd2cSJim Jagielski impl_getSecondaryComponentForEventInspection_throw( ) const; 208*b1cdbd2cSJim Jagielski 209*b1cdbd2cSJim Jagielski /** returns the event description for the given (programmatic) property name 210*b1cdbd2cSJim Jagielski @param _rPropertyName 211*b1cdbd2cSJim Jagielski the name whose event description should be looked up 212*b1cdbd2cSJim Jagielski @return 213*b1cdbd2cSJim Jagielski the event description for the property name 214*b1cdbd2cSJim Jagielski @throws ::com::sun::star::beans::UnknownPropertyException 215*b1cdbd2cSJim Jagielski if our introspectee does not have an event with the given logical name (see ->getSupportedProperties) 216*b1cdbd2cSJim Jagielski */ 217*b1cdbd2cSJim Jagielski const EventDescription& 218*b1cdbd2cSJim Jagielski impl_getEventForName_throw( const ::rtl::OUString& _rPropertyName ) const; 219*b1cdbd2cSJim Jagielski 220*b1cdbd2cSJim Jagielski /** returns the index of our component within its parent, if this parent can be 221*b1cdbd2cSJim Jagielski obtained (XChild::getParent) and supports an ->XIndexAccess interface 222*b1cdbd2cSJim Jagielski */ 223*b1cdbd2cSJim Jagielski sal_Int32 impl_getComponentIndexInParent_throw() const; 224*b1cdbd2cSJim Jagielski 225*b1cdbd2cSJim Jagielski /** sets a given script event as event handler at a form component 226*b1cdbd2cSJim Jagielski 227*b1cdbd2cSJim Jagielski @param _rScriptEvent 228*b1cdbd2cSJim Jagielski the script event to set 229*b1cdbd2cSJim Jagielski */ 230*b1cdbd2cSJim Jagielski void impl_setFormComponentScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent ); 231*b1cdbd2cSJim Jagielski 232*b1cdbd2cSJim Jagielski /** sets a given script event as event handler at a dialog component 233*b1cdbd2cSJim Jagielski 234*b1cdbd2cSJim Jagielski @param _rScriptEvent 235*b1cdbd2cSJim Jagielski the script event to set 236*b1cdbd2cSJim Jagielski */ 237*b1cdbd2cSJim Jagielski void impl_setDialogElementScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent ); 238*b1cdbd2cSJim Jagielski 239*b1cdbd2cSJim Jagielski /** returns the frame associated with our context document 240*b1cdbd2cSJim Jagielski */ 241*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > 242*b1cdbd2cSJim Jagielski impl_getContextFrame_nothrow() const; 243*b1cdbd2cSJim Jagielski 244*b1cdbd2cSJim Jagielski /** approves or denies a certain method to be included in the UI 245*b1cdbd2cSJim Jagielski @return 246*b1cdbd2cSJim Jagielski <TRUE/> if and only if the given method is allowed. 247*b1cdbd2cSJim Jagielski */ 248*b1cdbd2cSJim Jagielski bool impl_filterMethod_nothrow( const EventDescription& _rEvent ) const; 249*b1cdbd2cSJim Jagielski 250*b1cdbd2cSJim Jagielski private: 251*b1cdbd2cSJim Jagielski EventHandler(); // never implemented 252*b1cdbd2cSJim Jagielski EventHandler( const EventHandler& ); // never implemented 253*b1cdbd2cSJim Jagielski EventHandler& operator=( const EventHandler& ); // never implemented 254*b1cdbd2cSJim Jagielski }; 255*b1cdbd2cSJim Jagielski 256*b1cdbd2cSJim Jagielski //........................................................................ 257*b1cdbd2cSJim Jagielski } // namespace pcr 258*b1cdbd2cSJim Jagielski //........................................................................ 259*b1cdbd2cSJim Jagielski 260*b1cdbd2cSJim Jagielski #endif // EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX 261*b1cdbd2cSJim Jagielski 262