Line data Source code
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 : #ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
21 : #define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
22 :
23 : #include "pcrcommon.hxx"
24 : #include "composeduiupdate.hxx"
25 : #include "formbrowsertools.hxx"
26 :
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/compbase2.hxx>
33 : #include <comphelper/broadcasthelper.hxx>
34 : #include <comphelper/listenernotification.hxx>
35 :
36 : #include <vector>
37 : #include <set>
38 :
39 :
40 : namespace pcr
41 : {
42 :
43 :
44 :
45 : //= PropertyComposer
46 :
47 : typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
48 : , ::com::sun::star::beans::XPropertyChangeListener
49 : > PropertyComposer_Base;
50 : /** implements an <type>XPropertyHandler</type> which composes it's information
51 : from a set of other property handlers
52 : */
53 0 : class PropertyComposer :public PropertyComposer_Base
54 : ,public ::comphelper::OBaseMutex
55 : ,public IPropertyExistenceCheck
56 : {
57 : public:
58 : typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >
59 : HandlerArray;
60 :
61 : private:
62 : HandlerArray m_aSlaveHandlers;
63 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
64 : ::std::auto_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer;
65 : SAL_WNODEPRECATED_DECLARATIONS_POP
66 : PropertyChangeListeners m_aPropertyListeners;
67 : bool m_bSupportedPropertiesAreKnown;
68 : PropertyBag m_aSupportedProperties;
69 :
70 : public:
71 : /** constructs an <type>XPropertyHandler</type> which composes it's information from a set
72 : of other property handlers
73 :
74 : @param _rSlaveHandlers
75 : the set of slave handlers to invoke. Must not be <NULL/>
76 : */
77 : PropertyComposer( const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >& _rSlaveHandlers );
78 :
79 : public:
80 : // XPropertyHandler overridables
81 : virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual void SAL_CALL setPropertyValue( const OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::PropertyVetoException, std::exception) SAL_OVERRIDE;
84 : virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 : virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual ::com::sun::star::beans::PropertyState
87 : SAL_CALL getPropertyState( const OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 : virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 : virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
91 : SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 : virtual ::com::sun::star::uno::Sequence< OUString >
93 : SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 : virtual ::com::sun::star::uno::Sequence< OUString >
95 : SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 : virtual ::com::sun::star::inspection::LineDescriptor
97 : SAL_CALL describePropertyLine( const OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 : virtual sal_Bool SAL_CALL isComposable( const OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : virtual ::com::sun::star::inspection::InteractiveSelectionResult
100 : SAL_CALL onInteractivePropertySelection( const OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 : virtual void SAL_CALL actuatingPropertyChanged( const OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 :
104 : // XComponent
105 : DECLARE_XCOMPONENT()
106 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
107 :
108 : // XPropertyChangeListener
109 : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 : // XEventListener
112 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 :
114 : // IPropertyExistenceCheck
115 : virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& _rName ) throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
116 :
117 : private:
118 : /** ensures that m_pUIRequestComposer exists
119 : */
120 : void impl_ensureUIRequestComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI );
121 :
122 : /** checks whether a given property exists in <member>m_aSupportedProperties</member>
123 : */
124 0 : bool impl_isSupportedProperty_nothrow( const OUString& _rPropertyName )
125 : {
126 0 : ::com::sun::star::beans::Property aDummy; aDummy.Name = _rPropertyName;
127 0 : return m_aSupportedProperties.find( aDummy ) != m_aSupportedProperties.end();
128 : }
129 :
130 : private:
131 : class MethodGuard;
132 : friend class MethodGuard;
133 0 : class MethodGuard : public ::osl::MutexGuard
134 : {
135 : public:
136 0 : MethodGuard( PropertyComposer& _rInstance )
137 0 : : ::osl::MutexGuard( _rInstance.m_aMutex )
138 : {
139 0 : if ( _rInstance.m_aSlaveHandlers.empty() )
140 0 : throw ::com::sun::star::lang::DisposedException( OUString(), *(&_rInstance) );
141 0 : }
142 : };
143 : };
144 :
145 :
146 : } // namespace pcr
147 :
148 :
149 : #endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
150 :
151 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|