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_chart2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "WrappedPropertySet.hxx" 32*cdf0e10cSrcweir #include "macros.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir // header for define DELETEZ 35*cdf0e10cSrcweir #include <tools/solar.h> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <tools/debug.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir //............................................................................. 40*cdf0e10cSrcweir namespace chart 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir //............................................................................. 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir using namespace ::com::sun::star; 45*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 46*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 47*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 48*cdf0e10cSrcweir using ::rtl::OUString; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir WrappedPropertySet::WrappedPropertySet() 51*cdf0e10cSrcweir : MutexContainer() 52*cdf0e10cSrcweir , m_xInfo(0) 53*cdf0e10cSrcweir , m_pPropertyArrayHelper(0) 54*cdf0e10cSrcweir , m_pWrappedPropertyMap(0) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir WrappedPropertySet::~WrappedPropertySet() 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir clearWrappedPropertySet(); 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir Reference< beans::XPropertyState > WrappedPropertySet::getInnerPropertyState() 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir return Reference< beans::XPropertyState >( getInnerPropertySet(), uno::UNO_QUERY ); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir void WrappedPropertySet::clearWrappedPropertySet() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir //delete all wrapped properties 72*cdf0e10cSrcweir if(m_pWrappedPropertyMap) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir for( tWrappedPropertyMap::iterator aIt = m_pWrappedPropertyMap->begin() 75*cdf0e10cSrcweir ; aIt!= m_pWrappedPropertyMap->end(); aIt++ ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = (*aIt).second; 78*cdf0e10cSrcweir DELETEZ(pWrappedProperty); 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir DELETEZ(m_pPropertyArrayHelper); 83*cdf0e10cSrcweir DELETEZ(m_pWrappedPropertyMap); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir m_xInfo = NULL; 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //XPropertySet 89*cdf0e10cSrcweir Reference< beans::XPropertySetInfo > SAL_CALL WrappedPropertySet::getPropertySetInfo( ) 90*cdf0e10cSrcweir throw (uno::RuntimeException) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir Reference< beans::XPropertySetInfo > xInfo = m_xInfo; 93*cdf0e10cSrcweir if( !xInfo.is() ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence 96*cdf0e10cSrcweir xInfo = m_xInfo; 97*cdf0e10cSrcweir if( !xInfo.is() ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); 100*cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 101*cdf0e10cSrcweir m_xInfo = xInfo; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir else 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir return m_xInfo; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) 112*cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir try 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 117*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); 118*cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() ); 119*cdf0e10cSrcweir if( pWrappedProperty ) 120*cdf0e10cSrcweir pWrappedProperty->setPropertyValue( rValue, xInnerPropertySet ); 121*cdf0e10cSrcweir else if( xInnerPropertySet.is() ) 122*cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( rPropertyName, rValue ); 123*cdf0e10cSrcweir else 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 126*cdf0e10cSrcweir DBG_ERROR("found no inner property set to map to"); 127*cdf0e10cSrcweir #endif 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir throw ex; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir catch( beans::PropertyVetoException& ex ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir throw ex; 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ex ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir throw ex; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir catch( lang::WrappedTargetException& ex ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir throw ex; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir catch( uno::RuntimeException& ex ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir throw ex; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir catch( uno::Exception& ex ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir OSL_ENSURE(false,"invalid exception caught in WrappedPropertySet::setPropertyValue"); 153*cdf0e10cSrcweir lang::WrappedTargetException aWrappedException; 154*cdf0e10cSrcweir aWrappedException.TargetException = uno::makeAny( ex ); 155*cdf0e10cSrcweir throw aWrappedException; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName ) 159*cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir Any aRet; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir try 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 166*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); 167*cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() ); 168*cdf0e10cSrcweir if( pWrappedProperty ) 169*cdf0e10cSrcweir aRet = pWrappedProperty->getPropertyValue( xInnerPropertySet ); 170*cdf0e10cSrcweir else if( xInnerPropertySet.is() ) 171*cdf0e10cSrcweir aRet = xInnerPropertySet->getPropertyValue( rPropertyName ); 172*cdf0e10cSrcweir else 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 175*cdf0e10cSrcweir DBG_ERROR("found no inner property set to map to"); 176*cdf0e10cSrcweir #endif 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir throw ex; 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir catch( lang::WrappedTargetException& ex ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir throw ex; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir catch( uno::RuntimeException& ex ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir throw ex; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir catch( uno::Exception& ex ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir OSL_ENSURE(false,"invalid exception caught in WrappedPropertySet::setPropertyValue"); 194*cdf0e10cSrcweir lang::WrappedTargetException aWrappedException; 195*cdf0e10cSrcweir aWrappedException.TargetException = uno::makeAny( ex ); 196*cdf0e10cSrcweir throw aWrappedException; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir return aRet; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::addPropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) 203*cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() ); 206*cdf0e10cSrcweir if( xInnerPropertySet.is() ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 209*cdf0e10cSrcweir if( pWrappedProperty ) 210*cdf0e10cSrcweir xInnerPropertySet->addPropertyChangeListener( pWrappedProperty->getInnerName(), xListener ); 211*cdf0e10cSrcweir else 212*cdf0e10cSrcweir xInnerPropertySet->addPropertyChangeListener( rPropertyName, xListener ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir // m_aBoundListenerContainer.addInterface( (sal_Int32)nHandle, xListener ); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::removePropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& aListener ) 217*cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() ); 220*cdf0e10cSrcweir if( xInnerPropertySet.is() ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 223*cdf0e10cSrcweir if( pWrappedProperty ) 224*cdf0e10cSrcweir xInnerPropertySet->removePropertyChangeListener( pWrappedProperty->getInnerName(), aListener ); 225*cdf0e10cSrcweir else 226*cdf0e10cSrcweir xInnerPropertySet->removePropertyChangeListener( rPropertyName, aListener ); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::addVetoableChangeListener( const OUString& rPropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) 230*cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() ); 233*cdf0e10cSrcweir if( xInnerPropertySet.is() ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 236*cdf0e10cSrcweir if( pWrappedProperty ) 237*cdf0e10cSrcweir xInnerPropertySet->addVetoableChangeListener( pWrappedProperty->getInnerName(), aListener ); 238*cdf0e10cSrcweir else 239*cdf0e10cSrcweir xInnerPropertySet->addVetoableChangeListener( rPropertyName, aListener ); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::removeVetoableChangeListener( const OUString& rPropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) 243*cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() ); 246*cdf0e10cSrcweir if( xInnerPropertySet.is() ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 249*cdf0e10cSrcweir if( pWrappedProperty ) 250*cdf0e10cSrcweir xInnerPropertySet->removeVetoableChangeListener( pWrappedProperty->getInnerName(), aListener ); 251*cdf0e10cSrcweir else 252*cdf0e10cSrcweir xInnerPropertySet->removeVetoableChangeListener( rPropertyName, aListener ); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir //XMultiPropertySet 257*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertyValues( const Sequence< OUString >& rNameSeq, const Sequence< Any >& rValueSeq ) 258*cdf0e10cSrcweir throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir bool bUnknownProperty = false; 261*cdf0e10cSrcweir sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() ); 262*cdf0e10cSrcweir for(sal_Int32 nN=0; nN<nMinCount; nN++) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] ); 265*cdf0e10cSrcweir try 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir this->setPropertyValue( aPropertyName, rValueSeq[nN] ); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 272*cdf0e10cSrcweir bUnknownProperty = true; 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir //todo: store unknown properties elsewhere 276*cdf0e10cSrcweir // if( bUnknownProperty ) 277*cdf0e10cSrcweir // throw beans::UnknownPropertyException(); 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyValues( const Sequence< OUString >& rNameSeq ) 280*cdf0e10cSrcweir throw (uno::RuntimeException) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir Sequence< Any > aRetSeq; 283*cdf0e10cSrcweir if( rNameSeq.getLength() ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir aRetSeq.realloc( rNameSeq.getLength() ); 286*cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir try 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] ); 291*cdf0e10cSrcweir aRetSeq[nN] = this->getPropertyValue( aPropertyName ); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir catch( lang::WrappedTargetException& ex ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir return aRetSeq; 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::addPropertiesChangeListener( const Sequence< OUString >& /* rNameSeq */, const Reference< beans::XPropertiesChangeListener >& /* xListener */ ) 306*cdf0e10cSrcweir throw (uno::RuntimeException) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir OSL_ENSURE(false,"not implemented yet"); 309*cdf0e10cSrcweir //todo 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& /* xListener */ ) 312*cdf0e10cSrcweir throw (uno::RuntimeException) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir OSL_ENSURE(false,"not implemented yet"); 315*cdf0e10cSrcweir //todo 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::firePropertiesChangeEvent( const Sequence< OUString >& /* rNameSeq */, const Reference< beans::XPropertiesChangeListener >& /* xListener */ ) 318*cdf0e10cSrcweir throw (uno::RuntimeException) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir OSL_ENSURE(false,"not implemented yet"); 321*cdf0e10cSrcweir //todo 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir //XPropertyState 325*cdf0e10cSrcweir beans::PropertyState SAL_CALL WrappedPropertySet::getPropertyState( const OUString& rPropertyName ) 326*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE ); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() ); 331*cdf0e10cSrcweir if( xInnerPropertyState.is() ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 334*cdf0e10cSrcweir if( pWrappedProperty ) 335*cdf0e10cSrcweir aState = pWrappedProperty->getPropertyState( xInnerPropertyState ); 336*cdf0e10cSrcweir else 337*cdf0e10cSrcweir aState = xInnerPropertyState->getPropertyState( rPropertyName ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir return aState; 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir const WrappedProperty* WrappedPropertySet::getWrappedProperty( const ::rtl::OUString& rOuterName ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rOuterName ); 345*cdf0e10cSrcweir return getWrappedProperty( nHandle ); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir const WrappedProperty* WrappedPropertySet::getWrappedProperty( sal_Int32 nHandle ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir tWrappedPropertyMap::const_iterator aFound( getWrappedPropertyMap().find( nHandle ) ); 351*cdf0e10cSrcweir if( aFound != getWrappedPropertyMap().end() ) 352*cdf0e10cSrcweir return (*aFound).second; 353*cdf0e10cSrcweir return 0; 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir Sequence< beans::PropertyState > SAL_CALL WrappedPropertySet::getPropertyStates( const Sequence< OUString >& rNameSeq ) 357*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir Sequence< beans::PropertyState > aRetSeq; 360*cdf0e10cSrcweir if( rNameSeq.getLength() ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir aRetSeq.realloc( rNameSeq.getLength() ); 363*cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] ); 366*cdf0e10cSrcweir aRetSeq[nN] = this->getPropertyState( aPropertyName ); 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir return aRetSeq; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertyToDefault( const OUString& rPropertyName ) 373*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() ); 376*cdf0e10cSrcweir if( xInnerPropertyState.is() ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 379*cdf0e10cSrcweir if( pWrappedProperty ) 380*cdf0e10cSrcweir pWrappedProperty->setPropertyToDefault( xInnerPropertyState ); 381*cdf0e10cSrcweir else 382*cdf0e10cSrcweir xInnerPropertyState->setPropertyToDefault( rPropertyName ); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir Any SAL_CALL WrappedPropertySet::getPropertyDefault( const OUString& rPropertyName ) 386*cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir Any aRet; 389*cdf0e10cSrcweir Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() ); 390*cdf0e10cSrcweir if( xInnerPropertyState.is() ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 393*cdf0e10cSrcweir if( pWrappedProperty ) 394*cdf0e10cSrcweir aRet = pWrappedProperty->getPropertyDefault(xInnerPropertyState); 395*cdf0e10cSrcweir else 396*cdf0e10cSrcweir aRet = xInnerPropertyState->getPropertyDefault( rPropertyName ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir return aRet; 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir //XMultiPropertyStates 402*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setAllPropertiesToDefault( ) 403*cdf0e10cSrcweir throw (uno::RuntimeException) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir const Sequence< beans::Property >& rPropSeq = getPropertySequence(); 406*cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir ::rtl::OUString aPropertyName( rPropSeq[nN].Name ); 409*cdf0e10cSrcweir this->setPropertyToDefault( aPropertyName ); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertiesToDefault( const Sequence< OUString >& rNameSeq ) 413*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] ); 418*cdf0e10cSrcweir this->setPropertyToDefault( aPropertyName ); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyDefaults( const Sequence< OUString >& rNameSeq ) 422*cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir Sequence< Any > aRetSeq; 425*cdf0e10cSrcweir if( rNameSeq.getLength() ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir aRetSeq.realloc( rNameSeq.getLength() ); 428*cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] ); 431*cdf0e10cSrcweir aRetSeq[nN] = this->getPropertyDefault( aPropertyName ); 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir return aRetSeq; 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir //----------------------------------------------------------------------------- 438*cdf0e10cSrcweir //----------------------------------------------------------------------------- 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& WrappedPropertySet::getInfoHelper() 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir ::cppu::OPropertyArrayHelper* p = m_pPropertyArrayHelper; 443*cdf0e10cSrcweir if(!p) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence 446*cdf0e10cSrcweir p = m_pPropertyArrayHelper; 447*cdf0e10cSrcweir if(!p) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir p = new ::cppu::OPropertyArrayHelper( getPropertySequence(), sal_True ); 450*cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 451*cdf0e10cSrcweir m_pPropertyArrayHelper = p; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir else 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir return *m_pPropertyArrayHelper; 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir //----------------------------------------------------------------------------- 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir tWrappedPropertyMap& WrappedPropertySet::getWrappedPropertyMap() 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir tWrappedPropertyMap* p = m_pWrappedPropertyMap; 466*cdf0e10cSrcweir if(!p) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence 469*cdf0e10cSrcweir p = m_pWrappedPropertyMap; 470*cdf0e10cSrcweir if(!p) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir std::vector< WrappedProperty* > aPropList( createWrappedProperties() ); 473*cdf0e10cSrcweir p = new tWrappedPropertyMap(); 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir for( std::vector< WrappedProperty* >::const_iterator aIt = aPropList.begin(); aIt!=aPropList.end(); ++aIt ) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir WrappedProperty* pProperty = *aIt; 478*cdf0e10cSrcweir if(pProperty) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( pProperty->getOuterName() ); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir if( nHandle == -1 ) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir OSL_ENSURE( false, "missing property in property list" ); 485*cdf0e10cSrcweir delete pProperty;//we are owner or the created WrappedProperties 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir else if( p->find( nHandle ) != p->end() ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir //duplicate Wrapped property 490*cdf0e10cSrcweir OSL_ENSURE( false, "duplicate Wrapped property" ); 491*cdf0e10cSrcweir delete pProperty;//we are owner or the created WrappedProperties 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir else 494*cdf0e10cSrcweir (*p)[ nHandle ] = pProperty; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 499*cdf0e10cSrcweir m_pWrappedPropertyMap = p; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir else 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir return *m_pWrappedPropertyMap; 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir //............................................................................. 510*cdf0e10cSrcweir } //namespace chart 511*cdf0e10cSrcweir //............................................................................. 512