Tag: cws_src680_oj17
User: oj      
Date: 06/03/08 23:47:19

Modified:
 /dba/dbaccess/source/ui/inc/
  DExport.hxx, TokenWriter.hxx, TypeInfo.hxx, WCPage.hxx, WCopyTable.hxx,
  dbu_resource.hrc, dbu_tbl.hrc
 /dba/dbaccess/source/ui/misc/
  DExport.cxx, HtmlReader.cxx, RowSetDrop.cxx, RtfReader.cxx,
  TableCopyHelper.cxx, WColumnSelect.cxx, WCopyTable.cxx

Log:
 #i62561# use a prepared statement when the rowset can not be used for insertion

File Changes:

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

File [changed]: DExport.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/DExport.hxx?r1=1.14&r2=1.14.40.1
Delta lines:  +20 -15
---------------------
--- DExport.hxx 19 Jan 2006 15:42:16 -0000      1.14
+++ DExport.hxx 9 Mar 2006 07:47:13 -0000       1.14.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: DExport.hxx,v $
  *
- *  $Revision: 1.14 $
+ *  $Revision: 1.14.40.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/19 15:42:16 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:13 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -41,12 +41,6 @@
 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
 #endif
-#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
-#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_
-#include <com/sun/star/sdbc/XRowUpdate.hpp>
-#endif
 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
 #include <com/sun/star/beans/XPropertySet.hpp>
 #endif
@@ -78,11 +72,19 @@
 #ifndef _DBAUI_COMMON_TYPES_HXX_
 #include "commontypes.hxx"
 #endif
+#ifndef DBAUI_IUPDATEHELPER_HXX
+#include "IUpdateHelper.hxx"
+#endif
 
-namespace com { namespace sun { namespace star { namespace awt
-{
+namespace com { namespace sun { namespace star { 
+    namespace awt{
        struct FontDescriptor;
-}}}}
+    }
+    namespace sdbc{
+           class XPreparedStatement;
+        class XDatabaseMetaData;
+    }
+}}}
 
 class Window;
 namespace dbaui
@@ -111,10 +113,9 @@
                ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess>             m_xTables;              
// container
                SharedConnection                                                
                m_xConnection;  // dest conn
                
+        ::boost::shared_ptr<IUpdateHelper>                                     
         m_pUpdateHelper;
                ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XResultSet >                  m_xResultSet;   // 
-               ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XResultSetUpdate >    m_xResultSetUpdate;     // 
                ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XResultSetMetaData >  m_xResultSetMetaData;   // 
-               ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XRowUpdate >                  m_xRowUpdate;   // 
                ::com::sun::star::uno::Reference< 
::com::sun::star::util::XNumberFormatter >    m_xFormatter;   // a number 
formatter working with the connection's NumberFormatsSupplier
                ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
                
@@ -177,6 +178,10 @@
 
                void enableCheckOnly() { m_bCheckOnly = sal_True; }
                sal_Bool isCheckEnabled() const { return m_bCheckOnly; }
+
+        static ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XPreparedStatement > createPreparedStatment( const 
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& 
_xMetaData
+                                                       ,const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& 
_xDestTable
+                                                       ,const TPositions& 
_rvColumns);
        };
 }
 

File [changed]: TokenWriter.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/TokenWriter.hxx?r1=1.15&r2=1.15.96.1
Delta lines:  +9 -3
-------------------
--- TokenWriter.hxx     23 Sep 2005 12:34:12 -0000      1.15
+++ TokenWriter.hxx     9 Mar 2006 07:47:14 -0000       1.15.96.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TokenWriter.hxx,v $
  *
- *  $Revision: 1.15 $
+ *  $Revision: 1.15.96.1 $
  *
- *  last change: $Author: hr $ $Date: 2005/09/23 12:34:12 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:14 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -81,6 +81,12 @@
 #include "commontypes.hxx"
 #endif
 #include <memory>
+
+namespace com { namespace sun { namespace star { 
+    namespace sdbc{
+           class XRowUpdate;
+    }
+}}}
 
 namespace dbaui
 {

File [changed]: TypeInfo.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/TypeInfo.hxx?r1=1.7&r2=1.7.100.1
Delta lines:  +4 -4
-------------------
--- TypeInfo.hxx        8 Sep 2005 15:40:27 -0000       1.7
+++ TypeInfo.hxx        9 Mar 2006 07:47:14 -0000       1.7.100.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TypeInfo.hxx,v $
  *
- *  $Revision: 1.7 $
+ *  $Revision: 1.7.100.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/09/08 15:40:27 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:14 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -101,11 +101,11 @@
                                                
                sal_Int32               nPrecision;             // Laenge des 
Types
                sal_Int32               nNumPrecRadix;  // indicating the 
radix, which is usually 2 or 10
+        sal_Int32              nType;                  // Datenbanktyp
                
                sal_Int16               nMaximumScale;  // Nachkommastellen
                sal_Int16               nMinimumScale;  // Min Nachkommastellen
                                                
-               sal_Int16               nType;                  // Datenbanktyp
                sal_Int16               nSearchType;    // kann nach dem Typen 
gesucht werden
                
                                                

File [changed]: WCPage.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/WCPage.hxx?r1=1.5&r2=1.5.102.1
Delta lines:  +4 -4
-------------------
--- WCPage.hxx  8 Sep 2005 15:41:45 -0000       1.5
+++ WCPage.hxx  9 Mar 2006 07:47:14 -0000       1.5.102.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: WCPage.hxx,v $
  *
- *  $Revision: 1.5 $
+ *  $Revision: 1.5.102.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/09/08 15:41:45 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:14 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -106,7 +106,7 @@
                inline BOOL IsOptionDef()                       const { return 
m_aRB_Def.IsChecked(); }
                inline BOOL IsOptionAppendData()        const { return 
m_aRB_AppendData.IsChecked(); }
                inline BOOL IsOptionView()                      const { return 
m_aRB_View.IsChecked(); }
-
+        String      GetKeyName()            const { return 
m_edKeyName.GetText(); }
        };
 }
 #endif // DBAUI_WIZARD_CPAGE_HXX

File [changed]: WCopyTable.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/WCopyTable.hxx?r1=1.19&r2=1.19.40.1
Delta lines:  +5 -3
-------------------
--- WCopyTable.hxx      19 Jan 2006 15:42:49 -0000      1.19
+++ WCopyTable.hxx      9 Mar 2006 07:47:14 -0000       1.19.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: WCopyTable.hxx,v $
  *
- *  $Revision: 1.19 $
+ *  $Revision: 1.19.40.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/19 15:42:49 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:14 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -320,6 +320,8 @@
 
                // displays a error message that a column type is not supported
                void showColumnTypeNotSupported(const ::rtl::OUString& 
_rColumnName);
+
+        void removeColumnNameFromNameMap(const ::rtl::OUString& _sName);
        };
 }
 

File [changed]: dbu_resource.hrc
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/dbu_resource.hrc?r1=1.92&r2=1.92.102.1
Delta lines:  +5 -3
-------------------
--- dbu_resource.hrc    8 Sep 2005 15:50:25 -0000       1.92
+++ dbu_resource.hrc    9 Mar 2006 07:47:15 -0000       1.92.102.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: dbu_resource.hrc,v $
  *
- *  $Revision: 1.92 $
+ *  $Revision: 1.92.102.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/09/08 15:50:25 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:15 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -381,6 +381,8 @@
 #define STR_FRM_LABEL                                          
RID_STR_GEN_START + 34
 #define STR_RPT_LABEL                                          
RID_STR_GEN_START + 35
 #define STR_FOLDER_LABEL                                       
RID_STR_GEN_START + 36
+#define STR_TABLEDESIGN_NO_PRIM_KEY_HEAD       RID_STR_GEN_START + 37
+#define STR_TABLEDESIGN_NO_PRIM_KEY                    RID_STR_GEN_START + 38
 
 
 //========================================================================

File [changed]: dbu_tbl.hrc
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/dbu_tbl.hrc?r1=1.5&r2=1.5.102.1
Delta lines:  +5 -5
-------------------
--- dbu_tbl.hrc 8 Sep 2005 15:50:48 -0000       1.5
+++ dbu_tbl.hrc 9 Mar 2006 07:47:15 -0000       1.5.102.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: dbu_tbl.hrc,v $
  *
- *  $Revision: 1.5 $
+ *  $Revision: 1.5.102.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/09/08 15:50:48 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:15 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -78,14 +78,14 @@
 #define STR_FIELD_REQUIRED                                     
RID_STR_TBL_START + 36
 #define STR_DEFAULT_VALUE                                      
RID_STR_TBL_START + 37
 #define STR_TABED_UNDO_CELLMODIFIED                    RID_STR_TBL_START + 38
-#define STR_TABLEDESIGN_NO_PRIM_KEY                    RID_STR_TBL_START + 39
+// empty
 #define STR_TBL_COLUMN_IS_KEYCOLUMN                    RID_STR_TBL_START + 40
 #define STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE      RID_STR_TBL_START + 41
 #define STR_TABLEDESIGN_ALTER_ERROR                    RID_STR_TBL_START + 42
 #define STR_AUTOINCREMENT_VALUE                                
RID_STR_TBL_START + 43
 #define STR_HELP_FORMAT_BUTTON                         RID_STR_TBL_START + 44
 #define STR_TABLEDESIGN_CONNECTION_MISSING     RID_STR_TBL_START + 45
-#define STR_TABLEDESIGN_NO_PRIM_KEY_HEAD       RID_STR_TBL_START + 46
+// empty
 #define STR_TABLEDESIGN_TITLE                          RID_STR_TBL_START + 47
 #define STR_NO_TYPE_INFO_AVAILABLE                     RID_STR_TBL_START + 48
 #define STR_CHANGE_COLUMN_NAME              RID_STR_TBL_START + 49

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

File [changed]: DExport.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/DExport.cxx?r1=1.28&r2=1.28.38.1
Delta lines:  +82 -15
---------------------
--- DExport.cxx 19 Jan 2006 15:43:05 -0000      1.28
+++ DExport.cxx 9 Mar 2006 07:47:15 -0000       1.28.38.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: DExport.cxx,v $
  *
- *  $Revision: 1.28 $
+ *  $Revision: 1.28.38.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/19 15:43:05 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:15 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -59,9 +59,6 @@
 #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
 #include <com/sun/star/sdb/CommandType.hpp>
 #endif
-#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
-#include <com/sun/star/sdbc/XRowSet.hpp>
-#endif
 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
 #endif
@@ -144,6 +141,9 @@
 #ifndef _DBAUI_SQLMESSAGE_HXX_
 #include "sqlmessage.hxx"
 #endif
+#ifndef DBAUI_UPDATEHELPERIMPL_HXX
+#include "UpdateHelperImpl.hxx"
+#endif
 #ifndef _SV_MSGBOX_HXX
 #include <vcl/msgbox.hxx>
 #endif
@@ -384,7 +384,7 @@
 //                                             
m_pNF->ChangeIntl((LanguageType)m_nDefToken);
 
                                if(!m_sTextToken.Len() && 
m_xResultSetMetaData->isNullable(nPos))
-                                       m_xRowUpdate->updateNull(nPos);
+                    m_pUpdateHelper->updateNull(nPos,pField->GetType());
                                else
                                {
                                        sal_Int32 nNumberFormat = 0;
@@ -425,16 +425,16 @@
                                                try
                                                {
                                                        fOutNumber = 
m_xFormatter->convertStringToNumber(nNumberFormat,m_sTextToken);
-                                                       
m_xRowUpdate->updateDouble(nPos,::dbtools::DBTypeConversion::toStandardDbDate(::dbtools::DBTypeConversion::getStandardDate(),fOutNumber));
+                                                       
m_pUpdateHelper->updateDouble(nPos,::dbtools::DBTypeConversion::toStandardDbDate(::dbtools::DBTypeConversion::getStandardDate(),fOutNumber));
                                                }
                                                catch(Exception&)
                                                {
-                                                       
m_xRowUpdate->updateString(nPos,m_sTextToken);
+                                                   
m_pUpdateHelper->updateString(nPos,m_sTextToken);
                                                }
 
                                        }
                                        else
-                                               
m_xRowUpdate->updateString(nPos,m_sTextToken);
+                                               
m_pUpdateHelper->updateString(nPos,m_sTextToken);
                                }
                        }
                        m_sTextToken.Erase();
@@ -699,14 +699,20 @@
                
xProp->setPropertyValue(PROPERTY_IGNORERESULT,::cppu::bool2any(sal_True));
                Reference<XRowSet> xRowSet(xProp,UNO_QUERY);
                xRowSet->execute();
-               Reference< XResultSetMetaDataSupplier> 
xSrcMetaSup(xRowSet,UNO_QUERY);
+
+        Reference< XResultSetMetaDataSupplier> 
xSrcMetaSup(xRowSet,UNO_QUERY_THROW);
                m_xResultSetMetaData = xSrcMetaSup->getMetaData();
+
+        if ( ::dbtools::canInsert(xProp) )
+        {
+            m_pUpdateHelper.reset(new ORowUpdateHelper(xRowSet));
                OSL_ENSURE(m_xResultSetMetaData.is(),"No ResultSetMetaData!");
        }
-       m_xResultSetUpdate.set(xDestSet,UNO_QUERY);
-       m_xRowUpdate.set(xDestSet,UNO_QUERY);
+        else
+            m_pUpdateHelper.reset(new 
OParameterUpdateHelper(createPreparedStatment(m_xConnection->getMetaData(),m_xTable,m_vColumns)));
+       }
 
-       return m_xResultSetUpdate.is() && m_xRowUpdate.is() && 
m_xResultSetMetaData.is();
+       return m_pUpdateHelper.get() != NULL;
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool ODatabaseExport::executeWizard(const ::rtl::OUString& 
_sTableName,const Any& _aTextColor,const FontDescriptor& _rFont)
@@ -802,6 +808,67 @@
                else
                        m_bError = TRUE;
        } // if(!m_bDontAskAgain)
+}
+// 
-----------------------------------------------------------------------------
+Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const 
Reference<XDatabaseMetaData>& _xMetaData
+                                                       ,const 
Reference<XPropertySet>& _xDestTable
+                                                       ,const TPositions& 
_rvColumns)
+{
+    ::rtl::OUString aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT 
INTO ")));
+       ::rtl::OUString sComposedTableName = 
::dbtools::composeTableName(_xMetaData,_xDestTable,sal_True,::dbtools::eInDataManipulation);
+
+       aSql += sComposedTableName;
+       aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ( "));
+       // set values and column names
+       ::rtl::OUString aValues(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( "));
+       static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,"));
+       static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(","));
+
+       ::rtl::OUString aQuote;
+       if ( _xMetaData.is() )
+               aQuote = _xMetaData->getIdentifierQuoteString();
+
+       Reference<XColumnsSupplier> xDestColsSup(_xDestTable,UNO_QUERY_THROW);
+
+       // create sql string and set column types
+       Sequence< ::rtl::OUString> aDestColumnNames = 
xDestColsSup->getColumns()->getElementNames();
+    if ( aDestColumnNames.getLength() == 0 )
+    {
+        return Reference< XPreparedStatement > ();
+    }
+       const ::rtl::OUString* pIter = aDestColumnNames.getConstArray();
+       const ::rtl::OUString* pEnd       = pIter + 
aDestColumnNames.getLength();
+       ::std::vector< ::rtl::OUString> aInsertList;
+       aInsertList.resize(aDestColumnNames.getLength()+1);
+       sal_Int32 i = 0;
+       for(sal_uInt32 j=0; j < aInsertList.size() ;++i,++j)
+       {
+               ODatabaseExport::TPositions::const_iterator aFind = 
::std::find_if(_rvColumns.begin(),_rvColumns.end(),
+                       
::std::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),i+1),::std::select2nd<ODatabaseExport::TPositions::value_type>()));
+               if ( _rvColumns.end() != aFind && aFind->second != 
CONTAINER_ENTRY_NOTFOUND && aFind->first != CONTAINER_ENTRY_NOTFOUND )
+               {
+                       aInsertList[aFind->first] = ::dbtools::quoteName( 
aQuote,*(pIter+i));
+               }
+       }
+
+       i = 1;
+       // create the sql string
+       for (::std::vector< ::rtl::OUString>::iterator aInsertIter = 
aInsertList.begin(); aInsertIter != aInsertList.end(); ++aInsertIter)
+       {
+               if ( aInsertIter->getLength() )
+               {
+                       aSql += *aInsertIter;
+                       aSql += aComma;
+                       aValues += aPara;
+               }
+       }
+
+       aSql = 
aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+       aValues = 
aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+
+       aSql += aValues;
+       // now create,fill and execute the prepared statement
+       return Reference< XPreparedStatement 
>(_xMetaData->getConnection()->prepareStatement(aSql));
 }
 // 
-----------------------------------------------------------------------------
 

