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 "pcrcommon.hxx"
23 #include "composeduiupdate.hxx"
24 #include "formbrowsertools.hxx"
26 #include <com/sun/star/inspection/XPropertyHandler.hpp>
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <cppuhelper/compbase.hxx>
29 #include <cppuhelper/basemutex.hxx>
42 typedef ::cppu::WeakComponentImplHelper
< css::inspection::XPropertyHandler
43 , css::beans::XPropertyChangeListener
44 > PropertyComposer_Base
;
45 /** implements an <type>XPropertyHandler</type> which composes its information
46 from a set of other property handlers
48 class PropertyComposer
:public ::cppu::BaseMutex
49 ,public PropertyComposer_Base
50 ,public IPropertyExistenceCheck
53 typedef std::vector
< css::uno::Reference
< css::inspection::XPropertyHandler
> >
57 HandlerArray m_aSlaveHandlers
;
58 std::unique_ptr
< ComposedPropertyUIUpdate
> m_pUIRequestComposer
;
59 PropertyChangeListeners m_aPropertyListeners
;
60 bool m_bSupportedPropertiesAreKnown
;
61 PropertyBag m_aSupportedProperties
;
64 /** constructs an <type>XPropertyHandler</type> which composes its information from a set
65 of other property handlers
67 @param _rSlaveHandlers
68 the set of slave handlers to invoke. Must not be <NULL/>
70 explicit PropertyComposer( std::vector
< css::uno::Reference
< css::inspection::XPropertyHandler
> >&& _rSlaveHandlers
);
73 // XPropertyHandler overridables
74 virtual void SAL_CALL
inspect( const css::uno::Reference
< css::uno::XInterface
>& _rxIntrospectee
) override
;
75 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& _rPropertyName
) override
;
76 virtual void SAL_CALL
setPropertyValue( const OUString
& _rPropertyName
, const css::uno::Any
& _rValue
) override
;
77 virtual css::uno::Any SAL_CALL
convertToPropertyValue( const OUString
& _rPropertyName
, const css::uno::Any
& _rControlValue
) override
;
78 virtual css::uno::Any SAL_CALL
convertToControlValue( const OUString
& _rPropertyName
, const css::uno::Any
& _rPropertyValue
, const css::uno::Type
& _rControlValueType
) override
;
79 virtual css::beans::PropertyState
80 SAL_CALL
getPropertyState( const OUString
& _rPropertyName
) override
;
81 virtual void SAL_CALL
addPropertyChangeListener( const css::uno::Reference
< css::beans::XPropertyChangeListener
>& _rxListener
) override
;
82 virtual void SAL_CALL
removePropertyChangeListener( const css::uno::Reference
< css::beans::XPropertyChangeListener
>& _rxListener
) override
;
83 virtual css::uno::Sequence
< css::beans::Property
>
84 SAL_CALL
getSupportedProperties() override
;
85 virtual css::uno::Sequence
< OUString
>
86 SAL_CALL
getSupersededProperties( ) override
;
87 virtual css::uno::Sequence
< OUString
>
88 SAL_CALL
getActuatingProperties( ) override
;
89 virtual css::inspection::LineDescriptor
90 SAL_CALL
describePropertyLine( const OUString
& _rPropertyName
, const css::uno::Reference
< css::inspection::XPropertyControlFactory
>& _rxControlFactory
) override
;
91 virtual sal_Bool SAL_CALL
isComposable( const OUString
& _rPropertyName
) override
;
92 virtual css::inspection::InteractiveSelectionResult
93 SAL_CALL
onInteractivePropertySelection( const OUString
& _rPropertyName
, sal_Bool _bPrimary
, css::uno::Any
& _rData
, const css::uno::Reference
< css::inspection::XObjectInspectorUI
>& _rxInspectorUI
) override
;
94 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
;
95 virtual sal_Bool SAL_CALL
suspend( sal_Bool _bSuspend
) override
;
99 virtual void SAL_CALL
disposing() override
;
101 // XPropertyChangeListener
102 virtual void SAL_CALL
propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
105 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
107 // IPropertyExistenceCheck
108 virtual bool hasPropertyByName( const OUString
& _rName
) override
;
111 /** ensures that m_pUIRequestComposer exists
113 void impl_ensureUIRequestComposer( const css::uno::Reference
< css::inspection::XObjectInspectorUI
>& _rxInspectorUI
);
115 /** checks whether a given property exists in <member>m_aSupportedProperties</member>
117 bool impl_isSupportedProperty_nothrow( const OUString
& _rPropertyName
)
119 css::beans::Property aDummy
; aDummy
.Name
= _rPropertyName
;
120 return m_aSupportedProperties
.find( aDummy
) != m_aSupportedProperties
.end();
125 friend class MethodGuard
;
126 class MethodGuard
: public ::osl::MutexGuard
129 explicit MethodGuard( PropertyComposer
& _rInstance
)
130 : ::osl::MutexGuard( _rInstance
.m_aMutex
)
132 if ( _rInstance
.m_aSlaveHandlers
.empty() )
133 throw css::lang::DisposedException( OUString(), _rInstance
);
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */