1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _COMPHELPER_MASTERPROPERTYSETHELPER_HXX_ 25 #define _COMPHELPER_MASTERPROPERTYSETHELPER_HXX_ 26 #include <com/sun/star/beans/XPropertySet.hpp> 27 #include <com/sun/star/beans/XPropertyState.hpp> 28 #include <com/sun/star/beans/XMultiPropertySet.hpp> 29 #include <comphelper/PropertyInfoHash.hxx> 30 #include "comphelper/comphelperdllapi.h" 31 #include <map> 32 namespace vos 33 { 34 class IMutex; 35 } 36 namespace comphelper 37 { 38 class MasterPropertySetInfo; 39 class ChainablePropertySet; 40 struct SlaveData 41 { 42 ChainablePropertySet * mpSlave; 43 ::com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > mxSlave; 44 sal_Bool mbInit; 45 SlaveData ( ChainablePropertySet *pSlave); IsInitcomphelper::SlaveData46 inline sal_Bool IsInit () { return mbInit;} SetInitcomphelper::SlaveData47 inline void SetInit ( sal_Bool bInit) { mbInit = bInit; } 48 }; 49 } 50 typedef std::map < sal_uInt8, comphelper::SlaveData* > SlaveMap; 51 52 /* 53 * A MasterPropertySet implements all of the features of a ChainablePropertySet 54 * (it is not inherited from ChainablePropertySet to prevent MasterPropertySets 55 * being chained to each other), but also allows properties implemented in 56 * other ChainablePropertySets to be included as 'native' properties in a 57 * given MasterPropertySet implementation. These are registered using the 58 * 'registerSlave' method, and require that the implementation of the 59 * ChainablePropertySet and the implementation of the ChainablePropertySetInfo 60 * both declare the implementation of the MasterPropertySet as a friend. 61 */ 62 namespace comphelper 63 { 64 class COMPHELPER_DLLPUBLIC MasterPropertySet : public ::com::sun::star::beans::XPropertySet, 65 public ::com::sun::star::beans::XPropertyState, 66 public ::com::sun::star::beans::XMultiPropertySet 67 { 68 protected: 69 MasterPropertySetInfo *mpInfo; 70 vos::IMutex *mpMutex; 71 sal_uInt8 mnLastId; 72 SlaveMap maSlaveMap; 73 ::com::sun::star::uno::Reference < com::sun::star::beans::XPropertySetInfo > mxInfo; 74 void lockMutex(); 75 void unlockMutex(); 76 77 virtual void _preSetValues () 78 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0; 79 virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue ) 80 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0; 81 virtual void _postSetValues () 82 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0; 83 84 virtual void _preGetValues () 85 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0; 86 virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue ) 87 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException ) = 0; 88 virtual void _postGetValues () 89 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0; 90 91 virtual void _preGetPropertyState () 92 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ); 93 virtual void _getPropertyState( const comphelper::PropertyInfo& rInfo, ::com::sun::star::beans::PropertyState& rState ) 94 throw(::com::sun::star::beans::UnknownPropertyException ); 95 virtual void _postGetPropertyState () 96 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ); 97 98 virtual void _setPropertyToDefault( const comphelper::PropertyInfo& rEntry ) 99 throw(::com::sun::star::beans::UnknownPropertyException ); 100 virtual ::com::sun::star::uno::Any _getPropertyDefault( const comphelper::PropertyInfo& rEntry ) 101 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException ); 102 103 public: 104 MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo, ::vos::IMutex *pMutex = NULL ) 105 throw(); 106 virtual ~MasterPropertySet() 107 throw(); 108 void registerSlave ( ChainablePropertySet *pNewSet ) 109 throw(); 110 111 // XPropertySet 112 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) 113 throw(::com::sun::star::uno::RuntimeException); 114 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 115 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 116 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) 117 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 118 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) 119 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 120 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) 121 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 122 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 123 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 124 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 125 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 126 127 // XMultiPropertySet 128 virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) 129 throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 130 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) 131 throw(::com::sun::star::uno::RuntimeException); 132 virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) 133 throw(::com::sun::star::uno::RuntimeException); 134 virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) 135 throw(::com::sun::star::uno::RuntimeException); 136 virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) 137 throw(::com::sun::star::uno::RuntimeException); 138 139 // XPropertyState 140 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) 141 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 142 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) 143 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 144 virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) 145 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 146 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) 147 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 148 }; 149 } 150 #endif 151 152