LibreOffice Module extensions (master) 1
genericpropertyhandler.hxx
Go to the documentation of this file.
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#pragma once
21
22#include "pcrcommontypes.hxx"
23#include "pcrcommon.hxx"
24
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/beans/XPropertyState.hpp>
27#include <com/sun/star/lang/XServiceInfo.hpp>
28#include <com/sun/star/beans/XIntrospectionAccess.hpp>
29#include <com/sun/star/inspection/XPropertyHandler.hpp>
30#include <com/sun/star/script/XTypeConverter.hpp>
31#include <com/sun/star/uno/XComponentContext.hpp>
34#include <rtl/ref.hxx>
35
36#include <map>
37
38
39namespace pcr
40{
41
42
43 struct TypeLess
44 {
45 bool operator()( const css::uno::Type& _rLHS, const css::uno::Type& _rRHS ) const
46 {
47 return _rLHS.getTypeName() < _rRHS.getTypeName();
48 }
49 };
50
51 class IPropertyEnumRepresentation;
52
53 //= GenericPropertyHandler
54
55 typedef ::cppu::WeakComponentImplHelper < css::inspection::XPropertyHandler
56 , css::lang::XServiceInfo
59 {
60 mutable ::osl::Mutex m_aMutex;
61
63 css::uno::Reference< css::uno::XComponentContext > m_xContext;
65 css::uno::Reference< css::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess;
67 css::uno::Reference< css::beans::XPropertySet > m_xComponent;
69 css::uno::Reference< css::beans::XPropertyState > m_xPropertyState;
71 css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
76 std::map< css::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess >
78
81
82 public:
84 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
85 );
86
87 virtual ~GenericPropertyHandler() override;
88
89 private:
90 // XPropertyHandler overridables
91 virtual void SAL_CALL inspect( const css::uno::Reference< css::uno::XInterface >& _rxIntrospectee ) override;
92 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& _rPropertyName ) override;
93 virtual void SAL_CALL setPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rValue ) override;
94 virtual css::uno::Any SAL_CALL convertToPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rControlValue ) override;
95 virtual css::uno::Any SAL_CALL convertToControlValue( const OUString& _rPropertyName, const css::uno::Any& _rPropertyValue, const css::uno::Type& _rControlValueType ) override;
96 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& _rPropertyName ) override;
97 virtual void SAL_CALL addPropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
98 virtual void SAL_CALL removePropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
99 virtual css::uno::Sequence< css::beans::Property >
100 SAL_CALL getSupportedProperties() override;
101 virtual css::uno::Sequence< OUString >
102 SAL_CALL getSupersededProperties() override;
103 virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override;
104 virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine( const OUString& _rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory ) override;
105 virtual sal_Bool SAL_CALL isComposable( const OUString& _rPropertyName ) override;
106 virtual css::inspection::InteractiveSelectionResult
107 SAL_CALL onInteractivePropertySelection( const OUString& _rPropertyName, sal_Bool _bPrimary, css::uno::Any& _rData, const css::uno::Reference< css::inspection::XObjectInspectorUI >& _rxInspectorUI ) override;
108 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;
109 virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) override;
110
111 // XComponent
113 virtual void SAL_CALL disposing() override;
114
115 // XServiceInfo
116 virtual OUString SAL_CALL getImplementationName( ) override;
117 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
118 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
119
125
128 ::rtl::Reference< IPropertyEnumRepresentation >
129 impl_getEnumConverter( const css::uno::Type& _rEnumType );
130
132 GenericPropertyHandler& operator=( const GenericPropertyHandler& ) = delete;
133 };
134
135
136} // namespace pcr
137
138
139/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL suspend(sal_Bool _bSuspend) override
virtual void SAL_CALL inspect(const css::uno::Reference< css::uno::XInterface > &_rxIntrospectee) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &_rPropertyName) override
virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString &_rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory) override
PropertyMap m_aProperties
cache of our supported properties
virtual sal_Bool SAL_CALL isComposable(const OUString &_rPropertyName) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL disposing() override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::beans::XPropertySet > m_xComponent
the properties of the object we're handling
virtual css::uno::Any SAL_CALL convertToControlValue(const OUString &_rPropertyName, const css::uno::Any &_rPropertyValue, const css::uno::Type &_rControlValueType) override
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
virtual css::uno::Sequence< OUString > SAL_CALL getSupersededProperties() override
css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter
type converter, needed on various occasions
virtual css::uno::Sequence< css::beans::Property > SAL_CALL getSupportedProperties() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection(const OUString &_rPropertyName, sal_Bool _bPrimary, css::uno::Any &_rData, const css::uno::Reference< css::inspection::XObjectInspectorUI > &_rxInspectorUI) override
virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override
virtual void SAL_CALL addPropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
css::uno::Reference< css::beans::XPropertyState > m_xPropertyState
cached interface of ->m_xComponent
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &_rPropertyName) override
virtual void SAL_CALL removePropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
the service factory for creating services
GenericPropertyHandler(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
::rtl::Reference< IPropertyEnumRepresentation > impl_getEnumConverter(const css::uno::Type &_rEnumType)
retrieves the enum converter for the given ENUM type
void impl_ensurePropertyMap()
ensures that ->m_aProperties is initialized @precond our mutex is locked
bool m_bPropertyMapInitialized
has ->m_aProperties been initialized?
::comphelper::OInterfaceContainerHelper2 m_aPropertyListeners
property change listeners
virtual css::uno::Any SAL_CALL convertToPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rControlValue) override
virtual void SAL_CALL setPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rValue) override
css::uno::Reference< css::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess
need this to keep alive as long as m_xComponent lives
std::map< css::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess > m_aEnumConverters
Type
a property handler for any virtual string properties
Definition: browserline.cxx:39
::cppu::WeakComponentImplHelper< css::inspection::XPropertyHandler, css::lang::XServiceInfo > GenericPropertyHandler_Base
std::unordered_map< OUString, css::beans::Property > PropertyMap
#define DECLARE_XCOMPONENT()
Definition: pcrcommon.hxx:100
bool operator()(const css::uno::Type &_rLHS, const css::uno::Type &_rRHS) const
unsigned char sal_Bool