Tag: cws_src680_dba30 User: fs Date: 06/05/22 03:01:28 Modified: /dba/dbaccess/source/core/dataaccess/ datasource.cxx
Log: #i65678# when setting the Info property, ensure that all properties not present in the new sequence are reset respectively deleted from the Settings bag File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: datasource.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.cxx?r1=1.59.2.8&r2=1.59.2.9 Delta lines: +77 -12 --------------------- --- datasource.cxx 8 May 2006 11:19:01 -0000 1.59.2.8 +++ datasource.cxx 22 May 2006 10:01:25 -0000 1.59.2.9 @@ -4,9 +4,9 @@ * * $RCSfile: datasource.cxx,v $ * - * $Revision: 1.59.2.8 $ + * $Revision: 1.59.2.9 $ * - * last change: $Author: fs $ $Date: 2006/05/08 11:19:01 $ + * last change: $Author: fs $ $Date: 2006/05/22 10:01:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -976,6 +976,79 @@ } //------------------------------------------------------------------------------ +namespace +{ + struct SelectPropertyName : public ::std::unary_function< PropertyValue, ::rtl::OUString > + { + public: + const ::rtl::OUString& operator()( const PropertyValue& _lhs ) + { + return _lhs.Name; + } + }; + + /** sets a new set of property values at a given property bag instance + + The methods takes a property bag, and a sequence of property values to set at this bag. + Upon return, every property which is not part of the given sequence is + <ul><li>removed from the bag, if it's a removeable property</li> + <li><em>or</em>reset to its default value, if it's not a removeable property</li> + </ul>. + + @param _rxPropertyBag + the property bag to operate on + @param _rAllNewPropertyValues + the new property values to set at the bag + */ + void lcl_setPropertyValues_resetOrRemoveOther( const Reference< XPropertyAccess >& _rxPropertyBag, const Sequence< PropertyValue >& _rAllNewPropertyValues ) + { + // sequences are ugly to operate on + typedef ::std::set< ::rtl::OUString > StringSet; + StringSet aToBeSetPropertyNames; + ::std::transform( + _rAllNewPropertyValues.getConstArray(), + _rAllNewPropertyValues.getConstArray() + _rAllNewPropertyValues.getLength(), + ::std::insert_iterator< StringSet >( aToBeSetPropertyNames, aToBeSetPropertyNames.end() ), + SelectPropertyName() + ); + + try + { + // obtain all properties currently known at the bag + Reference< XPropertySet > xPropertySet( _rxPropertyBag, UNO_QUERY_THROW ); + Reference< XPropertySetInfo > xPSI( xPropertySet->getPropertySetInfo(), UNO_QUERY_THROW ); + Sequence< Property > aAllExistentProperties( xPSI->getProperties() ); + + Reference< XPropertyState > xPropertyState( _rxPropertyBag, UNO_QUERY_THROW ); + Reference< XPropertyContainer > xPropertyContainer( _rxPropertyBag, UNO_QUERY_THROW ); + + // loop through them, and reset resp. default properties which are not to be set + const Property* pExistentProperty( aAllExistentProperties.getConstArray() ); + const Property* pExistentPropertyEnd( aAllExistentProperties.getConstArray() + aAllExistentProperties.getLength() ); + for ( ; pExistentProperty != pExistentPropertyEnd; ++pExistentProperty ) + { + if ( aToBeSetPropertyNames.find( pExistentProperty->Name ) != aToBeSetPropertyNames.end() ) + continue; + + // this property is not to be set, but currently exists in the bag. + // -> Remove, respectively default, it + if ( ( pExistentProperty->Attributes & PropertyAttribute::REMOVEABLE ) != 0 ) + xPropertyContainer->removeProperty( pExistentProperty->Name ); + else + xPropertyState->setPropertyToDefault( pExistentProperty->Name ); + } + + // finally, set the new property values + _rxPropertyBag->setPropertyValues( _rAllNewPropertyValues ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } +} + +//------------------------------------------------------------------------------ void ODatabaseSource::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception) { if ( m_pImpl.is() ) @@ -1009,15 +1082,7 @@ { Sequence< PropertyValue > aInfo; OSL_VERIFY( rValue >>= aInfo ); - try - { - m_pImpl->m_xSettings->setPropertyValues( aInfo ); - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, - "ODatabaseSource::setFastPropertyValue_NoBroadcast: caught an exception while forwarding the Info property value to the property bag!" ); - } + lcl_setPropertyValues_resetOrRemoveOther( m_pImpl->m_xSettings, aInfo ); } break; case PROPERTY_ID_LAYOUTINFORMATION: --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
