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_CHAINABLEPROPERTYSET_HXX_ 25 #define _COMPHELPER_CHAINABLEPROPERTYSET_HXX_ 26 27 #include <com/sun/star/beans/XPropertySet.hpp> 28 #include <com/sun/star/beans/XPropertyState.hpp> 29 #include <com/sun/star/beans/XMultiPropertySet.hpp> 30 #include <comphelper/PropertyInfoHash.hxx> 31 #include "comphelper/comphelperdllapi.h" 32 33 namespace comphelper 34 { 35 class ChainablePropertySetInfo; 36 } 37 namespace vos 38 { 39 class IMutex; 40 } 41 /* 42 * A ChainablePropertySet has the following features: 43 * 44 * 1. It implements both the PropertySet and MultiPropertySet interfaces. 45 * 2. It can be 'included' in a MasterPropertySet to seamlessly appear as if 46 * if it's properties were in the master. 47 * 48 * To be used as a base class for PropertySets, the subclass must implement 49 * the 6 protected pure virtual functions. If a mutex is passed to the 50 * constructor, this is locked before any call to _getSingleValue or 51 * _setSingleValue and released after all processing has completed 52 * (including _postSetValues or _postGetValues ) 53 * 54 * The implementations of getPropertyValues/setPropertyValues call 55 * lockMutex and _preGetValues/_preSetValues once before calling 56 * _getSingleValue/_setSingleValue for each property. After each 57 * property has been dealt with, _postGetValues/_postSetValues 58 * are called once. 59 * 60 * Any MasterPropertySet implementations that can include an 61 * implementation of a given ChainablePropertySet must be 62 * declared as a 'friend' in the implementation of the ChainablePropertySet. 63 * 64 */ 65 66 namespace comphelper 67 { 68 class COMPHELPER_DLLPUBLIC ChainablePropertySet : public ::com::sun::star::beans::XPropertySet, 69 public ::com::sun::star::beans::XPropertyState, 70 public ::com::sun::star::beans::XMultiPropertySet 71 { 72 friend class MasterPropertySet; 73 protected: 74 ChainablePropertySetInfo *mpInfo; 75 vos::IMutex *mpMutex; 76 ::com::sun::star::uno::Reference < com::sun::star::beans::XPropertySetInfo > mxInfo; 77 void lockMutex(); 78 void unlockMutex(); 79 80 virtual void _preSetValues () = 0; 81 virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue ) = 0; 82 virtual void _postSetValues () = 0; 83 84 virtual void _preGetValues () = 0; 85 virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue ) = 0; 86 virtual void _postGetValues () = 0; 87 88 virtual void _preGetPropertyState (); 89 virtual void _getPropertyState( const comphelper::PropertyInfo& rInfo, ::com::sun::star::beans::PropertyState& rState ); 90 virtual void _postGetPropertyState (); 91 92 virtual void _setPropertyToDefault( const comphelper::PropertyInfo& rEntry ); 93 virtual ::com::sun::star::uno::Any _getPropertyDefault( const comphelper::PropertyInfo& rEntry ); 94 95 public: 96 ChainablePropertySet( comphelper::ChainablePropertySetInfo* pInfo, vos::IMutex *pMutex = NULL ) 97 throw(); 98 virtual ~ChainablePropertySet() 99 throw(); 100 101 // XPropertySet 102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 103 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ); 104 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ); 105 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ); 106 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ); 107 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 108 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 109 110 // XMultiPropertySet 111 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 ); 112 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ); 113 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 ); 114 virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ); 115 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 ); 116 117 // XPropertyState 118 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ); 119 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ); 120 virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ); 121 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ); 122 }; 123 } 124 #endif 125