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