Tag: cws_src680_dba24d User: fs Date: 2007-11-19 08:55:16+0000 Modified: dba/dbaccess/source/ui/uno/copytablewizard.cxx
Log: more settings which are not allowed (read: not yet implemented) in the copy source descriptor File Changes: Directory: /dba/dbaccess/source/ui/uno/ ======================================= File [changed]: copytablewizard.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/uno/copytablewizard.cxx?r1=1.1.2.12&r2=1.1.2.13 Delta lines: +68 -12 --------------------- --- copytablewizard.cxx 2007-11-19 08:39:01+0000 1.1.2.12 +++ copytablewizard.cxx 2007-11-19 08:55:13+0000 1.1.2.13 @@ -4,9 +4,9 @@ * * $RCSfile: copytablewizard.cxx,v $ * - * $Revision: 1.1.2.12 $ + * $Revision: 1.1.2.13 $ * - * last change: $Author: fs $ $Date: 2007/11/19 08:39:01 $ + * last change: $Author: fs $ $Date: 2007/11/19 08:55:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -257,6 +257,15 @@ sal_Int32& _out_rCommandType ) const; + /** checks whether the given copy source descriptor contains settings which are not + supported (yet) + + Throws an IllegalArgumentException if the descriptor contains a valid setting, which is + not yet supported. + */ + void impl_checkForUnsupportedSettings_throw( + const Reference< XPropertySet >& _rxSourceDescriptor ) const; + /** obtaines the connection described by the given data access descriptor If needed and possible, the method will ask the user, using the interaction @@ -671,26 +680,73 @@ } //------------------------------------------------------------------------- - ::std::auto_ptr< ICopyTableSourceObject > CopyTableWizard::impl_extractSourceObject_throw( const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) const + namespace { - OSL_PRECOND( _rxDescriptor.is() && m_xSourceConnection.is(), "CopyTableWizard::impl_extractSourceObject_throw: illegal arguments!" ); + bool lcl_hasNonEmptyStringValue_throw( const Reference< XPropertySet >& _rxDescriptor, + const Reference< XPropertySetInfo > _rxPSI, const ::rtl::OUString& _rPropertyName ) + { + ::rtl::OUString sValue; + if ( _rxPSI->hasPropertyByName( _rPropertyName ) ) + { + OSL_VERIFY( _rxDescriptor->getPropertyValue( _rPropertyName ) >>= sValue ); + } + return sValue.getLength() > 0; + } + } - Reference< XPropertySetInfo > xPSI( _rxDescriptor->getPropertySetInfo(), UNO_SET_THROW ); + //------------------------------------------------------------------------- + void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< XPropertySet >& _rxSourceDescriptor ) const + { + OSL_PRECOND( _rxSourceDescriptor.is(), "CopyTableWizard::impl_checkForUnsupportedSettings_throw: illegal argument!" ); + Reference< XPropertySetInfo > xPSI( _rxSourceDescriptor->getPropertySetInfo(), UNO_SET_THROW ); + ::rtl::OUString sUnsupportedSetting; // in theory, we could allow to use a mere result set as copy source. However, since this is currently // not implemented at all, we report this in the initialization phase already if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) ) { - Reference< XResultSet > xSource( _rxDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY ); + Reference< XResultSet > xSource( _rxSourceDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY ); if ( xSource.is() ) - throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Result sets not yet supported as source of the copy operation." ) ), + sUnsupportedSetting = PROPERTY_RESULT_SET; + } + + if ( sUnsupportedSetting.getLength() == 0 ) + { + const ::rtl::OUString aSettings[] = { + PROPERTY_FILTER, PROPERTY_ORDER, PROPERTY_HAVING_CLAUSE, PROPERTY_GROUP_BY + }; + for ( size_t i=0; i < sizeof( aSettings ) / sizeof( aSettings[0] ); ++i ) + { + if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) ) + { + sUnsupportedSetting = aSettings[i]; + break; + } + } + } + + if ( sUnsupportedSetting.getLength() != 0 ) + { + ::rtl::OUString sMessage( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unsupported setting in the copy source descriptor: $name$." ) ) ); // TODO: resource + sMessage = sMessage.replaceAt( sMessage.indexOfAsciiL( "$name$", 6 ), 6, sUnsupportedSetting ); + throw IllegalArgumentException( + sMessage, *const_cast< CopyTableWizard* >( this ), 1 ); } + } + + //------------------------------------------------------------------------- + ::std::auto_ptr< ICopyTableSourceObject > CopyTableWizard::impl_extractSourceObject_throw( const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) const + { + OSL_PRECOND( _rxDescriptor.is() && m_xSourceConnection.is(), "CopyTableWizard::impl_extractSourceObject_throw: illegal arguments!" ); + + impl_checkForUnsupportedSettings_throw( _rxDescriptor ); + + Reference< XPropertySetInfo > xPSI( _rxDescriptor->getPropertySetInfo(), UNO_SET_THROW ); if ( !xPSI->hasPropertyByName( PROPERTY_COMMAND ) || !xPSI->hasPropertyByName( PROPERTY_COMMAND_TYPE ) ) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
