merge the formfield patch from ooo-build
[ooovba.git] / extensions / source / propctrlr / genericpropertyhandler.hxx
blob5052f6cac1d7c63f8461614342dc800b3de4cf54
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: genericpropertyhandler.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
32 #define EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
34 #include "propertyhandler.hxx"
35 #include "pcrcommontypes.hxx"
36 #include "pcrcommon.hxx"
37 #include "pcrcomponentcontext.hxx"
39 /** === begin UNO includes === **/
40 #include <com/sun/star/beans/XPropertyState.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/beans/XIntrospectionAccess.hpp>
43 /** === end UNO includes === **/
44 #include <cppuhelper/compbase2.hxx>
45 #include <cppuhelper/interfacecontainer.hxx>
46 #include <rtl/ref.hxx>
48 #include <map>
50 //........................................................................
51 namespace pcr
53 //........................................................................
55 struct TypeLess : ::std::binary_function< ::com::sun::star::uno::Type, ::com::sun::star::uno::Type, bool >
57 bool operator()( const ::com::sun::star::uno::Type& _rLHS, const ::com::sun::star::uno::Type& _rRHS ) const
59 return _rLHS.getTypeName() < _rRHS.getTypeName();
63 class IPropertyInfoService;
64 class IPropertyEnumRepresentation;
65 //====================================================================
66 //= GenericPropertyHandler
67 //====================================================================
68 typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
69 , ::com::sun::star::lang::XServiceInfo
70 > GenericPropertyHandler_Base;
71 class GenericPropertyHandler : public GenericPropertyHandler_Base
73 private:
74 mutable ::osl::Mutex m_aMutex;
76 private:
77 /// the service factory for creating services
78 ComponentContext m_aContext;
79 /// need this to keep alive as long as m_xComponent lives
80 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess;
81 /// the properties of the object we're handling
82 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
83 /// cached interface of ->m_xComponent
84 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > m_xPropertyState;
85 /// type converter, needed on various occasions
86 ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
87 /// cache of our supported properties
88 PropertyMap m_aProperties;
89 /// property change listeners
90 ::cppu::OInterfaceContainerHelper m_aPropertyListeners;
91 ::std::map< ::com::sun::star::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess >
92 m_aEnumConverters;
94 /// has ->m_aProperties been initialized?
95 bool m_bPropertyMapInitialized : 1;
97 public:
98 // XServiceInfo - static versions
99 static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
100 static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
101 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
103 protected:
104 GenericPropertyHandler(
105 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
108 ~GenericPropertyHandler();
110 protected:
111 // XPropertyHandler overridables
112 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);
113 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
114 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);
115 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);
116 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);
117 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
118 virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
119 virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
120 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
121 SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
122 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
123 SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException);
124 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException);
125 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);
126 virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
127 virtual ::com::sun::star::inspection::InteractiveSelectionResult
128 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);
129 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);
130 virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
132 // XComponent
133 DECLARE_XCOMPONENT()
134 virtual void SAL_CALL disposing();
136 // XServiceInfo
137 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
138 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
139 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
141 private:
142 /** ensures that ->m_aProperties is initialized
143 @precond
144 our mutex is locked
146 void impl_ensurePropertyMap();
148 /** retrieves the enum converter for the given ENUM type
150 ::rtl::Reference< IPropertyEnumRepresentation >
151 impl_getEnumConverter( const ::com::sun::star::uno::Type& _rEnumType );
153 private:
154 GenericPropertyHandler(); // never implemented
155 GenericPropertyHandler( const GenericPropertyHandler& ); // never implemented
156 GenericPropertyHandler& operator=( const GenericPropertyHandler& ); // never implemented
159 //........................................................................
160 } // namespace pcr
161 //........................................................................
163 #endif // EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX