summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/uno/copytablewizard.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/uno/copytablewizard.cxx')
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx183
1 files changed, 102 insertions, 81 deletions
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 578b8fa55350..be1cf5288b21 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -258,6 +258,17 @@ namespace dbaui
sal_Int32& _out_rCommandType
) const;
+ /** extracts the result set to copy records from, and the selection-related aspects, if any.
+
+ Effectively, this method extracts m_xSourceResultSet, m_aSourceSelection, and m_bSourceSelectionBookmarks.
+
+ If an inconsistent/insufficent sub set of those properties is present in the descriptor, and exception
+ is thrown.
+ */
+ void impl_extractSourceResultSet_throw(
+ const Reference< XPropertySet >& i_rDescriptor
+ );
+
/** checks whether the given copy source descriptor contains settings which are not
supported (yet)
@@ -299,7 +310,7 @@ namespace dbaui
/** creates the INSERT INTO statement
@param _xTable The destination table.
*/
- ::rtl::OUString impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable);
+ ::rtl::OUString impl_getServerSideCopyStatement_throw( const Reference< XPropertySet >& _xTable );
/** creates the statement which, when executed, will produce the source data to copy
@@ -342,8 +353,9 @@ private:
sal_Int32 m_nCommandType;
::std::auto_ptr< ICopyTableSourceObject >
m_pSourceObject;
+ Reference< XResultSet > m_xSourceResultSet;
Sequence< Any > m_aSourceSelection;
- bool m_bSourceSelectionBookmarks;
+ sal_Bool m_bSourceSelectionBookmarks;
// destination
SharedConnection m_xDestConnection;
@@ -390,13 +402,13 @@ CopyTableWizard::CopyTableWizard( const Reference< XMultiServiceFactory >& _rxOR
,m_xSourceConnection()
,m_nCommandType( CommandType::COMMAND )
,m_pSourceObject()
+ ,m_xSourceResultSet()
,m_aSourceSelection()
- ,m_bSourceSelectionBookmarks( true )
+ ,m_bSourceSelectionBookmarks( sal_True )
,m_xDestConnection()
,m_aCopyTableListeners( m_aMutex )
,m_nOverrideExecutionResult( -1 )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::CopyTableWizard" );
}
//-------------------------------------------------------------------------
@@ -412,7 +424,7 @@ CopyTableWizard::~CopyTableWizard()
// TODO: shouldn't we have explicit disposal support? If a listener is registered
// at our instance, and perhaps holds this our instance by a hard ref, then we'll never
- // destroyed.
+ // be destroyed.
// However, adding XComponent support to the GenericUNODialog probably requires
// some thinking - would it break existing clients which do not call a dispose, then?
}
@@ -459,7 +471,6 @@ Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() thr
//--------------------------------------------------------------------
::sal_Int16 SAL_CALL CopyTableWizard::getOperation() throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getOperation" );
CopyTableAccessGuard aGuard( *this );
return m_nOperation;
}
@@ -467,7 +478,6 @@ Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() thr
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (IllegalArgumentException, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setOperation" );
CopyTableAccessGuard aGuard( *this );
if ( ( _operation != CopyTableOperation::CopyDefinitionAndData )
@@ -492,7 +502,6 @@ void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (Ill
//--------------------------------------------------------------------
::rtl::OUString SAL_CALL CopyTableWizard::getDestinationTableName() throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getDestinationTableName" );
CopyTableAccessGuard aGuard( *this );
return m_sDestinationTable;
}
@@ -500,7 +509,6 @@ void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (Ill
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _destinationTableName ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setDestinationTableName" );
CopyTableAccessGuard aGuard( *this );
m_sDestinationTable = _destinationTableName;
}
@@ -508,7 +516,6 @@ void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _
//--------------------------------------------------------------------
Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getCreatePrimaryKey" );
CopyTableAccessGuard aGuard( *this );
return m_aPrimaryKeyName;
}
@@ -516,7 +523,6 @@ Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() thro
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setCreatePrimaryKey( const Optional< ::rtl::OUString >& _newPrimaryKey ) throw (IllegalArgumentException, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setCreatePrimaryKey" );
CopyTableAccessGuard aGuard( *this );
if ( _newPrimaryKey.IsPresent && !OCopyTableWizard::supportsPrimaryKey( m_xDestConnection ) )
@@ -543,7 +549,6 @@ void SAL_CALL CopyTableWizard::setUseHeaderLineAsColumnNames( sal_Bool _bUseHead
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::addCopyTableListener" );
CopyTableAccessGuard aGuard( *this );
if ( _rxListener.is() )
m_aCopyTableListeners.addInterface( _rxListener );
@@ -552,7 +557,6 @@ void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTable
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::removeCopyTableListener" );
CopyTableAccessGuard aGuard( *this );
if ( _rxListener.is() )
m_aCopyTableListeners.removeInterface( _rxListener );
@@ -561,7 +565,6 @@ void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTa
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setTitle" );
CopyTableAccessGuard aGuard( *this );
CopyTableWizard_DialogBase::setTitle( _rTitle );
}
@@ -569,7 +572,6 @@ void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw
//--------------------------------------------------------------------
::sal_Int16 SAL_CALL CopyTableWizard::execute( ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::execute" );
CopyTableAccessGuard aGuard( *this );
m_nOverrideExecutionResult = -1;
@@ -583,7 +585,6 @@ void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw
//-------------------------------------------------------------------------
OCopyTableWizard& CopyTableWizard::impl_getDialog_throw()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" );
OCopyTableWizard* pWizard = dynamic_cast< OCopyTableWizard* >( m_pDialog );
if ( !pWizard )
throw DisposedException( ::rtl::OUString(), *this );
@@ -593,7 +594,6 @@ OCopyTableWizard& CopyTableWizard::impl_getDialog_throw()
//-------------------------------------------------------------------------
const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" );
const OCopyTableWizard* pWizard = dynamic_cast< const OCopyTableWizard* >( m_pDialog );
if ( !pWizard )
throw DisposedException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) );
@@ -603,7 +603,6 @@ const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const
//-------------------------------------------------------------------------
void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialog ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_attributesToDialog_nothrow" );
// primary key column
_rDialog.setCreatePrimaryKey( m_aPrimaryKeyName.IsPresent, m_aPrimaryKeyName.Value );
_rDialog.setUseHeaderLine(m_bUseHeaderLineAsColumnNames);
@@ -614,7 +613,6 @@ void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialo
//-------------------------------------------------------------------------
void CopyTableWizard::impl_dialogToAttributes_nothrow( const OCopyTableWizard& _rDialog )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_dialogToAttributes_nothrow" );
m_aPrimaryKeyName.IsPresent = _rDialog.shouldCreatePrimaryKey();
if ( m_aPrimaryKeyName.IsPresent )
m_aPrimaryKeyName.Value = _rDialog.getPrimaryKeyName();
@@ -689,7 +687,6 @@ Reference< XPropertySet > CopyTableWizard::impl_ensureDataAccessDescriptor_throw
const Sequence< Any >& _rAllArgs, const sal_Int16 _nArgPos, SharedConnection& _out_rxConnection,
InteractionHandler& _out_rxDocInteractionHandler ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_ensureDataAccessDescriptor_throw" );
Reference< XPropertySet > xDescriptor;
_rAllArgs[ _nArgPos ] >>= xDescriptor;
@@ -742,32 +739,19 @@ namespace
//-------------------------------------------------------------------------
void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< XPropertySet >& _rxSourceDescriptor ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_checkForUnsupportedSettings_throw" );
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( _rxSourceDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY );
- if ( xSource.is() )
- 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 )
{
- 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] ) )
{
- if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) )
- {
- sUnsupportedSetting = aSettings[i];
- break;
- }
+ sUnsupportedSetting = aSettings[i];
+ break;
}
}
@@ -787,17 +771,15 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X
//-------------------------------------------------------------------------
::std::auto_ptr< ICopyTableSourceObject > CopyTableWizard::impl_extractSourceObject_throw( const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractSourceObject_throw" );
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 )
)
throw IllegalArgumentException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Expecting a table or query specification." ) ),
+ // TODO: resource
*const_cast< CopyTableWizard* >( this ),
1
);
@@ -857,10 +839,48 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X
}
//-------------------------------------------------------------------------
+void CopyTableWizard::impl_extractSourceResultSet_throw( const Reference< XPropertySet >& i_rDescriptor )
+{
+ Reference< XPropertySetInfo > xPSI( i_rDescriptor->getPropertySetInfo(), UNO_SET_THROW );
+
+ // extract relevant settings
+ if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) )
+ m_xSourceResultSet.set( i_rDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY );
+
+ if ( xPSI->hasPropertyByName( PROPERTY_SELECTION ) )
+ OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_SELECTION ) >>= m_aSourceSelection );
+
+ if ( xPSI->hasPropertyByName( PROPERTY_BOOKMARK_SELECTION ) )
+ OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_BOOKMARK_SELECTION ) >>= m_bSourceSelectionBookmarks );
+
+ // sanity checks
+ const bool bHasResultSet = m_xSourceResultSet.is();
+ const bool bHasSelection = ( m_aSourceSelection.getLength() != 0 );
+ if ( bHasSelection && !bHasResultSet )
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "A result set is needed when specifying a selection to copy." ) ),
+ // TODO: resource
+ *this,
+ 1
+ );
+
+ if ( bHasSelection && m_bSourceSelectionBookmarks )
+ {
+ Reference< XRowLocate > xRowLocate( m_xSourceResultSet, UNO_QUERY );
+ if ( !xRowLocate.is() )
+ {
+ ::dbtools::throwGenericSQLException(
+ String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ),
+ *this
+ );
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference< XPropertySet >& _rxDataSourceDescriptor,
InteractionHandler& _out_rxDocInteractionHandler ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractConnection_throw" );
SharedConnection xConnection;
OSL_PRECOND( _rxDataSourceDescriptor.is(), "CopyTableWizard::impl_extractConnection_throw: no descriptor!" );
@@ -954,7 +974,6 @@ SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference<
//-------------------------------------------------------------------------
::utl::SharedUNOComponent< XPreparedStatement > CopyTableWizard::impl_createSourceStatement_throw() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_createSourceStatement_throw" );
OSL_PRECOND( m_xSourceConnection.is(), "CopyTableWizard::impl_createSourceStatement_throw: illegal call!" );
if ( !m_xSourceConnection.is() )
throw RuntimeException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) );
@@ -1059,7 +1078,6 @@ namespace
//-------------------------------------------------------------------------
bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _rEvent )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_processCopyError_nothrow" );
Reference< XCopyTableListener > xListener;
try
{
@@ -1138,7 +1156,6 @@ bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _r
void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSourceResultSet,
const Reference< XPropertySet >& _rxDestTable )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_copyRows_throw" );
OSL_PRECOND( m_xDestConnection.is(), "CopyTableWizard::impl_copyRows_throw: illegal call!" );
if ( !m_xDestConnection.is() )
throw RuntimeException( ::rtl::OUString(), *this );
@@ -1150,16 +1167,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
bool bAutoIncrement = rWizard.shouldCreatePrimaryKey();
Reference< XRow > xRow ( _rxSourceResultSet, UNO_QUERY_THROW );
- Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY );
-
- bool bSelectedRecordsOnly = m_aSourceSelection.getLength() > 0;
- if ( bSelectedRecordsOnly && m_bSourceSelectionBookmarks && !xRowLocate.is() )
- {
- ::dbtools::throwGenericSQLException(
- String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ),
- *this
- );
- }
+ Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY_THROW );
Reference< XResultSetMetaDataSupplier > xSuppResMeta( _rxSourceResultSet, UNO_QUERY_THROW );
Reference< XResultSetMetaData> xMeta( xSuppResMeta->getMetaData() );
@@ -1177,9 +1185,11 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
Reference< XPreparedStatement > xStatement( ODatabaseExport::createPreparedStatment( xDestMetaData, _rxDestTable, aColumnMapping ), UNO_SET_THROW );
Reference< XParameters > xStatementParams( xStatement, UNO_QUERY_THROW );
+ const bool bSelectedRecordsOnly = m_aSourceSelection.getLength() != 0;
+ const Any* pSelectedRow = m_aSourceSelection.getConstArray();
+ const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength();
+
sal_Int32 nRowCount = 0;
- const Any* pSelectedRow = m_aSourceSelection.getConstArray();
- const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength();
bool bContinue = false;
CopyTableRowEvent aCopyEvent;
@@ -1195,7 +1205,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
{
if ( m_bSourceSelectionBookmarks )
{
- xRowLocate->moveToBookmark( *pSelectedRow );
+ bContinue = xRowLocate->moveToBookmark( *pSelectedRow );
}
else
{
@@ -1355,7 +1365,6 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
//-------------------------------------------------------------------------
void CopyTableWizard::impl_doCopy_nothrow()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_doCopy_nothrow" );
Any aError;
try
@@ -1396,26 +1405,41 @@ void CopyTableWizard::impl_doCopy_nothrow()
}
}
- bool bServerCopy = CommandType::TABLE == m_nCommandType && m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() && !m_aSourceSelection.getLength();
- try
+ ::utl::SharedUNOComponent< XPreparedStatement > xSourceStatement;
+ ::utl::SharedUNOComponent< XResultSet > xSourceResultSet;
+
+ if ( m_xSourceResultSet.is() )
{
- if ( bServerCopy )
- {
- m_xDestConnection->createStatement()->executeUpdate( impl_getSelectStatement_nothrow(xTable) );
- }
+ xSourceResultSet.reset( m_xSourceResultSet, ::utl::SharedUNOComponent< XResultSet >::NoTakeOwnership );
}
- catch( const Exception& e )
+ else
{
- (void)e;
- bServerCopy = false;
+ const bool bIsSameConnection = ( m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() );
+ const bool bIsTable = ( CommandType::TABLE == m_nCommandType );
+ bool bDone = false;
+ if ( bIsSameConnection && bIsTable )
+ {
+ // try whether the server supports copying via SQL
+ try
+ {
+ m_xDestConnection->createStatement()->executeUpdate( impl_getServerSideCopyStatement_throw(xTable) );
+ bDone = true;
+ }
+ catch( const Exception& )
+ {
+ // this is allowed.
+ }
+ }
+
+ if ( !bDone )
+ {
+ xSourceStatement.set( impl_createSourceStatement_throw(), UNO_SET_THROW );
+ xSourceResultSet.set( xSourceStatement->executeQuery(), UNO_SET_THROW );
+ }
}
- if ( !bServerCopy )
- {
- ::utl::SharedUNOComponent< XPreparedStatement > xStatement( impl_createSourceStatement_throw(), UNO_SET_THROW );
- Reference< XResultSet > xSourceResultSet( xStatement->executeQuery() );
+ if ( xSourceResultSet.is() )
impl_copyRows_throw( xSourceResultSet, xTable );
- }
}
break;
@@ -1455,7 +1479,7 @@ void CopyTableWizard::impl_doCopy_nothrow()
}
}
// -----------------------------------------------------------------------------
-::rtl::OUString CopyTableWizard::impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable)
+::rtl::OUString CopyTableWizard::impl_getServerSideCopyStatement_throw(const Reference< XPropertySet >& _xTable)
{
const Reference<XColumnsSupplier> xDestColsSup(_xTable,UNO_QUERY_THROW);
const Sequence< ::rtl::OUString> aDestColumnNames = xDestColsSup->getColumns()->getElementNames();
@@ -1493,7 +1517,6 @@ void CopyTableWizard::impl_doCopy_nothrow()
//-------------------------------------------------------------------------
void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::initialize" );
::osl::MutexGuard aGuard( m_aMutex );
if ( isInitialized() )
throw AlreadyInitializedException( ::rtl::OUString(), *this );
@@ -1522,7 +1545,9 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments )
InteractionHandler xSourceDocHandler;
Reference< XPropertySet > xSourceDescriptor( impl_ensureDataAccessDescriptor_throw( _rArguments, 0, m_xSourceConnection, xSourceDocHandler ) );
+ impl_checkForUnsupportedSettings_throw( xSourceDescriptor );
m_pSourceObject = impl_extractSourceObject_throw( xSourceDescriptor, m_nCommandType );
+ impl_extractSourceResultSet_throw( xSourceDescriptor );
InteractionHandler xDestDocHandler;
impl_ensureDataAccessDescriptor_throw( _rArguments, 1, m_xDestConnection, xDestDocHandler );
@@ -1546,14 +1571,12 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments )
//-------------------------------------------------------------------------
::cppu::IPropertyArrayHelper& CopyTableWizard::getInfoHelper()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getInfoHelper" );
return *getArrayHelper();
}
//------------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* CopyTableWizard::createArrayHelper( ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createArrayHelper" );
Sequence< Property > aProps;
describeProperties( aProps );
return new ::cppu::OPropertyArrayHelper( aProps );
@@ -1562,7 +1585,6 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments )
//------------------------------------------------------------------------------
Dialog* CopyTableWizard::createDialog( Window* _pParent )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createDialog" );
OSL_PRECOND( isInitialized(), "CopyTableWizard::createDialog: not initialized!" );
// this should have been prevented in ::execute already
@@ -1585,7 +1607,6 @@ Dialog* CopyTableWizard::createDialog( Window* _pParent )
//------------------------------------------------------------------------------
void CopyTableWizard::executedDialog( sal_Int16 _nExecutionResult )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::executedDialog" );
CopyTableWizard_DialogBase::executedDialog( _nExecutionResult );
if ( _nExecutionResult == RET_OK )