1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include "pcrcommontypes.hxx"
23 #include "pcrcommon.hxx"
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>
32 #include <comphelper/interfacecontainer2.hxx>
33 #include <cppuhelper/compbase.hxx>
34 #include <rtl/ref.hxx>
45 bool operator()( const css::uno::Type
& _rLHS
, const css::uno::Type
& _rRHS
) const
47 return _rLHS
.getTypeName() < _rRHS
.getTypeName();
51 class IPropertyEnumRepresentation
;
53 //= GenericPropertyHandler
55 typedef ::cppu::WeakComponentImplHelper
< css::inspection::XPropertyHandler
56 , css::lang::XServiceInfo
57 > GenericPropertyHandler_Base
;
58 class GenericPropertyHandler final
: public GenericPropertyHandler_Base
60 mutable ::osl::Mutex m_aMutex
;
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
>
79 /// has ->m_aProperties been initialized?
80 bool m_bPropertyMapInitialized
: 1;
83 explicit GenericPropertyHandler(
84 const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
87 virtual ~GenericPropertyHandler() override
;
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
;
113 virtual void SAL_CALL
disposing() override
;
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
;
120 /** ensures that ->m_aProperties is initialized
124 void impl_ensurePropertyMap();
126 /** retrieves the enum converter for the given ENUM type
128 ::rtl::Reference
< IPropertyEnumRepresentation
>
129 impl_getEnumConverter( const css::uno::Type
& _rEnumType
);
131 GenericPropertyHandler( const GenericPropertyHandler
& ) = delete;
132 GenericPropertyHandler
& operator=( const GenericPropertyHandler
& ) = delete;
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */