Tag: cws_src680_dba24d
User: fs      
Date: 2007-11-19 09:49:12+0000
Modified:
   dba/dbaccess/source/ui/misc/WCopyTable.cxx

Log:
 #i81658# NamedTableCopySource: fill the field description from a 
ResultSetMetaData instance, this allows for more information (such as the 
auto-increment flag)

File Changes:

Directory: /dba/dbaccess/source/ui/misc/
========================================

File [changed]: WCopyTable.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/WCopyTable.cxx?r1=1.53.28.5&r2=1.53.28.6
Delta lines:  +77 -98
---------------------
--- WCopyTable.cxx      2007-11-18 12:48:20+0000        1.53.28.5
+++ WCopyTable.cxx      2007-11-19 09:49:10+0000        1.53.28.6
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: WCopyTable.cxx,v $
  *
- *  $Revision: 1.53.28.5 $
+ *  $Revision: 1.53.28.6 $
  *
- *  last change: $Author: fs $ $Date: 2007/11/18 12:48:20 $
+ *  last change: $Author: fs $ $Date: 2007/11/19 09:49:10 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -36,100 +36,45 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_dbaccess.hxx"
 
-#include "WNameMatch.hxx"
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+#include "sqlmessage.hxx"
+#include "UITools.hxx"
 #include "WColumnSelect.hxx"
+#include "WCopyTable.hxx"
+#include "WCPage.hxx"
 #include "WExtendPages.hxx"
+#include "WizardPages.hrc"
+#include "WNameMatch.hxx"
+#include "WTypeSelect.hxx"
 
-#ifndef _TOOLS_DEBUG_HXX
-#include <tools/debug.hxx>
-#endif
-#ifndef TOOLS_DIAGNOSE_EX_H
-#include <tools/diagnose_ex.h>
-#endif
-#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
+/** === begin UNO includes === **/
 #include <com/sun/star/sdb/application/CopyTableOperation.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
-#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
-#include <com/sun/star/sdbcx/XAppend.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
-#include <com/sun/star/sdbc/DataType.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
-#include <com/sun/star/sdbcx/KeyType.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
 #include <com/sun/star/sdbc/ColumnValue.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
 #include <com/sun/star/sdbc/XResultSet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
 #include <com/sun/star/sdbc/XRow.hpp>
-#endif
-#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
-#include "dbustrings.hrc"
-#endif
-#ifndef _SV_MSGBOX_HXX 
-#include <vcl/msgbox.hxx>
-#endif
-#ifndef _SV_LSTBOX_HXX
-#include <vcl/lstbox.hxx>
-#endif
-#ifndef _DBU_MISC_HRC_
-#include "dbu_misc.hrc"
-#endif
-#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
-#include "WCopyTable.hxx"
-#endif
-#ifndef DBAUI_WIZARD_PAGES_HRC
-#include "WizardPages.hrc"
-#endif
-#ifndef _COMPHELPER_TYPES_HXX_
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
 #include <comphelper/types.hxx>
-#endif
-#ifndef _DBAUI_MODULE_DBU_HXX_
-#include "moduledbu.hxx"
-#endif
-#ifndef _CONNECTIVITY_DBTOOLS_HXX_
 #include <connectivity/dbtools.hxx>
-#endif
-#ifndef _COMPHELPER_EXTRACT_HXX_
-#include <comphelper/extract.hxx>
-#endif
-#ifndef DBAUI_TOOLS_HXX
-#include "UITools.hxx"
-#endif
-#ifndef DBAUI_WIZARD_CPAGE_HXX
-#include "WCPage.hxx"
-#endif
-#ifndef _SV_WAITOBJ_HXX
-#include <vcl/waitobj.hxx>
-#endif
-#ifndef DBAUI_WIZ_TYPESELECT_HXX
-#include "WTypeSelect.hxx"
-#endif
-#ifndef _DBAUI_SQLMESSAGE_HXX_
-#include "sqlmessage.hxx"
-#endif
-#ifndef _RTL_USTRBUF_HXX_
+
 #include <rtl/ustrbuf.hxx>
-#endif
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/lstbox.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
 
 #include <functional>
 
@@ -298,6 +243,16 @@
     return sSelectStatement;
 }
 
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > 
ObjectCopySource::getPreparedSelectStatement() const
+{
+    ::utl::SharedUNOComponent< XPreparedStatement > xStatement(
+        m_xConnection->prepareStatement( getSelectStatement() ),
+        ::utl::SharedUNOComponent< XPreparedStatement >::TakeOwnership
+    );
+    return xStatement;
+}
+
 //========================================================================
 //= NamedTableCopySource
 //========================================================================
@@ -351,22 +306,23 @@
 
     try
     {
-        Reference< XResultSet > xColumnDesc( m_xMetaData->getColumns( makeAny( 
m_sTableCatalog ), m_sTableSchema, m_sTableBareName,
-            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "%" ) ) ), 
UNO_SET_THROW );
+        Reference< XResultSetMetaDataSupplier > xStatementMetaSupp( 
impl_ensureStatement_throw().getTyped(), UNO_QUERY_THROW );
+        Reference< XResultSetMetaData > xStatementMeta( 
xStatementMetaSupp->getMetaData(), UNO_SET_THROW );
 
-        Reference< XRow > xDescRow( xColumnDesc, UNO_QUERY_THROW );
-        while ( xColumnDesc->next() )
+        sal_Int32 nColCount( xStatementMeta->getColumnCount() );
+        for ( sal_Int32 i = 1; i <= nColCount; ++i )
         {
             OFieldDescription aDesc;
-            aDesc.SetName(          xDescRow->getString(  4 ) );    // 
COLUMN_NAME
-            aDesc.SetDescription(   xDescRow->getString( 12 ) );    // REMARKS
-            aDesc.SetTypeValue(     xDescRow->getInt   (  5 ) );    // 
DATA_TYPE
-            aDesc.SetTypeName(      xDescRow->getString(  6 ) );    // 
TYPE_NAME
-            aDesc.SetPrecision(     xDescRow->getInt   (  7 ) );    // 
COLUMN_SIZE
-            aDesc.SetScale(         xDescRow->getInt   (  9 ) );    // 
DECIMAL_DIGITS
-            aDesc.SetIsNullable(    xDescRow->getInt   ( 11 ) );    // NULLABLE
 
-            aDesc.SetDefaultValue(  makeAny( xDescRow->getString( 13 ) ) );    
// COLUMN_DEF
+            aDesc.SetName(          xStatementMeta->getColumnName(      i ) );
+            aDesc.SetDescription(   xStatementMeta->getColumnLabel(     i ) );
+            aDesc.SetTypeValue(     xStatementMeta->getColumnType(      i ) );
+            aDesc.SetTypeName(      xStatementMeta->getColumnTypeName(  i ) );
+            aDesc.SetPrecision(     xStatementMeta->getPrecision(       i ) );
+            aDesc.SetScale(         xStatementMeta->getScale(           i ) );
+            aDesc.SetIsNullable(    xStatementMeta->isNullable(         i ) );
+            aDesc.SetCurrency(      xStatementMeta->isCurrency(         i ) );
+            aDesc.SetAutoIncrement( xStatementMeta->isAutoIncrement(    i ) );
 
             m_aColumnInfo[ aDesc.GetName() ] = aDesc;
         }
@@ -378,6 +334,14 @@
 }
 
 //------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > 
NamedTableCopySource::impl_ensureStatement_throw()
+{
+    if ( !m_xStatement.is() )
+        m_xStatement.set( m_xConnection->prepareStatement( 
getSelectStatement() ), UNO_SET_THROW );
+    return m_xStatement;
+}
+
+//------------------------------------------------------------------------
 Sequence< ::rtl::OUString > NamedTableCopySource::getColumnNames() const
 {
     const_cast< NamedTableCopySource* >( this 
)->impl_ensureColumnInfo_nothrow();
@@ -440,6 +404,12 @@
     return aSQL.makeStringAndClear();
 }
 
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > 
NamedTableCopySource::getPreparedSelectStatement() const
+{
+    return const_cast< NamedTableCopySource* >( this 
)->impl_ensureStatement_throw();
+}
+
 // ========================================================
 // DummyCopySource
 // ========================================================
@@ -460,6 +430,8 @@
                                 getPrimaryKeyColumnNames() const;
     virtual OFieldDescription*  createFieldDescription( const ::rtl::OUString& 
_rColumnName ) const;
     virtual ::rtl::OUString     getSelectStatement() const;
+    virtual ::utl::SharedUNOComponent< XPreparedStatement >
+                                getPreparedSelectStatement() const;
 };
 
 //------------------------------------------------------------------------
@@ -517,6 +489,13 @@
 }
 
 //------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > 
DummyCopySource::getPreparedSelectStatement() const
+{
+    OSL_ENSURE( false, "DummyCopySource::getPreparedSelectStatement: not to be 
called!" );
+    return ::utl::SharedUNOComponent< XPreparedStatement >();
+}
+
+//------------------------------------------------------------------------
 namespace
 {
     bool lcl_canCreateViewFor_nothrow( const Reference< XConnection >& 
_rxConnection )




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

Reply via email to