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

Log:
 #i81658# in preparation of supporting SDBC-level source objects 
(DataAccessDescriptor::ConnectionResource), the wizard dialog has been 
re-worked to take an abstract ICopyTableSourceObject interface describing the 
to-be-copied object

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.7&r2=1.1.2.8
Delta lines:  +21 -37
---------------------
--- copytablewizard.cxx 2007-11-14 10:37:55+0000        1.1.2.7
+++ copytablewizard.cxx 2007-11-15 10:08:01+0000        1.1.2.8
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: copytablewizard.cxx,v $
  *
- *  $Revision: 1.1.2.7 $
+ *  $Revision: 1.1.2.8 $
  *
- *  last change: $Author: fs $ $Date: 2007/11/14 10:37:55 $
+ *  last change: $Author: fs $ $Date: 2007/11/15 10:08:01 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -65,6 +65,7 @@
 #include <com/sun/star/sdbcx/XRowLocate.hpp>
 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
 #include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/XDriverManager.hpp>
 /** === end UNO includes === **/
 
 #include <comphelper/componentcontext.hxx>
@@ -134,6 +135,7 @@
     using ::com::sun::star::sdbc::XResultSetMetaData;
     using ::com::sun::star::sdbc::SQLException;
     using ::com::sun::star::sdb::SQLContext;
+    using ::com::sun::star::sdbc::XDriverManager;
        /** === end UNO using === **/
     namespace CopyTableOperation = 
::com::sun::star::sdb::application::CopyTableOperation;
     namespace CopyTableContinuation = 
::com::sun::star::sdb::application::CopyTableContinuation;
@@ -190,7 +192,7 @@
 
     public:
         ::osl::Mutex&   getMutex() { return m_aMutex; }
-        bool            isInitialized() const { return 
m_xSourceConnection.is() && m_xSourceObject.is() && m_xDestConnection.is(); }
+        bool            isInitialized() const { return 
m_xSourceConnection.is() && m_pSourceObject.get() && m_xDestConnection.is(); }
 
     protected:
            CopyTableWizard( const Reference< XMultiServiceFactory >& _rxORB );
@@ -321,7 +323,8 @@
         // source
         SharedConnection                m_xSourceConnection;
         sal_Int32                       m_nCommandType;
-        Reference< XPropertySet >       m_xSourceObject;
+        ::std::auto_ptr< ICopyTableSourceObject >
+                                        m_pSourceObject;
         Sequence< Any >                 m_aSourceSelection;
         bool                            m_bSourceSelectionBookmarks;
 
@@ -367,7 +370,7 @@
         ,m_aPrimaryKeyName()
         ,m_xSourceConnection()
         ,m_nCommandType( CommandType::COMMAND )
-        ,m_xSourceObject()
+        ,m_pSourceObject()
         ,m_aSourceSelection()
         ,m_bSourceSelectionBookmarks( true )
         ,m_xDestConnection()
@@ -780,7 +783,13 @@
         if ( xPSI->hasPropertyByName( PROPERTY_CONNECTION_RESOURCE ) )
             OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( 
PROPERTY_CONNECTION_RESOURCE ) >>= sConnectionResource );
 
-        // TODO
+        Reference< XDriverManager > xDriverManager;
+        xDriverManager.set( m_aContext.createComponent( 
"com.sun.star.sdbc.ConnectionPool" ), UNO_QUERY );
+        if ( !xDriverManager.is() )
+            // no connection pool installed
+            xDriverManager.set( m_aContext.createComponent( 
"com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW );
+
+        xConnection.set( xDriverManager->getConnection( sConnectionResource ), 
UNO_SET_THROW );
         }
         while ( false );
 
@@ -802,40 +811,14 @@
         {
         case CommandType::TABLE:
         {
-            ::rtl::OUStringBuffer aSQL;
-            aSQL.appendAscii( "SELECT " );
-
-            // we need to create the sql stmt with column names
-            // otherwise it is possible that names don't match
-            Reference< XDatabaseMetaData > xSourceMeta( 
m_xSourceConnection->getMetaData(), UNO_SET_THROW );
-            const ::rtl::OUString sQuote = 
xSourceMeta->getIdentifierQuoteString();
-
-            Reference< XColumnsSupplier > xSuppCols( m_xSourceObject, 
UNO_QUERY_THROW );
-            Reference< XNameAccess > xColumns = xSuppCols->getColumns();
-
-            Sequence< ::rtl::OUString > aColumnNames = 
xColumns->getElementNames();
-            const ::rtl::OUString* pColumnName = aColumnNames.getConstArray();
-            const ::rtl::OUString* pEnd = pColumnName + 
aColumnNames.getLength();
-            for ( ; pColumnName != pEnd; )
-            {
-                aSQL.append( ::dbtools::quoteName( sQuote, *pColumnName++ ) );
-
-                if ( pColumnName == pEnd )
-                    aSQL.appendAscii( " " );
-                else
-                    aSQL.appendAscii( ", " );
-            }
-
-            aSQL.appendAscii( "FROM " );
-            aSQL.append( ::dbtools::composeTableNameForSelect( 
m_xSourceConnection, m_xSourceObject ) );
-            xStatement.set( m_xSourceConnection->prepareStatement( 
aSQL.makeStringAndClear() ), UNO_SET_THROW );
+            ::rtl::OUString sSQL( m_pSourceObject->getSelectStatement() );
+            xStatement.set( m_xSourceConnection->prepareStatement( sSQL ), 
UNO_SET_THROW );
         }
         break;
 
         case CommandType::QUERY:
         {
-            ::rtl::OUString sQueryCommand;
-            m_xSourceObject->getPropertyValue( PROPERTY_COMMAND ) >>= 
sQueryCommand;
+            ::rtl::OUString sQueryCommand( 
m_pSourceObject->getSelectStatement() );
             xStatement.set( m_xSourceConnection->prepareStatement( 
sQueryCommand ), UNO_SET_THROW );
 
             // check whether we have to fill in parameter values
@@ -1320,7 +1303,8 @@
 
             InteractionHandler xSourceDocHandler;
             Reference< XPropertySet > xSourceDescriptor( 
impl_ensureDataAccessDescriptor_throw( _rArguments, 0, m_xSourceConnection, 
xSourceDocHandler ) );
-            m_xSourceObject = impl_extractSourceObject_throw( 
xSourceDescriptor, m_nCommandType );
+            Reference< XPropertySet > xSourceObject( 
impl_extractSourceObject_throw( xSourceDescriptor, m_nCommandType ) );
+            m_pSourceObject.reset( new ObjectCopySource( m_xSourceConnection, 
xSourceObject ) );
 
             InteractionHandler xDestDocHandler;
             impl_ensureDataAccessDescriptor_throw( _rArguments, 1, 
m_xDestConnection, xDestDocHandler );
@@ -1365,7 +1349,7 @@
             _pParent,
             m_sDestinationTable,
             m_nOperation,
-            m_xSourceObject,
+            *m_pSourceObject,
             m_xSourceConnection.getTyped(),
             m_xDestConnection.getTyped(),
             m_aContext.getLegacyServiceFactory()




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

Reply via email to