Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / extensions / source / propctrlr / genericpropertyhandler.hxx
blob1ba3b328957d055db19a7cf3b7e029dc09f1ac5f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
23 #include "propertyhandler.hxx"
24 #include "pcrcommontypes.hxx"
25 #include "pcrcommon.hxx"
27 #include <com/sun/star/beans/XPropertyState.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/beans/XIntrospectionAccess.hpp>
30 #include <cppuhelper/compbase.hxx>
31 #include <cppuhelper/interfacecontainer.hxx>
32 #include <rtl/ref.hxx>
34 #include <map>
37 namespace pcr
41 struct TypeLess : std::binary_function< css::uno::Type, css::uno::Type, bool >
43 bool operator()( const css::uno::Type& _rLHS, const css::uno::Type& _rRHS ) const
45 return _rLHS.getTypeName() < _rRHS.getTypeName();
49 class IPropertyEnumRepresentation;
51 //= GenericPropertyHandler
53 typedef ::cppu::WeakComponentImplHelper < css::inspection::XPropertyHandler
54 , css::lang::XServiceInfo
55 > GenericPropertyHandler_Base;
56 class GenericPropertyHandler : public GenericPropertyHandler_Base
58 private:
59 mutable ::osl::Mutex m_aMutex;
61 private:
62 /// the service factory for creating services
63 css::uno::Reference< css::uno::XComponentContext > m_xContext;
64 /// need this to keep alive as long as m_xComponent lives
65 css::uno::Reference< css::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess;
66 /// the properties of the object we're handling
67 css::uno::Reference< css::beans::XPropertySet > m_xComponent;
68 /// cached interface of ->m_xComponent
69 css::uno::Reference< css::beans::XPropertyState > m_xPropertyState;
70 /// type converter, needed on various occasions
71 css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
72 /// cache of our supported properties
73 PropertyMap m_aProperties;
74 /// property change listeners
75 ::comphelper::OInterfaceContainerHelper2 m_aPropertyListeners;
76 std::map< css::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess >
77 m_aEnumConverters;
79 /// has ->m_aProperties been initialized?
80 bool m_bPropertyMapInitialized : 1;
82 public:
83 // XServiceInfo - static versions
84 /// @throws css::uno::RuntimeException
85 static OUString SAL_CALL getImplementationName_static( );
86 /// @throws css::uno::RuntimeException
87 static css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_static( );
88 static css::uno::Reference< css::uno::XInterface > Create( const css::uno::Reference< css::uno::XComponentContext >& _rxContext );
90 protected:
91 explicit GenericPropertyHandler(
92 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
95 virtual ~GenericPropertyHandler() override;
97 protected:
98 // XPropertyHandler overridables
99 virtual void SAL_CALL inspect( const css::uno::Reference< css::uno::XInterface >& _rxIntrospectee ) override;
100 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& _rPropertyName ) override;
101 virtual void SAL_CALL setPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rValue ) override;
102 virtual css::uno::Any SAL_CALL convertToPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rControlValue ) override;
103 virtual css::uno::Any SAL_CALL convertToControlValue( const OUString& _rPropertyName, const css::uno::Any& _rPropertyValue, const css::uno::Type& _rControlValueType ) override;
104 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& _rPropertyName ) override;
105 virtual void SAL_CALL addPropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
106 virtual void SAL_CALL removePropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
107 virtual css::uno::Sequence< css::beans::Property >
108 SAL_CALL getSupportedProperties() override;
109 virtual css::uno::Sequence< OUString >
110 SAL_CALL getSupersededProperties() override;
111 virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override;
112 virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine( const OUString& _rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory ) override;
113 virtual sal_Bool SAL_CALL isComposable( const OUString& _rPropertyName ) override;
114 virtual css::inspection::InteractiveSelectionResult
115 SAL_CALL onInteractivePropertySelection( const OUString& _rPropertyName, sal_Bool _bPrimary, css::uno::Any& _rData, const css::uno::Reference< css::inspection::XObjectInspectorUI >& _rxInspectorUI ) override;
116 virtual void SAL_CALL actuatingPropertyChanged( const OUString& _rActuatingPropertyName, const css::uno::Any& _rNewValue, const css::uno::Any& _rOldValue, const css::uno::Reference< css::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) override;
117 virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) override;
119 // XComponent
120 DECLARE_XCOMPONENT()
121 virtual void SAL_CALL disposing() override;
123 // XServiceInfo
124 virtual OUString SAL_CALL getImplementationName( ) override;
125 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
126 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
128 private:
129 /** ensures that ->m_aProperties is initialized
130 @precond
131 our mutex is locked
133 void impl_ensurePropertyMap();
135 /** retrieves the enum converter for the given ENUM type
137 ::rtl::Reference< IPropertyEnumRepresentation >
138 impl_getEnumConverter( const css::uno::Type& _rEnumType );
140 private:
141 GenericPropertyHandler( const GenericPropertyHandler& ) = delete;
142 GenericPropertyHandler& operator=( const GenericPropertyHandler& ) = delete;
146 } // namespace pcr
149 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */