1*46dbaceeSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*46dbaceeSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*46dbaceeSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*46dbaceeSAndrew Rist * distributed with this work for additional information 6*46dbaceeSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*46dbaceeSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*46dbaceeSAndrew Rist * "License"); you may not use this file except in compliance 9*46dbaceeSAndrew Rist * with the License. You may obtain a copy of the License at 10*46dbaceeSAndrew Rist * 11*46dbaceeSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*46dbaceeSAndrew Rist * 13*46dbaceeSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*46dbaceeSAndrew Rist * software distributed under the License is distributed on an 15*46dbaceeSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*46dbaceeSAndrew Rist * KIND, either express or implied. See the License for the 17*46dbaceeSAndrew Rist * specific language governing permissions and limitations 18*46dbaceeSAndrew Rist * under the License. 19*46dbaceeSAndrew Rist * 20*46dbaceeSAndrew Rist *************************************************************/ 21*46dbaceeSAndrew Rist 22*46dbaceeSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX 25cdf0e10cSrcweir #define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "pcrcommon.hxx" 28cdf0e10cSrcweir #include "formbrowsertools.hxx" 29cdf0e10cSrcweir #include "composeduiupdate.hxx" 30cdf0e10cSrcweir #include "formbrowsertools.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir /** === begin UNO includes === **/ 33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 34cdf0e10cSrcweir #include <com/sun/star/inspection/XPropertyHandler.hpp> 35cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 36cdf0e10cSrcweir /** === end UNO includes === **/ 37cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 38cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 39cdf0e10cSrcweir #include <comphelper/listenernotification.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <vector> 42cdf0e10cSrcweir #include <set> 43cdf0e10cSrcweir 44cdf0e10cSrcweir //........................................................................ 45cdf0e10cSrcweir namespace pcr 46cdf0e10cSrcweir { 47cdf0e10cSrcweir //........................................................................ 48cdf0e10cSrcweir 49cdf0e10cSrcweir //==================================================================== 50cdf0e10cSrcweir //= PropertyComposer 51cdf0e10cSrcweir //==================================================================== 52cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler 53cdf0e10cSrcweir , ::com::sun::star::beans::XPropertyChangeListener 54cdf0e10cSrcweir > PropertyComposer_Base; 55cdf0e10cSrcweir /** implements an <type>XPropertyHandler</type> which composes it's information 56cdf0e10cSrcweir from a set of other property handlers 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir class PropertyComposer :public PropertyComposer_Base 59cdf0e10cSrcweir ,public ::comphelper::OBaseMutex 60cdf0e10cSrcweir ,public IPropertyExistenceCheck 61cdf0e10cSrcweir { 62cdf0e10cSrcweir public: 63cdf0e10cSrcweir typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > > 64cdf0e10cSrcweir HandlerArray; 65cdf0e10cSrcweir 66cdf0e10cSrcweir private: 67cdf0e10cSrcweir HandlerArray m_aSlaveHandlers; 68cdf0e10cSrcweir ::std::auto_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer; 69cdf0e10cSrcweir PropertyChangeListeners m_aPropertyListeners; 70cdf0e10cSrcweir bool m_bSupportedPropertiesAreKnown; 71cdf0e10cSrcweir PropertyBag m_aSupportedProperties; 72cdf0e10cSrcweir 73cdf0e10cSrcweir public: 74cdf0e10cSrcweir /** constructs an <type>XPropertyHandler</type> which composes it's information from a set 75cdf0e10cSrcweir of other property handlers 76cdf0e10cSrcweir 77cdf0e10cSrcweir @param _rSlaveHandlers 78cdf0e10cSrcweir the set of slave handlers to invoke. Must not be <NULL/> 79cdf0e10cSrcweir */ 80cdf0e10cSrcweir PropertyComposer( const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >& _rSlaveHandlers ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir public: 83cdf0e10cSrcweir // XPropertyHandler overridables 84cdf0e10cSrcweir 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); 85cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 86cdf0e10cSrcweir 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); 87cdf0e10cSrcweir 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); 88cdf0e10cSrcweir 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); 89cdf0e10cSrcweir virtual ::com::sun::star::beans::PropertyState 90cdf0e10cSrcweir SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 91cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 92cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException); 93cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > 94cdf0e10cSrcweir SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > 96cdf0e10cSrcweir SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > 98cdf0e10cSrcweir SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir virtual ::com::sun::star::inspection::LineDescriptor 100cdf0e10cSrcweir 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); 101cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 102cdf0e10cSrcweir virtual ::com::sun::star::inspection::InteractiveSelectionResult 103cdf0e10cSrcweir 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); 104cdf0e10cSrcweir 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); 105cdf0e10cSrcweir virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XComponent 108cdf0e10cSrcweir DECLARE_XCOMPONENT() 109cdf0e10cSrcweir virtual void SAL_CALL disposing(); 110cdf0e10cSrcweir 111cdf0e10cSrcweir // XPropertyChangeListener 112cdf0e10cSrcweir virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // XEventListener 115cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 116cdf0e10cSrcweir 117cdf0e10cSrcweir // IPropertyExistenceCheck 118cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException); 119cdf0e10cSrcweir 120cdf0e10cSrcweir private: 121cdf0e10cSrcweir /** ensures that m_pUIRequestComposer exists 122cdf0e10cSrcweir */ 123cdf0e10cSrcweir void impl_ensureUIRequestComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir /** checks whether a given property exists in <member>m_aSupportedProperties</member> 126cdf0e10cSrcweir */ impl_isSupportedProperty_nothrow(const::rtl::OUString & _rPropertyName)127cdf0e10cSrcweir bool impl_isSupportedProperty_nothrow( const ::rtl::OUString& _rPropertyName ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir ::com::sun::star::beans::Property aDummy; aDummy.Name = _rPropertyName; 130cdf0e10cSrcweir return m_aSupportedProperties.find( aDummy ) != m_aSupportedProperties.end(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir private: 134cdf0e10cSrcweir class MethodGuard; 135cdf0e10cSrcweir friend class MethodGuard; 136cdf0e10cSrcweir class MethodGuard : public ::osl::MutexGuard 137cdf0e10cSrcweir { 138cdf0e10cSrcweir public: MethodGuard(PropertyComposer & _rInstance)139cdf0e10cSrcweir MethodGuard( PropertyComposer& _rInstance ) 140cdf0e10cSrcweir : ::osl::MutexGuard( _rInstance.m_aMutex ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir if ( _rInstance.m_aSlaveHandlers.empty() ) 143cdf0e10cSrcweir throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *(&_rInstance) ); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir }; 146cdf0e10cSrcweir }; 147cdf0e10cSrcweir 148cdf0e10cSrcweir //........................................................................ 149cdf0e10cSrcweir } // namespace pcr 150cdf0e10cSrcweir //........................................................................ 151cdf0e10cSrcweir 152cdf0e10cSrcweir #endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX 153cdf0e10cSrcweir 154