Tag: cws_src680_dba23b User: fs Date: 2007-07-07 19:24:18+0000 Modified: dba/dbaccess/source/core/dataaccess/datasource.cxx
Log: #i78593# when obtaining the Info property value from the Settings, copy all values which are removeable, and the non-default ones which are removeable 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.72&r2=1.72.102.1 Delta lines: +58 -15 --------------------- --- datasource.cxx 2006-09-17 06:39:41+0000 1.72 +++ datasource.cxx 2007-07-07 19:24:15+0000 1.72.102.1 @@ -4,9 +4,9 @@ * * $RCSfile: datasource.cxx,v $ * - * $Revision: 1.72 $ + * $Revision: 1.72.102.1 $ * - * last change: $Author: obo $ $Date: 2006/09/17 06:39:41 $ + * last change: $Author: fs $ $Date: 2007/07/07 19:24:15 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -589,11 +589,30 @@ } //------------------------------------------------------------------ - struct CheckForDefaultPropertyValue : public ::std::unary_function< PropertyValue, bool > + typedef ::std::map< ::rtl::OUString, sal_Int32 > PropertyAttributeCache; + + //------------------------------------------------------------------ + struct IsDefaultAndNotRemoveable : public ::std::unary_function< PropertyValue, bool > { + private: + const PropertyAttributeCache& m_rAttribs; + + public: + IsDefaultAndNotRemoveable( const PropertyAttributeCache& _rAttribs ) : m_rAttribs( _rAttribs ) { } + bool operator()( const PropertyValue& _rProp ) { - return _rProp.State == PropertyState_DEFAULT_VALUE; + if ( _rProp.State != PropertyState_DEFAULT_VALUE ) + return false; + + bool bRemoveable = true; + + PropertyAttributeCache::const_iterator pos = m_rAttribs.find( _rProp.Name ); + OSL_ENSURE( pos != m_rAttribs.end(), "IsDefaultAndNotRemoveable: illegal property name!" ); + if ( pos != m_rAttribs.end() ) + bRemoveable = ( ( pos->second & PropertyAttribute::REMOVEABLE ) != 0 ); + + return !bRemoveable; } }; } @@ -1127,16 +1146,40 @@ break; case PROPERTY_ID_INFO: { + try + { + // collect the property attributes of all current settings + Reference< XPropertySet > xSettingsAsProps( m_pImpl->m_xSettings, UNO_QUERY_THROW ); + Reference< XPropertySetInfo > xPST( xSettingsAsProps->getPropertySetInfo(), UNO_QUERY_THROW ); + Sequence< Property > aSettings( xPST->getProperties() ); + ::std::map< ::rtl::OUString, sal_Int32 > aPropertyAttributes; + for ( const Property* pSettings = aSettings.getConstArray(); + pSettings != aSettings.getConstArray() + aSettings.getLength(); + ++pSettings + ) + { + aPropertyAttributes[ pSettings->Name ] = pSettings->Attributes; + } + + // get all current settings with their values Sequence< PropertyValue > aValues( m_pImpl->m_xSettings->getPropertyValues() ); - Sequence< PropertyValue > aNonDefaultValues( aValues.getLength() ); + + // transform them so that only property values which fulfill certain + // criterions survive + Sequence< PropertyValue > aNonDefaultOrUserDefined( aValues.getLength() ); const PropertyValue* pCopyEnd = ::std::remove_copy_if( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(), - aNonDefaultValues.getArray(), - CheckForDefaultPropertyValue() + aNonDefaultOrUserDefined.getArray(), + IsDefaultAndNotRemoveable( aPropertyAttributes ) ); - aNonDefaultValues.realloc( pCopyEnd - aNonDefaultValues.getArray() ); - rValue <<= aNonDefaultValues; + aNonDefaultOrUserDefined.realloc( pCopyEnd - aNonDefaultOrUserDefined.getArray() ); + rValue <<= aNonDefaultOrUserDefined; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } break; case PROPERTY_ID_SETTINGS: --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