File [changed]: HtmlReader.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/HtmlReader.cxx?r1=1.22&r2=1.22.40.1
Delta lines:  +8 -8
-------------------
--- HtmlReader.cxx      19 Jan 2006 15:43:23 -0000      1.22
+++ HtmlReader.cxx      9 Mar 2006 07:47:15 -0000       1.22.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: HtmlReader.cxx,v $
  *
- *  $Revision: 1.22 $
+ *  $Revision: 1.22.40.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/19 15:43:23 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:15 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -307,11 +307,11 @@
                                }
                                break;
                        case HTML_TABLEROW_ON:
-                               if ( m_xResultSetUpdate.is() )
+                               if ( m_pUpdateHelper.get() )
                                {
                                        try
                                        {
-                                               
m_xResultSetUpdate->moveToInsertRow(); // sonst neue Zeile anh"angen
+                                               
m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
                                        }
                                        catch(SQLException& e)
                                        // UpdateFehlerbehandlung
@@ -370,7 +370,7 @@
                                }
                                break;
                        case HTML_TABLEROW_OFF:
-                               if ( !m_xResultSetUpdate.is() )
+                               if ( !m_pUpdateHelper.get() )
                                {
                                        m_bError = sal_True;
                                        break;
@@ -379,8 +379,8 @@
                                {
                                        m_nRowCount++;
                                        if (m_bIsAutoIncrement) // if 
bSetAutoIncrement then I have to set the autoincrement
-                                               
m_xRowUpdate->updateInt(1,m_nRowCount);
-                                       m_xResultSetUpdate->insertRow();
+                                               
m_pUpdateHelper->updateInt(1,m_nRowCount);
+                                       m_pUpdateHelper->insertRow();
                                }
                                catch(SQLException& e)
                                
//////////////////////////////////////////////////////////////////////

File [changed]: RowSetDrop.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/RowSetDrop.cxx?r1=1.10&r2=1.10.96.1
Delta lines:  +7 -5
-------------------
--- RowSetDrop.cxx      23 Sep 2005 12:37:02 -0000      1.10
+++ RowSetDrop.cxx      9 Mar 2006 07:47:16 -0000       1.10.96.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: RowSetDrop.cxx,v $
  *
- *  $Revision: 1.10 $
+ *  $Revision: 1.10.96.1 $
  *
- *  last change: $Author: hr $ $Date: 2005/09/23 12:37:02 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -54,7 +54,9 @@
 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
 #include "dbustrings.hrc"
 #endif
-
+#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#endif
 #include <functional>
 
 using namespace dbaui;

File [changed]: RtfReader.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/RtfReader.cxx?r1=1.18&r2=1.18.40.1
Delta lines:  +6 -6
-------------------
--- RtfReader.cxx       19 Jan 2006 15:43:40 -0000      1.18
+++ RtfReader.cxx       9 Mar 2006 07:47:16 -0000       1.18.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: RtfReader.cxx,v $
  *
- *  $Revision: 1.18 $
+ *  $Revision: 1.18.40.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/19 15:43:40 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -220,7 +220,7 @@
                                {
                                        try
                                        {
-                                               
m_xResultSetUpdate->moveToInsertRow(); // sonst neue Zeile anh"angen
+                                               
m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
                                        }
                                        catch(SQLException& e)
                                        // UpdateFehlerbehandlung
@@ -261,8 +261,8 @@
                                        insertValueIntoColumn();
                                        m_nRowCount++;
                                        if(m_bIsAutoIncrement) // if 
bSetAutoIncrement then I have to set the autoincrement
-                                               
m_xRowUpdate->updateInt(1,m_nRowCount);
-                                       m_xResultSetUpdate->insertRow();
+                                               
m_pUpdateHelper->updateInt(1,m_nRowCount);
+                                       m_pUpdateHelper->insertRow();
                                }
                                catch(SQLException& e)
                                
//////////////////////////////////////////////////////////////////////

File [changed]: TableCopyHelper.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/TableCopyHelper.cxx?r1=1.5&r2=1.5.42.1
Delta lines:  +5 -43
--------------------
--- TableCopyHelper.cxx 16 Jan 2006 15:29:20 -0000      1.5
+++ TableCopyHelper.cxx 9 Mar 2006 07:47:16 -0000       1.5.42.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TableCopyHelper.cxx,v $
  *
- *  $Revision: 1.5 $
+ *  $Revision: 1.5.42.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/16 15:29:20 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -211,49 +211,10 @@
        for(sal_Int32 k=1;k <= nCount;++k)
                aColumnTypes.push_back(xMeta->getColumnType(k));
 
-       // create sql string and set column types
-       Reference<XNameAccess> xNameAccess = xColsSup->getColumns();
-       Sequence< ::rtl::OUString> aSeq = xNameAccess->getElementNames();
-    if ( aSeq.getLength() == 0 )
-    {
-        return;
-    }
-       const ::rtl::OUString* pBegin = aSeq.getConstArray();
-       const ::rtl::OUString* pEnd       = pBegin + aSeq.getLength();
-       ::std::vector< ::rtl::OUString> aInsertList;
-       aInsertList.resize(aSeq.getLength()+1);
-       sal_Int32 i = 0;
-       for(sal_uInt32 j=0; j < aInsertList.size() ;++i,++j)
-       {
-               ODatabaseExport::TPositions::const_iterator aFind = 
::std::find_if(_rvColumns.begin(),_rvColumns.end(),
-                       
::std::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),i+1),::std::select2nd<ODatabaseExport::TPositions::value_type>()));
-               if ( _rvColumns.end() != aFind && aFind->second != 
CONTAINER_ENTRY_NOTFOUND && aFind->first != CONTAINER_ENTRY_NOTFOUND )
-               {
-                       aInsertList[aFind->first] = ::dbtools::quoteName( 
aQuote,*(pBegin+i));
-               }
-       }
-
-       i = 1;
-       // create the sql string
-       for (::std::vector< ::rtl::OUString>::iterator aInsertIter = 
aInsertList.begin(); aInsertIter != aInsertList.end(); ++aInsertIter)
-       {
-               if ( aInsertIter->getLength() )
-               {
-                       aSql += *aInsertIter;
-                       aSql += aComma;
-                       aValues += aPara;
-               }
-       }
-
-       aSql = 
aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
-       aValues = 
aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
-
-       aSql += aValues;
        // now create,fill and execute the prepared statement
-       Reference< XPreparedStatement > 
xPrep(_xMetaData->getConnection()->prepareStatement(aSql));
+    Reference< XPreparedStatement > 
xPrep(ODatabaseExport::createPreparedStatment(_xMetaData,_xDestTable,_rvColumns));
        Reference< XParameters > xParameter(xPrep,UNO_QUERY);
 
-
        sal_Int32 nRowCount = 0;
        const Any* pSelBegin    = _aSelection.getConstArray();
        const Any* pSelEnd              = pSelBegin + _aSelection.getLength();
@@ -853,6 +814,7 @@
        else
                
m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString::createFromAscii("S1000")
 ,0,Any()));
 }
+// 
-----------------------------------------------------------------------------
 //........................................................................
 }      // namespace dbaui
 //........................................................................

File [changed]: WColumnSelect.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/WColumnSelect.cxx?r1=1.17&r2=1.17.40.1
Delta lines:  +4 -3
-------------------
--- WColumnSelect.cxx   19 Jan 2006 15:44:12 -0000      1.17
+++ WColumnSelect.cxx   9 Mar 2006 07:47:16 -0000       1.17.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: WColumnSelect.cxx,v $
  *
- *  $Revision: 1.17 $
+ *  $Revision: 1.17.40.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/19 15:44:12 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -386,6 +386,7 @@
 
                        _pRight->SetEntryData( _pRight->InsertEntry( 
(*aIter).first, nPos),aSrcIter->second );
                        _rRightColumns.push_back((*aIter).first);
+            m_pParent->removeColumnNameFromNameMap(_sColumnName);
                }
        }
 }

File [changed]: WCopyTable.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/WCopyTable.cxx?r1=1.42&r2=1.42.40.1
Delta lines:  +70 -6
--------------------
--- WCopyTable.cxx      19 Jan 2006 15:44:34 -0000      1.42
+++ WCopyTable.cxx      9 Mar 2006 07:47:16 -0000       1.42.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: WCopyTable.cxx,v $
  *
- *  $Revision: 1.42 $
+ *  $Revision: 1.42.40.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/01/19 15:44:34 $
+ *  last change: $Author: oj $ $Date: 2006/03/09 07:47:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -102,6 +102,9 @@
 #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
