1*46dbaceeSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*46dbaceeSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*46dbaceeSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*46dbaceeSAndrew Rist * distributed with this work for additional information 6*46dbaceeSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*46dbaceeSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*46dbaceeSAndrew Rist * "License"); you may not use this file except in compliance 9*46dbaceeSAndrew Rist * with the License. You may obtain a copy of the License at 10*46dbaceeSAndrew Rist * 11*46dbaceeSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*46dbaceeSAndrew Rist * 13*46dbaceeSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*46dbaceeSAndrew Rist * software distributed under the License is distributed on an 15*46dbaceeSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*46dbaceeSAndrew Rist * KIND, either express or implied. See the License for the 17*46dbaceeSAndrew Rist * specific language governing permissions and limitations 18*46dbaceeSAndrew Rist * under the License. 19*46dbaceeSAndrew Rist * 20*46dbaceeSAndrew Rist *************************************************************/ 21*46dbaceeSAndrew Rist 22*46dbaceeSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX 25cdf0e10cSrcweir #define EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "propertyhandler.hxx" 28cdf0e10cSrcweir #include "pcrcommontypes.hxx" 29cdf0e10cSrcweir #include "pcrcommon.hxx" 30cdf0e10cSrcweir #include "pcrcomponentcontext.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir /** === begin UNO includes === **/ 33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp> 34cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 35cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospectionAccess.hpp> 36cdf0e10cSrcweir /** === end UNO includes === **/ 37cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 38cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 39cdf0e10cSrcweir #include <rtl/ref.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <map> 42cdf0e10cSrcweir 43cdf0e10cSrcweir //........................................................................ 44cdf0e10cSrcweir namespace pcr 45cdf0e10cSrcweir { 46cdf0e10cSrcweir //........................................................................ 47cdf0e10cSrcweir 48cdf0e10cSrcweir struct TypeLess : ::std::binary_function< ::com::sun::star::uno::Type, ::com::sun::star::uno::Type, bool > 49cdf0e10cSrcweir { operator ()pcr::TypeLess50cdf0e10cSrcweir bool operator()( const ::com::sun::star::uno::Type& _rLHS, const ::com::sun::star::uno::Type& _rRHS ) const 51cdf0e10cSrcweir { 52cdf0e10cSrcweir return _rLHS.getTypeName() < _rRHS.getTypeName(); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir }; 55cdf0e10cSrcweir 56cdf0e10cSrcweir class IPropertyInfoService; 57cdf0e10cSrcweir class IPropertyEnumRepresentation; 58cdf0e10cSrcweir //==================================================================== 59cdf0e10cSrcweir //= GenericPropertyHandler 60cdf0e10cSrcweir //==================================================================== 61cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler 62cdf0e10cSrcweir , ::com::sun::star::lang::XServiceInfo 63cdf0e10cSrcweir > GenericPropertyHandler_Base; 64cdf0e10cSrcweir class GenericPropertyHandler : public GenericPropertyHandler_Base 65cdf0e10cSrcweir { 66cdf0e10cSrcweir private: 67cdf0e10cSrcweir mutable ::osl::Mutex m_aMutex; 68cdf0e10cSrcweir 69cdf0e10cSrcweir private: 70cdf0e10cSrcweir /// the service factory for creating services 71cdf0e10cSrcweir ComponentContext m_aContext; 72cdf0e10cSrcweir /// need this to keep alive as long as m_xComponent lives 73cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess; 74cdf0e10cSrcweir /// the properties of the object we're handling 75cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent; 76cdf0e10cSrcweir /// cached interface of ->m_xComponent 77cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > m_xPropertyState; 78cdf0e10cSrcweir /// type converter, needed on various occasions 79cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter; 80cdf0e10cSrcweir /// cache of our supported properties 81cdf0e10cSrcweir PropertyMap m_aProperties; 82cdf0e10cSrcweir /// property change listeners 83cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper m_aPropertyListeners; 84cdf0e10cSrcweir ::std::map< ::com::sun::star::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess > 85cdf0e10cSrcweir m_aEnumConverters; 86cdf0e10cSrcweir 87cdf0e10cSrcweir /// has ->m_aProperties been initialized? 88cdf0e10cSrcweir bool m_bPropertyMapInitialized : 1; 89cdf0e10cSrcweir 90cdf0e10cSrcweir public: 91cdf0e10cSrcweir // XServiceInfo - static versions 92cdf0e10cSrcweir static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException); 93cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException); 94cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ); 95cdf0e10cSrcweir 96cdf0e10cSrcweir protected: 97cdf0e10cSrcweir GenericPropertyHandler( 98cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext 99cdf0e10cSrcweir ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir ~GenericPropertyHandler(); 102cdf0e10cSrcweir 103cdf0e10cSrcweir protected: 104cdf0e10cSrcweir // XPropertyHandler overridables 105cdf0e10cSrcweir 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); 106cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 107cdf0e10cSrcweir 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); 108cdf0e10cSrcweir 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); 109cdf0e10cSrcweir 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); 110cdf0e10cSrcweir virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 112cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 113cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > 114cdf0e10cSrcweir SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException); 115cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > 116cdf0e10cSrcweir SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException); 118cdf0e10cSrcweir 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); 119cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 120cdf0e10cSrcweir virtual ::com::sun::star::inspection::InteractiveSelectionResult 121cdf0e10cSrcweir 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); 122cdf0e10cSrcweir 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); 123cdf0e10cSrcweir virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException); 124cdf0e10cSrcweir 125cdf0e10cSrcweir // XComponent 126cdf0e10cSrcweir DECLARE_XCOMPONENT() 127cdf0e10cSrcweir virtual void SAL_CALL disposing(); 128cdf0e10cSrcweir 129cdf0e10cSrcweir // XServiceInfo 130cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 131cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 132cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 133cdf0e10cSrcweir 134cdf0e10cSrcweir private: 135cdf0e10cSrcweir /** ensures that ->m_aProperties is initialized 136cdf0e10cSrcweir @precond 137cdf0e10cSrcweir our mutex is locked 138cdf0e10cSrcweir */ 139cdf0e10cSrcweir void impl_ensurePropertyMap(); 140cdf0e10cSrcweir 141cdf0e10cSrcweir /** retrieves the enum converter for the given ENUM type 142cdf0e10cSrcweir */ 143cdf0e10cSrcweir ::rtl::Reference< IPropertyEnumRepresentation > 144cdf0e10cSrcweir impl_getEnumConverter( const ::com::sun::star::uno::Type& _rEnumType ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir private: 147cdf0e10cSrcweir GenericPropertyHandler(); // never implemented 148cdf0e10cSrcweir GenericPropertyHandler( const GenericPropertyHandler& ); // never implemented 149cdf0e10cSrcweir GenericPropertyHandler& operator=( const GenericPropertyHandler& ); // never implemented 150cdf0e10cSrcweir }; 151cdf0e10cSrcweir 152cdf0e10cSrcweir //........................................................................ 153cdf0e10cSrcweir } // namespace pcr 154cdf0e10cSrcweir //........................................................................ 155cdf0e10cSrcweir 156cdf0e10cSrcweir #endif // EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX 157cdf0e10cSrcweir 158