1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_comphelper.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifndef _COMPHELPER_MASTERPROPERTYSET_HXX_ 32*cdf0e10cSrcweir #include <comphelper/MasterPropertySet.hxx> 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #include <comphelper/MasterPropertySetInfo.hxx> 35*cdf0e10cSrcweir #include <comphelper/ChainablePropertySet.hxx> 36*cdf0e10cSrcweir #include <comphelper/ChainablePropertySetInfo.hxx> 37*cdf0e10cSrcweir #include <vos/mutex.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <memory> // STL auto_ptr 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir class AutoOGuardArray 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir sal_Int32 nSize; 46*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > * pGuardArray; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir public: 49*cdf0e10cSrcweir AutoOGuardArray( sal_Int32 nNumElements ); 50*cdf0e10cSrcweir ~AutoOGuardArray(); 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > & operator[] ( sal_Int32 i ) { return pGuardArray[i]; } 53*cdf0e10cSrcweir }; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir AutoOGuardArray::AutoOGuardArray( sal_Int32 nNumElements ) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir nSize = nNumElements; 58*cdf0e10cSrcweir pGuardArray = new std::auto_ptr< vos::OGuard >[ nSize ]; 59*cdf0e10cSrcweir } 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir AutoOGuardArray::~AutoOGuardArray() 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir //!! release auto_ptr's and thus the mutexes locks 64*cdf0e10cSrcweir delete [] pGuardArray; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir using namespace ::rtl; 71*cdf0e10cSrcweir using namespace ::comphelper; 72*cdf0e10cSrcweir using namespace ::com::sun::star; 73*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 74*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 75*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 76*cdf0e10cSrcweir using vos::IMutex; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir SlaveData::SlaveData ( ChainablePropertySet *pSlave) 79*cdf0e10cSrcweir : mpSlave ( pSlave ) 80*cdf0e10cSrcweir , mxSlave ( pSlave ) 81*cdf0e10cSrcweir , mbInit ( sal_False ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir MasterPropertySet::MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo, IMutex *pMutex ) 86*cdf0e10cSrcweir throw() 87*cdf0e10cSrcweir : mpInfo ( pInfo ) 88*cdf0e10cSrcweir , mpMutex ( pMutex ) 89*cdf0e10cSrcweir , mnLastId ( 0 ) 90*cdf0e10cSrcweir , mxInfo ( pInfo ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir void MasterPropertySet::lockMutex() 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir if (mpMutex) 97*cdf0e10cSrcweir mpMutex->acquire(); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir void MasterPropertySet::unlockMutex() 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir if (mpMutex) 102*cdf0e10cSrcweir mpMutex->release(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir MasterPropertySet::~MasterPropertySet() 106*cdf0e10cSrcweir throw() 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir SlaveMap::iterator aEnd = maSlaveMap.end(), aIter = maSlaveMap.begin(); 109*cdf0e10cSrcweir while (aIter != aEnd ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir delete (*aIter).second; 112*cdf0e10cSrcweir aIter++; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // XPropertySet 117*cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL MasterPropertySet::getPropertySetInfo( ) 118*cdf0e10cSrcweir throw(RuntimeException) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir return mxInfo; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir void MasterPropertySet::registerSlave ( ChainablePropertySet *pNewSet ) 124*cdf0e10cSrcweir throw() 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir maSlaveMap [ ++mnLastId ] = new SlaveData ( pNewSet ); 127*cdf0e10cSrcweir mpInfo->add ( pNewSet->mpInfo->maMap, mnLastId ); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::setPropertyValue( const ::rtl::OUString& rPropertyName, const Any& rValue ) 131*cdf0e10cSrcweir throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 134*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > pMutexGuard; 135*cdf0e10cSrcweir if (mpMutex) 136*cdf0e10cSrcweir pMutexGuard.reset( new vos::OGuard(mpMutex) ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir if( aIter == mpInfo->maMap.end()) 141*cdf0e10cSrcweir throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir _preSetValues(); 146*cdf0e10cSrcweir _setSingleValue( *((*aIter).second->mpInfo), rValue ); 147*cdf0e10cSrcweir _postSetValues(); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir else 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mpSlave; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 154*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > pMutexGuard2; 155*cdf0e10cSrcweir if (pSlave->mpMutex) 156*cdf0e10cSrcweir pMutexGuard2.reset( new vos::OGuard(pSlave->mpMutex) ); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir pSlave->_preSetValues(); 159*cdf0e10cSrcweir pSlave->_setSingleValue( *((*aIter).second->mpInfo), rValue ); 160*cdf0e10cSrcweir pSlave->_postSetValues(); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir Any SAL_CALL MasterPropertySet::getPropertyValue( const ::rtl::OUString& rPropertyName ) 165*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 168*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > pMutexGuard; 169*cdf0e10cSrcweir if (mpMutex) 170*cdf0e10cSrcweir pMutexGuard.reset( new vos::OGuard(mpMutex) ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir if( aIter == mpInfo->maMap.end()) 175*cdf0e10cSrcweir throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir Any aAny; 178*cdf0e10cSrcweir if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir _preGetValues(); 181*cdf0e10cSrcweir _getSingleValue( *((*aIter).second->mpInfo), aAny ); 182*cdf0e10cSrcweir _postGetValues(); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir else 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mpSlave; 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 189*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > pMutexGuard2; 190*cdf0e10cSrcweir if (pSlave->mpMutex) 191*cdf0e10cSrcweir pMutexGuard2.reset( new vos::OGuard(pSlave->mpMutex) ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir pSlave->_preGetValues(); 194*cdf0e10cSrcweir pSlave->_getSingleValue( *((*aIter).second->mpInfo), aAny ); 195*cdf0e10cSrcweir pSlave->_postGetValues(); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir return aAny; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::addPropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& ) 201*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir // todo 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::removePropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& ) 207*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir // todo 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::addVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& ) 213*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir // todo 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::removeVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& ) 219*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir // todo 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir // XMultiPropertySet 225*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames, const Sequence< Any >& aValues ) 226*cdf0e10cSrcweir throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 229*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > pMutexGuard; 230*cdf0e10cSrcweir if (mpMutex) 231*cdf0e10cSrcweir pMutexGuard.reset( new vos::OGuard(mpMutex) ); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir const sal_Int32 nCount = aPropertyNames.getLength(); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir if( nCount != aValues.getLength() ) 236*cdf0e10cSrcweir throw IllegalArgumentException(); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir if( nCount ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir _preSetValues(); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir const Any * pAny = aValues.getConstArray(); 243*cdf0e10cSrcweir const OUString * pString = aPropertyNames.getConstArray(); 244*cdf0e10cSrcweir PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter; 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir //!! have an auto_ptr to an array of OGuards in order to have the 247*cdf0e10cSrcweir //!! allocated memory properly freed (exception safe!). 248*cdf0e10cSrcweir //!! Since the array itself has auto_ptrs as members we have to use a 249*cdf0e10cSrcweir //!! helper class 'AutoOGuardArray' in order to have 250*cdf0e10cSrcweir //!! the acquired locks properly released. 251*cdf0e10cSrcweir AutoOGuardArray aOGuardArray( nCount ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir aIter = mpInfo->maMap.find ( *pString ); 256*cdf0e10cSrcweir if ( aIter == aEnd ) 257*cdf0e10cSrcweir throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! 260*cdf0e10cSrcweir _setSingleValue( *((*aIter).second->mpInfo), *pAny ); 261*cdf0e10cSrcweir else 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]; 264*cdf0e10cSrcweir if (!pSlave->IsInit()) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 267*cdf0e10cSrcweir if (pSlave->mpSlave->mpMutex) 268*cdf0e10cSrcweir aOGuardArray[i].reset( new vos::OGuard(pSlave->mpSlave->mpMutex) ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir pSlave->mpSlave->_preSetValues(); 271*cdf0e10cSrcweir pSlave->SetInit ( sal_True ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir pSlave->mpSlave->_setSingleValue( *((*aIter).second->mpInfo), *pAny ); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir _postSetValues(); 278*cdf0e10cSrcweir SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end(); 279*cdf0e10cSrcweir while (aSlaveIter != aSlaveEnd) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir if ( (*aSlaveIter).second->IsInit()) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir (*aSlaveIter).second->mpSlave->_postSetValues(); 284*cdf0e10cSrcweir (*aSlaveIter).second->SetInit ( sal_False ); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir ++aSlaveIter; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames ) 292*cdf0e10cSrcweir throw(RuntimeException) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 295*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > pMutexGuard; 296*cdf0e10cSrcweir if (mpMutex) 297*cdf0e10cSrcweir pMutexGuard.reset( new vos::OGuard(mpMutex) ); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir const sal_Int32 nCount = aPropertyNames.getLength(); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir Sequence < Any > aValues ( nCount ); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir if( nCount ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir _preGetValues(); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir Any * pAny = aValues.getArray(); 308*cdf0e10cSrcweir const OUString * pString = aPropertyNames.getConstArray(); 309*cdf0e10cSrcweir PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter; 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir //!! have an auto_ptr to an array of OGuards in order to have the 312*cdf0e10cSrcweir //!! allocated memory properly freed (exception safe!). 313*cdf0e10cSrcweir //!! Since the array itself has auto_ptrs as members we have to use a 314*cdf0e10cSrcweir //!! helper class 'AutoOGuardArray' in order to have 315*cdf0e10cSrcweir //!! the acquired locks properly released. 316*cdf0e10cSrcweir AutoOGuardArray aOGuardArray( nCount ); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny ) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir aIter = mpInfo->maMap.find ( *pString ); 321*cdf0e10cSrcweir if ( aIter == aEnd ) 322*cdf0e10cSrcweir throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! 325*cdf0e10cSrcweir _getSingleValue( *((*aIter).second->mpInfo), *pAny ); 326*cdf0e10cSrcweir else 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]; 329*cdf0e10cSrcweir if (!pSlave->IsInit()) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 332*cdf0e10cSrcweir if (pSlave->mpSlave->mpMutex) 333*cdf0e10cSrcweir aOGuardArray[i].reset( new vos::OGuard(pSlave->mpSlave->mpMutex) ); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir pSlave->mpSlave->_preGetValues(); 336*cdf0e10cSrcweir pSlave->SetInit ( sal_True ); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir pSlave->mpSlave->_getSingleValue( *((*aIter).second->mpInfo), *pAny ); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir _postSetValues(); 343*cdf0e10cSrcweir SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end(); 344*cdf0e10cSrcweir while (aSlaveIter != aSlaveEnd) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir if ( (*aSlaveIter).second->IsInit()) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir (*aSlaveIter).second->mpSlave->_postSetValues(); 349*cdf0e10cSrcweir (*aSlaveIter).second->SetInit ( sal_False ); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir ++aSlaveIter; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir return aValues; 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::addPropertiesChangeListener( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& ) 358*cdf0e10cSrcweir throw(RuntimeException) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir // todo 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& ) 364*cdf0e10cSrcweir throw(RuntimeException) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir // todo 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::firePropertiesChangeEvent( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& ) 370*cdf0e10cSrcweir throw(RuntimeException) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir // todo 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir // XPropertyState 376*cdf0e10cSrcweir PropertyState SAL_CALL MasterPropertySet::getPropertyState( const ::rtl::OUString& PropertyName ) 377*cdf0e10cSrcweir throw(UnknownPropertyException, RuntimeException) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir PropertyDataHash::const_iterator aIter = mpInfo->maMap.find( PropertyName ); 380*cdf0e10cSrcweir if( aIter == mpInfo->maMap.end()) 381*cdf0e10cSrcweir throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) ); 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir PropertyState aState; 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir _preGetPropertyState(); 388*cdf0e10cSrcweir _getPropertyState( *((*aIter).second->mpInfo), aState ); 389*cdf0e10cSrcweir _postGetPropertyState(); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir else 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mpSlave; 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir // acquire mutex in c-tor and releases it in the d-tor (exception safe!). 396*cdf0e10cSrcweir std::auto_ptr< vos::OGuard > pMutexGuard; 397*cdf0e10cSrcweir if (pSlave->mpMutex) 398*cdf0e10cSrcweir pMutexGuard.reset( new vos::OGuard(pSlave->mpMutex) ); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir pSlave->_preGetPropertyState(); 401*cdf0e10cSrcweir pSlave->_getPropertyState( *((*aIter).second->mpInfo), aState ); 402*cdf0e10cSrcweir pSlave->_postGetPropertyState(); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir return aState; 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir Sequence< PropertyState > SAL_CALL MasterPropertySet::getPropertyStates( const Sequence< ::rtl::OUString >& rPropertyNames ) 409*cdf0e10cSrcweir throw(UnknownPropertyException, RuntimeException) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir const sal_Int32 nCount = rPropertyNames.getLength(); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir Sequence< PropertyState > aStates( nCount ); 414*cdf0e10cSrcweir if( nCount ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir PropertyState * pState = aStates.getArray(); 417*cdf0e10cSrcweir const OUString * pString = rPropertyNames.getConstArray(); 418*cdf0e10cSrcweir PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter; 419*cdf0e10cSrcweir _preGetPropertyState(); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pState ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir aIter = mpInfo->maMap.find ( *pString ); 424*cdf0e10cSrcweir if ( aIter == aEnd ) 425*cdf0e10cSrcweir throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! 428*cdf0e10cSrcweir _getPropertyState( *((*aIter).second->mpInfo), *pState ); 429*cdf0e10cSrcweir else 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]; 432*cdf0e10cSrcweir if (!pSlave->IsInit()) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir pSlave->mpSlave->_preGetPropertyState(); 435*cdf0e10cSrcweir pSlave->SetInit ( sal_True ); 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir pSlave->mpSlave->_getPropertyState( *((*aIter).second->mpInfo), *pState ); 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir _postGetPropertyState(); 441*cdf0e10cSrcweir SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end(); 442*cdf0e10cSrcweir while (aSlaveIter != aSlaveEnd) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir if ( (*aSlaveIter).second->IsInit()) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir (*aSlaveIter).second->mpSlave->_postGetPropertyState(); 447*cdf0e10cSrcweir (*aSlaveIter).second->SetInit ( sal_False ); 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir ++aSlaveIter; 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir return aStates; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir void SAL_CALL MasterPropertySet::setPropertyToDefault( const ::rtl::OUString& rPropertyName ) 456*cdf0e10cSrcweir throw(UnknownPropertyException, RuntimeException) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir if( aIter == mpInfo->maMap.end()) 461*cdf0e10cSrcweir throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); 462*cdf0e10cSrcweir _setPropertyToDefault( *((*aIter).second->mpInfo) ); 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir Any SAL_CALL MasterPropertySet::getPropertyDefault( const ::rtl::OUString& rPropertyName ) 466*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir if( aIter == mpInfo->maMap.end()) 471*cdf0e10cSrcweir throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); 472*cdf0e10cSrcweir return _getPropertyDefault( *((*aIter).second->mpInfo) ); 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir void MasterPropertySet::_preGetPropertyState () 476*cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir OSL_ENSURE( sal_False, "you have to implement this yourself!"); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir void MasterPropertySet::_getPropertyState( const comphelper::PropertyInfo&, PropertyState& ) 482*cdf0e10cSrcweir throw(UnknownPropertyException ) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir OSL_ENSURE( sal_False, "you have to implement this yourself!"); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir void MasterPropertySet::_postGetPropertyState () 488*cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir OSL_ENSURE( sal_False, "you have to implement this yourself!"); 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir void MasterPropertySet::_setPropertyToDefault( const comphelper::PropertyInfo& ) 494*cdf0e10cSrcweir throw(UnknownPropertyException ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir OSL_ENSURE( sal_False, "you have to implement this yourself!"); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir Any MasterPropertySet::_getPropertyDefault( const comphelper::PropertyInfo& ) 500*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir OSL_ENSURE( sal_False, "you have to implement this yourself!"); 503*cdf0e10cSrcweir Any aAny; 504*cdf0e10cSrcweir return aAny; 505*cdf0e10cSrcweir } 506