bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / genericpropertyhandler.hxx
blob9f2fceca768d5f1c8c8ff524ebadd3957b401111
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
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 final : public GenericPropertyHandler_Base
58 mutable ::osl::Mutex m_aMutex;
60 /// the service factory for creating services
61 css::uno::Reference< css::uno::XComponentContext > m_xContext;
62 /// need this to keep alive as long as m_xComponent lives
63 css::uno::Reference< css::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess;
64 /// the properties of the object we're handling
65 css::uno::Reference< css::beans::XPropertySet > m_xComponent;
66 /// cached interface of ->m_xComponent
67 css::uno::Reference< css::beans::XPropertyState > m_xPropertyState;
68 /// type converter, needed on various occasions
69 css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
70 /// cache of our supported properties
71 PropertyMap m_aProperties;
72 /// property change listeners
73 ::comphelper::OInterfaceContainerHelper2 m_aPropertyListeners;
74 std::map< css::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess >
75 m_aEnumConverters;
77 /// has ->m_aProperties been initialized?
78 bool m_bPropertyMapInitialized : 1;
80 public:
81 // XServiceInfo - static versions
82 /// @throws css::uno::RuntimeException
83 static OUString getImplementationName_static( );
84 /// @throws css::uno::RuntimeException
85 static css::uno::Sequence< OUString > getSupportedServiceNames_static( );
86 static css::uno::Reference< css::uno::XInterface > Create( const css::uno::Reference< css::uno::XComponentContext >& _rxContext );
88 private:
89 explicit GenericPropertyHandler(
90 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
93 virtual ~GenericPropertyHandler() override;
95 // XPropertyHandler overridables
96 virtual void SAL_CALL inspect( const css::uno::Reference< css::uno::XInterface >& _rxIntrospectee ) override;
97 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& _rPropertyName ) override;
98 virtual void SAL_CALL setPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rValue ) override;
99 virtual css::uno::Any SAL_CALL convertToPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rControlValue ) override;
100 virtual css::uno::Any SAL_CALL convertToControlValue( const OUString& _rPropertyName, const css::uno::Any& _rPropertyValue, const css::uno::Type& _rControlValueType ) override;
101 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& _rPropertyName ) override;
102 virtual void SAL_CALL addPropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
103 virtual void SAL_CALL removePropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
104 virtual css::uno::Sequence< css::beans::Property >
105 SAL_CALL getSupportedProperties() override;
106 virtual css::uno::Sequence< OUString >
107 SAL_CALL getSupersededProperties() override;
108 virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override;
109 virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine( const OUString& _rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory ) override;
110 virtual sal_Bool SAL_CALL isComposable( const OUString& _rPropertyName ) override;
111 virtual css::inspection::InteractiveSelectionResult
112 SAL_CALL onInteractivePropertySelection( const OUString& _rPropertyName, sal_Bool _bPrimary, css::uno::Any& _rData, const css::uno::Reference< css::inspection::XObjectInspectorUI >& _rxInspectorUI ) override;
113 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;
114 virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) override;
116 // XComponent
117 DECLARE_XCOMPONENT()
118 virtual void SAL_CALL disposing() override;
120 // XServiceInfo
121 virtual OUString SAL_CALL getImplementationName( ) override;
122 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
123 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
125 /** ensures that ->m_aProperties is initialized
126 @precond
127 our mutex is locked
129 void impl_ensurePropertyMap();
131 /** retrieves the enum converter for the given ENUM type
133 ::rtl::Reference< IPropertyEnumRepresentation >
134 impl_getEnumConverter( const css::uno::Type& _rEnumType );
136 GenericPropertyHandler( const GenericPropertyHandler& ) = delete;
137 GenericPropertyHandler& operator=( const GenericPropertyHandler& ) = delete;
141 } // namespace pcr
144 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */