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_PROPERTYHANDLER_HXX 25cdf0e10cSrcweir #define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "pcrcomponentcontext.hxx" 28cdf0e10cSrcweir #include "pcrcommon.hxx" 29cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_MODULEPCR_HXX_ 30cdf0e10cSrcweir #include "modulepcr.hxx" 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** === begin UNO includes === **/ 34cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 35cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp> 36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 37cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp> 38cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp> 39cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 40cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 41cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 42cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp> 43cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp> 44cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 45cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 46cdf0e10cSrcweir #include <com/sun/star/inspection/XPropertyHandler.hpp> 47cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 48cdf0e10cSrcweir /** === end UNO includes === **/ 49cdf0e10cSrcweir #include <osl/interlck.h> 50cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 51cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 52cdf0e10cSrcweir #include <comphelper/uno3.hxx> 53cdf0e10cSrcweir 54cdf0e10cSrcweir #include <memory> 55cdf0e10cSrcweir #include <vector> 56cdf0e10cSrcweir 57cdf0e10cSrcweir namespace com { namespace sun { namespace star { 58cdf0e10cSrcweir namespace inspection { 59cdf0e10cSrcweir struct LineDescriptor; 60cdf0e10cSrcweir class XPropertyControlFactory; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir } } } 63cdf0e10cSrcweir 64cdf0e10cSrcweir class Window; 65cdf0e10cSrcweir //........................................................................ 66cdf0e10cSrcweir namespace pcr 67cdf0e10cSrcweir { 68cdf0e10cSrcweir //........................................................................ 69cdf0e10cSrcweir 70cdf0e10cSrcweir typedef sal_Int32 PropertyId; 71cdf0e10cSrcweir 72cdf0e10cSrcweir //==================================================================== 73cdf0e10cSrcweir //= PropertyHandler 74cdf0e10cSrcweir //==================================================================== 75cdf0e10cSrcweir class OPropertyInfoService; 76cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::inspection::XPropertyHandler 77cdf0e10cSrcweir > PropertyHandler_Base; 78cdf0e10cSrcweir /** the base class for property handlers 79cdf0e10cSrcweir */ 80cdf0e10cSrcweir class PropertyHandler : public PropertyHandler_Base 81cdf0e10cSrcweir { 82cdf0e10cSrcweir private: 83cdf0e10cSrcweir /// cache for getSupportedProperties 84cdf0e10cSrcweir mutable StlSyntaxSequence< ::com::sun::star::beans::Property > 85cdf0e10cSrcweir m_aSupportedProperties; 86cdf0e10cSrcweir mutable bool m_bSupportedPropertiesAreKnown; 87cdf0e10cSrcweir 88cdf0e10cSrcweir /// helper which ensures that we can access resources as long as the instance lives 89cdf0e10cSrcweir PcrClient m_aEnsureResAccess; 90cdf0e10cSrcweir 91cdf0e10cSrcweir private: 92cdf0e10cSrcweir /// the property listener which has been registered 93cdf0e10cSrcweir PropertyChangeListeners m_aPropertyListeners; 94cdf0e10cSrcweir 95cdf0e10cSrcweir protected: 96cdf0e10cSrcweir mutable ::osl::Mutex m_aMutex; 97cdf0e10cSrcweir /// the context in which the instance was created 98cdf0e10cSrcweir ComponentContext m_aContext; 99cdf0e10cSrcweir /// the component we're inspecting 100cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent; 101cdf0e10cSrcweir /// info about our component's properties 102cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xComponentPropertyInfo; 103cdf0e10cSrcweir /// type converter, needed on various occasions 104cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter; 105cdf0e10cSrcweir /// access to property meta data 106cdf0e10cSrcweir ::std::auto_ptr< OPropertyInfoService > m_pInfoService; 107cdf0e10cSrcweir 108cdf0e10cSrcweir protected: 109cdf0e10cSrcweir PropertyHandler( 110cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext 111cdf0e10cSrcweir ); 112cdf0e10cSrcweir ~PropertyHandler(); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // default implementations for XPropertyHandler 115cdf0e10cSrcweir virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException); 116cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException); 118cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException); 119cdf0e10cSrcweir 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); 120cdf0e10cSrcweir 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); 121cdf0e10cSrcweir virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 122cdf0e10cSrcweir 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); 123cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 124cdf0e10cSrcweir virtual ::com::sun::star::inspection::InteractiveSelectionResult 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); 125cdf0e10cSrcweir 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); 126cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 128cdf0e10cSrcweir virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException); 129cdf0e10cSrcweir 130cdf0e10cSrcweir // XComponent 131cdf0e10cSrcweir DECLARE_XCOMPONENT() 132cdf0e10cSrcweir virtual void SAL_CALL disposing(); 133cdf0e10cSrcweir 134cdf0e10cSrcweir // own overridables 135cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > 136cdf0e10cSrcweir SAL_CALL doDescribeSupportedProperties() const = 0; 137cdf0e10cSrcweir 138cdf0e10cSrcweir /// called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect 139cdf0e10cSrcweir virtual void onNewComponent(); 140cdf0e10cSrcweir 141cdf0e10cSrcweir protected: 142cdf0e10cSrcweir /** fires the change in a property value to our listener (if any) 143cdf0e10cSrcweir @see addPropertyChangeListener 144cdf0e10cSrcweir */ 145cdf0e10cSrcweir void firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId, 146cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Any& _rNewValue ) SAL_THROW(()); 147cdf0e10cSrcweir 148cdf0e10cSrcweir /** retrieves a window which can be used as parent for dialogs 149cdf0e10cSrcweir */ 150cdf0e10cSrcweir Window* impl_getDefaultDialogParent_nothrow() const; 151cdf0e10cSrcweir 152cdf0e10cSrcweir /** retrieves the property id for a given property name 153cdf0e10cSrcweir @throw com::sun::star::beans::UnknownPropertyException 154cdf0e10cSrcweir if the property name is not known to our ->m_pInfoService 155cdf0e10cSrcweir */ 156cdf0e10cSrcweir PropertyId impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const; 157cdf0e10cSrcweir 158cdf0e10cSrcweir //------------------------------------------------------------------------------- 159cdf0e10cSrcweir // helper for implementing doDescribeSupportedProperties 160cdf0e10cSrcweir /** adds a description for the given string property to the given property vector 161cdf0e10cSrcweir Most probably to be called from within getSupportedProperties 162cdf0e10cSrcweir */ 163cdf0e10cSrcweir inline void addStringPropertyDescription( 164cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 165cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 166cdf0e10cSrcweir sal_Int16 _nAttribs = 0 167cdf0e10cSrcweir ) const; 168cdf0e10cSrcweir 169cdf0e10cSrcweir /** adds a description for the given int32 property to the given property vector 170cdf0e10cSrcweir */ 171cdf0e10cSrcweir inline void addInt32PropertyDescription( 172cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 173cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 174cdf0e10cSrcweir sal_Int16 _nAttribs = 0 175cdf0e10cSrcweir ) const; 176cdf0e10cSrcweir 177cdf0e10cSrcweir /** adds a description for the given int16 property to the given property vector 178cdf0e10cSrcweir */ 179cdf0e10cSrcweir inline void addInt16PropertyDescription( 180cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 181cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 182cdf0e10cSrcweir sal_Int16 _nAttribs = 0 183cdf0e10cSrcweir ) const; 184cdf0e10cSrcweir 185cdf0e10cSrcweir /** adds a description for the given double property to the given property vector 186cdf0e10cSrcweir */ 187cdf0e10cSrcweir inline void addDoublePropertyDescription( 188cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 189cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 190cdf0e10cSrcweir sal_Int16 _nAttribs = 0 191cdf0e10cSrcweir ) const; 192cdf0e10cSrcweir 193cdf0e10cSrcweir /** adds a description for the given date property to the given property vector 194cdf0e10cSrcweir */ 195cdf0e10cSrcweir inline void addDatePropertyDescription( 196cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 197cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 198cdf0e10cSrcweir sal_Int16 _nAttribs = 0 199cdf0e10cSrcweir ) const; 200cdf0e10cSrcweir 201cdf0e10cSrcweir /** adds a description for the given time property to the given property vector 202cdf0e10cSrcweir */ 203cdf0e10cSrcweir inline void addTimePropertyDescription( 204cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 205cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 206cdf0e10cSrcweir sal_Int16 _nAttribs = 0 207cdf0e10cSrcweir ) const; 208cdf0e10cSrcweir 209cdf0e10cSrcweir /** adds a description for the given DateTime property to the given property vector 210cdf0e10cSrcweir */ 211cdf0e10cSrcweir inline void addDateTimePropertyDescription( 212cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 213cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 214cdf0e10cSrcweir sal_Int16 _nAttribs = 0 215cdf0e10cSrcweir ) const; 216cdf0e10cSrcweir 217cdf0e10cSrcweir /// adds a Property, given by name only, to a given vector of Properties 218cdf0e10cSrcweir void implAddPropertyDescription( 219cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property >& _rProperties, 220cdf0e10cSrcweir const ::rtl::OUString& _rPropertyName, 221cdf0e10cSrcweir const ::com::sun::star::uno::Type& _rType, 222cdf0e10cSrcweir sal_Int16 _nAttribs = 0 223cdf0e10cSrcweir ) const; 224cdf0e10cSrcweir 225cdf0e10cSrcweir //------------------------------------------------------------------------------- 226cdf0e10cSrcweir // helper for accessing and maintaining meta data about our supported properties 227cdf0e10cSrcweir 228cdf0e10cSrcweir /** retrieves a property given by handle 229cdf0e10cSrcweir 230cdf0e10cSrcweir @return 231cdf0e10cSrcweir a pointer to the descriptor for the given properties, if it is one of our 232cdf0e10cSrcweir supported properties, <NULL/> else. 233cdf0e10cSrcweir 234cdf0e10cSrcweir @see doDescribeSupportedProperties 235cdf0e10cSrcweir @see impl_getPropertyFromId_throw 236cdf0e10cSrcweir */ 237cdf0e10cSrcweir const ::com::sun::star::beans::Property* 238cdf0e10cSrcweir impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const; 239cdf0e10cSrcweir 240cdf0e10cSrcweir /** retrieves a property given by handle 241cdf0e10cSrcweir 242cdf0e10cSrcweir @throws UnknownPropertyException 243cdf0e10cSrcweir if the handler does not support a property with the given handle 244cdf0e10cSrcweir 245cdf0e10cSrcweir @seealso doDescribeSupportedProperties 246cdf0e10cSrcweir @see impl_getPropertyFromId_nothrow 247cdf0e10cSrcweir */ 248cdf0e10cSrcweir const ::com::sun::star::beans::Property& 249cdf0e10cSrcweir impl_getPropertyFromId_throw( PropertyId _nPropId ) const; 250cdf0e10cSrcweir 251cdf0e10cSrcweir /** determines whether a given property id is part of our supported properties 252cdf0e10cSrcweir @see getSupportedProperties 253cdf0e10cSrcweir @see doDescribeSupportedProperties 254cdf0e10cSrcweir */ impl_isSupportedProperty_nothrow(PropertyId _nPropId) const255cdf0e10cSrcweir inline bool impl_isSupportedProperty_nothrow( PropertyId _nPropId ) const 256cdf0e10cSrcweir { 257cdf0e10cSrcweir return impl_getPropertyFromId_nothrow( _nPropId ) != NULL; 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir /** retrieves a property given by name 261cdf0e10cSrcweir 262cdf0e10cSrcweir @throws UnknownPropertyException 263cdf0e10cSrcweir if the handler does not support a property with the given name 264cdf0e10cSrcweir 265cdf0e10cSrcweir @seealso doDescribeSupportedProperties 266cdf0e10cSrcweir */ 267cdf0e10cSrcweir const ::com::sun::star::beans::Property& 268cdf0e10cSrcweir impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const; 269cdf0e10cSrcweir 270cdf0e10cSrcweir /** get the name of a property given by handle 271cdf0e10cSrcweir */ 272cdf0e10cSrcweir inline ::rtl::OUString 273cdf0e10cSrcweir impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const; 274cdf0e10cSrcweir 275cdf0e10cSrcweir /** returns the value of the ContextDocument property in the ComponentContext which was used to create 276cdf0e10cSrcweir this handler. 277cdf0e10cSrcweir */ 278cdf0e10cSrcweir inline ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > impl_getContextDocument_nothrow() const279cdf0e10cSrcweir impl_getContextDocument_nothrow() const 280cdf0e10cSrcweir { 281cdf0e10cSrcweir return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >( 282cdf0e10cSrcweir m_aContext.getContextValueByAsciiName( "ContextDocument" ), ::com::sun::star::uno::UNO_QUERY ); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir /** marks the context document as modified 286cdf0e10cSrcweir 287cdf0e10cSrcweir @see impl_getContextDocument_nothrow 288cdf0e10cSrcweir */ 289cdf0e10cSrcweir void impl_setContextDocumentModified_nothrow() const; 290cdf0e10cSrcweir 291cdf0e10cSrcweir /// determines whether our component has a given property 292cdf0e10cSrcweir bool impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const; 293cdf0e10cSrcweir 294cdf0e10cSrcweir /** determines the default measure unit for the document in which our component lives 295cdf0e10cSrcweir */ 296cdf0e10cSrcweir sal_Int16 impl_getDocumentMeasurementUnit_throw() const; 297cdf0e10cSrcweir 298cdf0e10cSrcweir private: 299cdf0e10cSrcweir PropertyHandler(); // never implemented 300cdf0e10cSrcweir PropertyHandler( const PropertyHandler& ); // never implemented 301cdf0e10cSrcweir PropertyHandler& operator=( const PropertyHandler& ); // never implemented 302cdf0e10cSrcweir }; 303cdf0e10cSrcweir 304cdf0e10cSrcweir //-------------------------------------------------------------------- addStringPropertyDescription(::std::vector<::com::sun::star::beans::Property> & _rProperties,const::rtl::OUString & _rPropertyName,sal_Int16 _nAttribs) const305cdf0e10cSrcweir inline void PropertyHandler::addStringPropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const 306cdf0e10cSrcweir { 307cdf0e10cSrcweir implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), _nAttribs ); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir addInt32PropertyDescription(::std::vector<::com::sun::star::beans::Property> & _rProperties,const::rtl::OUString & _rPropertyName,sal_Int16 _nAttribs) const310cdf0e10cSrcweir inline void PropertyHandler::addInt32PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const 311cdf0e10cSrcweir { 312cdf0e10cSrcweir implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int32* >( NULL ) ), _nAttribs ); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir addInt16PropertyDescription(::std::vector<::com::sun::star::beans::Property> & _rProperties,const::rtl::OUString & _rPropertyName,sal_Int16 _nAttribs) const315cdf0e10cSrcweir inline void PropertyHandler::addInt16PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const 316cdf0e10cSrcweir { 317cdf0e10cSrcweir implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int16* >( NULL ) ), _nAttribs ); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir addDoublePropertyDescription(::std::vector<::com::sun::star::beans::Property> & _rProperties,const::rtl::OUString & _rPropertyName,sal_Int16 _nAttribs) const320cdf0e10cSrcweir inline void PropertyHandler::addDoublePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const 321cdf0e10cSrcweir { 322cdf0e10cSrcweir implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< double* >( NULL ) ), _nAttribs ); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir addDatePropertyDescription(::std::vector<::com::sun::star::beans::Property> & _rProperties,const::rtl::OUString & _rPropertyName,sal_Int16 _nAttribs) const325cdf0e10cSrcweir inline void PropertyHandler::addDatePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const 326cdf0e10cSrcweir { 327cdf0e10cSrcweir implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Date* >( NULL ) ), _nAttribs ); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir addTimePropertyDescription(::std::vector<::com::sun::star::beans::Property> & _rProperties,const::rtl::OUString & _rPropertyName,sal_Int16 _nAttribs) const330cdf0e10cSrcweir inline void PropertyHandler::addTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const 331cdf0e10cSrcweir { 332cdf0e10cSrcweir implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Time* >( NULL ) ), _nAttribs ); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir addDateTimePropertyDescription(::std::vector<::com::sun::star::beans::Property> & _rProperties,const::rtl::OUString & _rPropertyName,sal_Int16 _nAttribs) const335cdf0e10cSrcweir inline void PropertyHandler::addDateTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const 336cdf0e10cSrcweir { 337cdf0e10cSrcweir implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::DateTime* >( NULL ) ), _nAttribs ); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir impl_getPropertyNameFromId_nothrow(PropertyId _nPropId) const340cdf0e10cSrcweir inline ::rtl::OUString PropertyHandler::impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const 341cdf0e10cSrcweir { 342cdf0e10cSrcweir const ::com::sun::star::beans::Property* pProp = impl_getPropertyFromId_nothrow( _nPropId ); 343cdf0e10cSrcweir return pProp ? pProp->Name : ::rtl::OUString(); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir //==================================================================== 347cdf0e10cSrcweir //= PropertyHandlerComponent 348cdf0e10cSrcweir //==================================================================== 349cdf0e10cSrcweir typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo 350cdf0e10cSrcweir > PropertyHandlerComponent_Base; 351cdf0e10cSrcweir /** PropertyHandler implementation which additionally supports XServiceInfo 352cdf0e10cSrcweir */ 353cdf0e10cSrcweir class PropertyHandlerComponent :public PropertyHandler 354cdf0e10cSrcweir ,public PropertyHandlerComponent_Base 355cdf0e10cSrcweir { 356cdf0e10cSrcweir protected: 357cdf0e10cSrcweir PropertyHandlerComponent( 358cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext 359cdf0e10cSrcweir ); 360cdf0e10cSrcweir 361cdf0e10cSrcweir DECLARE_XINTERFACE() 362cdf0e10cSrcweir DECLARE_XTYPEPROVIDER() 363cdf0e10cSrcweir 364cdf0e10cSrcweir // XServiceInfo 365cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) = 0; 366cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 367cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; 368cdf0e10cSrcweir }; 369cdf0e10cSrcweir 370cdf0e10cSrcweir //==================================================================== 371cdf0e10cSrcweir //= HandlerComponentBase 372cdf0e10cSrcweir //==================================================================== 373cdf0e10cSrcweir /** a PropertyHandlerComponent implementation which routes XServiceInfo::getImplementationName and 374cdf0e10cSrcweir XServiceInfo::getSupportedServiceNames to static versions of those methods, which are part of 375cdf0e10cSrcweir the derived class. 376cdf0e10cSrcweir 377cdf0e10cSrcweir Additionally, a method <member>Create</member> is provided which takes a component context, and returns a new 378cdf0e10cSrcweir instance of the derived class. This <member>Create</member> is used to register the implementation 379cdf0e10cSrcweir of the derived class at the <type>PcrModule</type>. 380cdf0e10cSrcweir 381cdf0e10cSrcweir Well, every time we're talking about derived class, we in fact mean the template argument of 382cdf0e10cSrcweir <type>HandlerComponentBase</type>. But usually this equals your derived class: 383cdf0e10cSrcweir <pre> 384cdf0e10cSrcweir class MyHandler; 385cdf0e10cSrcweir typedef HandlerComponentBase< MyHandler > MyHandler_Base; 386cdf0e10cSrcweir class MyHandler : MyHandler_Base 387cdf0e10cSrcweir { 388cdf0e10cSrcweir ... 389cdf0e10cSrcweir public: 390cdf0e10cSrcweir static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException); 391cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException); 392cdf0e10cSrcweir }; 393cdf0e10cSrcweir </pre> 394cdf0e10cSrcweir */ 395cdf0e10cSrcweir template < class HANDLER > 396cdf0e10cSrcweir class HandlerComponentBase : public PropertyHandlerComponent 397cdf0e10cSrcweir { 398cdf0e10cSrcweir protected: HandlerComponentBase(const::com::sun::star::uno::Reference<::com::sun::star::uno::XComponentContext> & _rxContext)399cdf0e10cSrcweir HandlerComponentBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ) 400cdf0e10cSrcweir :PropertyHandlerComponent( _rxContext ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir protected: 405cdf0e10cSrcweir // XServiceInfo 406cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 407cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 408cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ); 409cdf0e10cSrcweir 410cdf0e10cSrcweir public: 411cdf0e10cSrcweir /** registers the implementation of HANDLER at the <type>PcrModule</type> 412cdf0e10cSrcweir */ 413cdf0e10cSrcweir static void registerImplementation(); 414cdf0e10cSrcweir }; 415cdf0e10cSrcweir 416cdf0e10cSrcweir //-------------------------------------------------------------------- 417cdf0e10cSrcweir template < class HANDLER > getImplementationName()418cdf0e10cSrcweir ::rtl::OUString SAL_CALL HandlerComponentBase< HANDLER >::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir return HANDLER::getImplementationName_static(); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir //-------------------------------------------------------------------- 424cdf0e10cSrcweir template < class HANDLER > getSupportedServiceNames()425cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL HandlerComponentBase< HANDLER >::getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir return HANDLER::getSupportedServiceNames_static(); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir //-------------------------------------------------------------------- 431cdf0e10cSrcweir template < class HANDLER > registerImplementation()432cdf0e10cSrcweir void HandlerComponentBase< HANDLER >::registerImplementation() 433cdf0e10cSrcweir { 434cdf0e10cSrcweir PcrModule::getInstance().registerImplementation( 435cdf0e10cSrcweir HANDLER::getImplementationName_static(), 436cdf0e10cSrcweir HANDLER::getSupportedServiceNames_static(), 437cdf0e10cSrcweir HANDLER::Create 438cdf0e10cSrcweir ); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir //-------------------------------------------------------------------- 442cdf0e10cSrcweir template < class HANDLER > Create(const::com::sun::star::uno::Reference<::com::sun::star::uno::XComponentContext> & _rxContext)443cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL HandlerComponentBase< HANDLER >::Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir return *( new HANDLER( _rxContext ) ); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir //........................................................................ 449cdf0e10cSrcweir } // namespace pcr 450cdf0e10cSrcweir //........................................................................ 451cdf0e10cSrcweir 452cdf0e10cSrcweir #endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX 453cdf0e10cSrcweir 454