Tag: cws_src680_dba24d
User: fs      
Date: 2007-11-15 15:17:53+0000
Modified:
   dba/dbaccess/source/ui/uno/copytablewizard.cxx

Log:
 #i81658# also allow to copy a table from an SDBC level connection

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.8&r2=1.1.2.9
Delta lines:  +34 -11
---------------------
--- copytablewizard.cxx 2007-11-15 10:08:01+0000        1.1.2.8
+++ copytablewizard.cxx 2007-11-15 15:17:51+0000        1.1.2.9
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: copytablewizard.cxx,v $
  *
- *  $Revision: 1.1.2.8 $
+ *  $Revision: 1.1.2.9 $
  *
- *  last change: $Author: fs $ $Date: 2007/11/15 10:08:01 $
+ *  last change: $Author: fs $ $Date: 2007/11/15 15:17:51 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -250,7 +250,7 @@
         /** extracts the source object (table or query) described by the given 
descriptor,
             relative to m_xSourceConnection
         */
-        Reference< XPropertySet >
+        ::std::auto_ptr< ICopyTableSourceObject >
                 impl_extractSourceObject_throw(
                     const Reference< XPropertySet >& _rxDescriptor,
                     sal_Int32& _out_rCommandType
@@ -665,7 +665,7 @@
     }
 
     //-------------------------------------------------------------------------
-    Reference< XPropertySet > CopyTableWizard::impl_extractSourceObject_throw( 
const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) 
const
+    ::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!" );
 
@@ -684,18 +684,21 @@
         OSL_VERIFY( _rxDescriptor->getPropertyValue( PROPERTY_COMMAND ) >>= 
sCommand );
         OSL_VERIFY( _rxDescriptor->getPropertyValue( PROPERTY_COMMAND_TYPE ) 
>>= _out_rCommandType );
 
+        ::std::auto_ptr< ICopyTableSourceObject > pSourceObject;
         Reference< XNameAccess > xContainer;
         switch ( _out_rCommandType )
         {
         case CommandType::TABLE:
         {
-            Reference< XTablesSupplier > xSuppTables( 
m_xSourceConnection.getTyped(), UNO_QUERY_THROW );
+            Reference< XTablesSupplier > xSuppTables( 
m_xSourceConnection.getTyped(), UNO_QUERY );
+            if ( xSuppTables.is() )
             xContainer.set( xSuppTables->getTables(), UNO_SET_THROW );
         }
         break;
         case CommandType::QUERY:
         {
-            Reference< XQueriesSupplier > xSuppQueries( 
m_xSourceConnection.getTyped(), UNO_QUERY_THROW );
+            Reference< XQueriesSupplier > xSuppQueries( 
m_xSourceConnection.getTyped(), UNO_QUERY );
+            if ( xSuppQueries.is() )
             xContainer.set( xSuppQueries->getQueries(), UNO_SET_THROW );
         }
         break;
@@ -708,7 +711,28 @@
             );
         }
 
-        return Reference< XPropertySet >( xContainer->getByName( sCommand ), 
UNO_QUERY_THROW );
+        if ( xContainer.is() )
+        {
+            pSourceObject.reset( new ObjectCopySource( m_xSourceConnection,
+                Reference< XPropertySet >( xContainer->getByName( sCommand ), 
UNO_QUERY_THROW ) ) );
+        }
+        else
+        {
+            // our source connection is an SDBC level connection only, not a 
SDBCX level one
+            // Which means it cannot provide the to-be-copied object as 
component.
+
+            if ( _out_rCommandType == CommandType::QUERY )
+                // we cannot copy a query if the connection cannot provide it 
...
+                throw IllegalArgumentException(
+                    ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "To copy a 
query, your connection must be able to provide queries." ) ),
+                    // TODO: resource
+                    *const_cast< CopyTableWizard* >( this ),
+                    1
+                );
+            pSourceObject.reset( new NamedTableCopySource( 
m_xSourceConnection, sCommand ) );
+        }
+
+        return pSourceObject;
     }
 
     //-------------------------------------------------------------------------
@@ -1303,8 +1327,7 @@
 
             InteractionHandler xSourceDocHandler;
             Reference< XPropertySet > xSourceDescriptor( 
impl_ensureDataAccessDescriptor_throw( _rArguments, 0, m_xSourceConnection, 
xSourceDocHandler ) );
-            Reference< XPropertySet > xSourceObject( 
impl_extractSourceObject_throw( xSourceDescriptor, m_nCommandType ) );
-            m_pSourceObject.reset( new ObjectCopySource( m_xSourceConnection, 
xSourceObject ) );
+            m_pSourceObject = impl_extractSourceObject_throw( 
xSourceDescriptor, m_nCommandType );
 
             InteractionHandler xDestDocHandler;
             impl_ensureDataAccessDescriptor_throw( _rArguments, 1, 
m_xDestConnection, xDestDocHandler );




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to