@@ -179,11 +182,18 @@
                                m_sSourceName = 
::dbtools::composeTableName(m_xConnection->getMetaData(),m_xSourceObject,sal_False,::dbtools::eInDataManipulation);
                        else
                                _xSourceObject->getPropertyValue(PROPERTY_NAME) 
>>= m_sSourceName;
+            if ( m_xSourceConnection == m_xConnection )
+            {
+                Reference<XTablesSupplier> xSup(m_xConnection,UNO_QUERY_THROW);
+                m_sName = 
::dbtools::createUniqueName(xSup->getTables(),m_sSourceName,sal_False);
+            }
+            else
                        m_sName = m_sSourceName;
                }
        }
-       catch(Exception)
+       catch(const Exception&)
        {
+        m_sName = m_sSourceName;
        }
 }
 // 
-----------------------------------------------------------------------------
@@ -210,12 +220,17 @@
        ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
        ,m_xFactory(_rM)
        ,m_sName(_rDefaultName)
-       ,m_vSourceVec(_rSourceColVec)
        ,m_xSourceConnection(_xConnection) // in this case source connection 
and dest connection are the same
        ,m_bDeleteSourceColumns(sal_False)
 {
        DBG_CTOR(OCopyTableWizard,NULL);
        construct();
+    ODatabaseExport::TColumnVector::const_iterator aIter = 
_rSourceColVec.begin();
+    ODatabaseExport::TColumnVector::const_iterator aEnd = _rSourceColVec.end();
+    for (; aIter != aEnd ; ++aIter)
+    {
+        m_vSourceVec.push_back(m_vSourceColumns.find((*aIter)->first));
+    }
 }
 // 
-----------------------------------------------------------------------------
 void OCopyTableWizard::construct()
@@ -430,6 +445,50 @@
                                                return 0;
                                        }
                                }
+                if ( m_xConnection.is() )
+                   {
+                    sal_Bool bPKeyAllowed = sal_False;
+                    try
+                    {
+                               Reference< XDatabaseMetaData >  
xMetaData(m_xConnection->getMetaData());
+                               bPKeyAllowed = 
xMetaData->supportsCoreSQLGrammar();
+                    }
+                    catch(const Exception&)
+                    {
+                        OSL_ENSURE(0,"Exception caught while asking for 
supportsCoreSQLGrammar!");
+                    }
+                    if ( bPKeyAllowed )
+                    {
+                        ODatabaseExport::TColumns::iterator aFind = 
::std::find_if(m_vDestColumns.begin(),m_vDestColumns.end()
+                            
,::std::compose1(::std::mem_fun(&OFieldDescription::IsPrimaryKey),::std::select2nd<ODatabaseExport::TColumns::value_type>()));
+                        if ( aFind == m_vDestColumns.end() )
+                        {
+                            String 
sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
+                                       String 
sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY));
+                                       OSQLMessageBox aBox(this, sTitle,sMsg, 
WB_YES_NO_CANCEL | WB_DEF_YES);
+
+                                       INT16 nReturn = aBox.Execute();
+
+                                       switch(nReturn )
+                            {
+                                case RET_YES:
+                                {
+                                    OCopyTable* pPage = 
reinterpret_cast<OCopyTable*>(GetPage(0));
+                                    m_bCreatePrimaryColumn = sal_True;
+                                    m_aKeyName = pPage->GetKeyName();
+                                    sal_Int32 nBreakPos = 0;
+                                                   CheckColumns(nBreakPos);
+                                    break;
+                                }
+                                case RET_CANCEL:
+                                    ShowPage(3);
+                                    return 0;
+                                default:
+                                    ;
+                            }
+                        }
+                    }
+                }
                                break;
                        }
                        case WIZARD_APPEND_DATA:
@@ -1002,6 +1061,11 @@
        OSL_ENSURE(m_mNameMapping.find(_sColumnName) == 
m_mNameMapping.end(),"name doubled!");
        m_mNameMapping[_sColumnName] = sAlias;
        return sAlias;
+}
+// 
-----------------------------------------------------------------------------
+void OCopyTableWizard::removeColumnNameFromNameMap(const ::rtl::OUString& 
_sName)
+{
+    m_mNameMapping.erase(_sName);
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool OCopyTableWizard::supportsType(sal_Int32 _nDataType,sal_Int32& 
_rNewDataType)




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

Reply via email to