Update ooo320-m1
[ooovba.git] / extensions / source / propctrlr / propertycomposer.hxx
blob189c402dd9fc2555da846d23efc1fae8191df9f5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propertycomposer.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
32 #define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
34 #include "pcrcommon.hxx"
35 #include "formbrowsertools.hxx"
36 #include "composeduiupdate.hxx"
37 #include "formbrowsertools.hxx"
39 /** === begin UNO includes === **/
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/inspection/XPropertyHandler.hpp>
42 #include <com/sun/star/lang/DisposedException.hpp>
43 /** === end UNO includes === **/
44 #include <cppuhelper/compbase2.hxx>
45 #include <comphelper/broadcasthelper.hxx>
46 #include <comphelper/listenernotification.hxx>
48 #include <vector>
49 #include <set>
51 //........................................................................
52 namespace pcr
54 //........................................................................
56 //====================================================================
57 //= PropertyComposer
58 //====================================================================
59 typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
60 , ::com::sun::star::beans::XPropertyChangeListener
61 > PropertyComposer_Base;
62 /** implements an <type>XPropertyHandler</type> which composes it's information
63 from a set of other property handlers
65 class PropertyComposer :public PropertyComposer_Base
66 ,public ::comphelper::OBaseMutex
67 ,public IPropertyExistenceCheck
69 public:
70 typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >
71 HandlerArray;
73 private:
74 HandlerArray m_aSlaveHandlers;
75 ::std::auto_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer;
76 PropertyChangeListeners m_aPropertyListeners;
77 bool m_bSupportedPropertiesAreKnown;
78 PropertyBag m_aSupportedProperties;
80 public:
81 /** constructs an <type>XPropertyHandler</type> which composes it's information from a set
82 of other property handlers
84 @param _rSlaveHandlers
85 the set of slave handlers to invoke. Must not be <NULL/>
87 PropertyComposer( const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >& _rSlaveHandlers );
89 public:
90 // XPropertyHandler overridables
91 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);
92 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
93 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
94 virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
95 virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::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);
96 virtual ::com::sun::star::beans::PropertyState
97 SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
98 virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
99 virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
100 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
101 SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
102 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
103 SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
104 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
105 SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
106 virtual ::com::sun::star::inspection::LineDescriptor
107 SAL_CALL describePropertyLine( const ::rtl::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);
108 virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
109 virtual ::com::sun::star::inspection::InteractiveSelectionResult
110 SAL_CALL onInteractivePropertySelection( const ::rtl::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);
111 virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::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);
112 virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
114 // XComponent
115 DECLARE_XCOMPONENT()
116 virtual void SAL_CALL disposing();
118 // XPropertyChangeListener
119 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
121 // XEventListener
122 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
124 // IPropertyExistenceCheck
125 virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException);
127 private:
128 /** ensures that m_pUIRequestComposer exists
130 void impl_ensureUIRequestComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI );
132 /** checks whether a given property exists in <member>m_aSupportedProperties</member>
134 bool impl_isSupportedProperty_nothrow( const ::rtl::OUString& _rPropertyName )
136 ::com::sun::star::beans::Property aDummy; aDummy.Name = _rPropertyName;
137 return m_aSupportedProperties.find( aDummy ) != m_aSupportedProperties.end();
140 private:
141 class MethodGuard;
142 friend class MethodGuard;
143 class MethodGuard : public ::osl::MutexGuard
145 public:
146 MethodGuard( PropertyComposer& _rInstance )
147 : ::osl::MutexGuard( _rInstance.m_aMutex )
149 if ( _rInstance.m_aSlaveHandlers.empty() )
150 throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *(&_rInstance) );
155 //........................................................................
156 } // namespace pcr
157 //........................................................................
159 #endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX