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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
23 #include "pcrcommon.hxx"
24 #include "composeduiupdate.hxx"
25 #include "formbrowsertools.hxx"
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/inspection/XPropertyHandler.hpp>
29 #include <com/sun/star/lang/DisposedException.hpp>
30 #include <com/sun/star/beans/UnknownPropertyException.hpp>
31 #include <com/sun/star/beans/PropertyVetoException.hpp>
32 #include <cppuhelper/compbase.hxx>
33 #include <cppuhelper/basemutex.hxx>
46 typedef ::cppu::WeakComponentImplHelper
< css::inspection::XPropertyHandler
47 , css::beans::XPropertyChangeListener
48 > PropertyComposer_Base
;
49 /** implements an <type>XPropertyHandler</type> which composes its information
50 from a set of other property handlers
52 class PropertyComposer
:public ::cppu::BaseMutex
53 ,public PropertyComposer_Base
54 ,public IPropertyExistenceCheck
57 typedef std::vector
< css::uno::Reference
< css::inspection::XPropertyHandler
> >
61 HandlerArray m_aSlaveHandlers
;
62 std::unique_ptr
< ComposedPropertyUIUpdate
> m_pUIRequestComposer
;
63 PropertyChangeListeners m_aPropertyListeners
;
64 bool m_bSupportedPropertiesAreKnown
;
65 PropertyBag m_aSupportedProperties
;
68 /** constructs an <type>XPropertyHandler</type> which composes its information from a set
69 of other property handlers
71 @param _rSlaveHandlers
72 the set of slave handlers to invoke. Must not be <NULL/>
74 explicit PropertyComposer( const std::vector
< css::uno::Reference
< css::inspection::XPropertyHandler
> >& _rSlaveHandlers
);
77 // XPropertyHandler overridables
78 virtual void SAL_CALL
inspect( const css::uno::Reference
< css::uno::XInterface
>& _rxIntrospectee
) override
;
79 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& _rPropertyName
) override
;
80 virtual void SAL_CALL
setPropertyValue( const OUString
& _rPropertyName
, const css::uno::Any
& _rValue
) override
;
81 virtual css::uno::Any SAL_CALL
convertToPropertyValue( const OUString
& _rPropertyName
, const css::uno::Any
& _rControlValue
) override
;
82 virtual css::uno::Any SAL_CALL
convertToControlValue( const OUString
& _rPropertyName
, const css::uno::Any
& _rPropertyValue
, const css::uno::Type
& _rControlValueType
) override
;
83 virtual css::beans::PropertyState
84 SAL_CALL
getPropertyState( const OUString
& _rPropertyName
) override
;
85 virtual void SAL_CALL
addPropertyChangeListener( const css::uno::Reference
< css::beans::XPropertyChangeListener
>& _rxListener
) override
;
86 virtual void SAL_CALL
removePropertyChangeListener( const css::uno::Reference
< css::beans::XPropertyChangeListener
>& _rxListener
) override
;
87 virtual css::uno::Sequence
< css::beans::Property
>
88 SAL_CALL
getSupportedProperties() override
;
89 virtual css::uno::Sequence
< OUString
>
90 SAL_CALL
getSupersededProperties( ) override
;
91 virtual css::uno::Sequence
< OUString
>
92 SAL_CALL
getActuatingProperties( ) override
;
93 virtual css::inspection::LineDescriptor
94 SAL_CALL
describePropertyLine( const OUString
& _rPropertyName
, const css::uno::Reference
< css::inspection::XPropertyControlFactory
>& _rxControlFactory
) override
;
95 virtual sal_Bool SAL_CALL
isComposable( const OUString
& _rPropertyName
) override
;
96 virtual css::inspection::InteractiveSelectionResult
97 SAL_CALL
onInteractivePropertySelection( const OUString
& _rPropertyName
, sal_Bool _bPrimary
, css::uno::Any
& _rData
, const css::uno::Reference
< css::inspection::XObjectInspectorUI
>& _rxInspectorUI
) override
;
98 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
;
99 virtual sal_Bool SAL_CALL
suspend( sal_Bool _bSuspend
) override
;
103 virtual void SAL_CALL
disposing() override
;
105 // XPropertyChangeListener
106 virtual void SAL_CALL
propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
109 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
111 // IPropertyExistenceCheck
112 virtual bool hasPropertyByName( const OUString
& _rName
) override
;
115 /** ensures that m_pUIRequestComposer exists
117 void impl_ensureUIRequestComposer( const css::uno::Reference
< css::inspection::XObjectInspectorUI
>& _rxInspectorUI
);
119 /** checks whether a given property exists in <member>m_aSupportedProperties</member>
121 bool impl_isSupportedProperty_nothrow( const OUString
& _rPropertyName
)
123 css::beans::Property aDummy
; aDummy
.Name
= _rPropertyName
;
124 return m_aSupportedProperties
.find( aDummy
) != m_aSupportedProperties
.end();
129 friend class MethodGuard
;
130 class MethodGuard
: public ::osl::MutexGuard
133 explicit MethodGuard( PropertyComposer
& _rInstance
)
134 : ::osl::MutexGuard( _rInstance
.m_aMutex
)
136 if ( _rInstance
.m_aSlaveHandlers
.empty() )
137 throw css::lang::DisposedException( OUString(), _rInstance
);
146 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */