bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / propertycomposer.hxx
blobfd7818eeb8c5e65259337ebca41c36581bbd1906
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_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>
35 #include <memory>
36 #include <vector>
37 #include <set>
40 namespace pcr
44 //= PropertyComposer
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
56 public:
57 typedef std::vector< css::uno::Reference< css::inspection::XPropertyHandler > >
58 HandlerArray;
60 private:
61 HandlerArray m_aSlaveHandlers;
62 std::unique_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer;
63 PropertyChangeListeners m_aPropertyListeners;
64 bool m_bSupportedPropertiesAreKnown;
65 PropertyBag m_aSupportedProperties;
67 public:
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 );
76 public:
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;
101 // XComponent
102 DECLARE_XCOMPONENT()
103 virtual void SAL_CALL disposing() override;
105 // XPropertyChangeListener
106 virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
108 // XEventListener
109 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
111 // IPropertyExistenceCheck
112 virtual bool hasPropertyByName( const OUString& _rName ) override;
114 private:
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();
127 private:
128 class MethodGuard;
129 friend class MethodGuard;
130 class MethodGuard : public ::osl::MutexGuard
132 public:
133 explicit MethodGuard( PropertyComposer& _rInstance )
134 : ::osl::MutexGuard( _rInstance.m_aMutex )
136 if ( _rInstance.m_aSlaveHandlers.empty() )
137 throw css::lang::DisposedException( OUString(), _rInstance );
143 } // namespace pcr
146 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */