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